From d78af6a84362d828756d6916b84812c0d9429b83 Mon Sep 17 00:00:00 2001 From: Luis Rascao Date: Wed, 8 Aug 2018 00:51:49 +0100 Subject: Check for pipe write permission on start/attach A common pitfall when starting up Erlang nodes is to start them as root and then fail silently when switching to another user, improve this by providing a helpful error message when this happens. --- priv/templates/extended_bin | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'priv') diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 11a0abc..78f25e0 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -492,6 +492,11 @@ case "$1" in test -z "$PIPE_BASE_DIR" || mkdir -m 1777 -p "$PIPE_BASE_DIR" mkdir -p "$PIPE_DIR" + if [ ! -w "$PIPE_DIR" ] + then + echo "failed to start, user '$USER' does not have write privileges on '$PIPE_DIR', either delete it or run node as a different user" + exit 1 + fi relx_run_hooks "$PRE_START_HOOKS" "$BINDIR/run_erl" -daemon "$PIPE_DIR" "$RUNNER_LOG_DIR" \ @@ -555,6 +560,12 @@ case "$1" in exit 1 fi + if [ ! -w "$PIPE_DIR" ] + then + echo "failed to attach, user '$USER' does not have sufficient privileges on '$PIPE_DIR', please run node as a different user" + exit 1 + fi + shift exec "$BINDIR/to_erl" "$PIPE_DIR" ;; -- cgit v1.2.3