aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Rascao <[email protected]>2018-08-08 00:51:49 +0100
committerLuis Rascao <[email protected]>2018-08-09 18:53:13 +0100
commitd78af6a84362d828756d6916b84812c0d9429b83 (patch)
treea349b82dbfa4f04e53dce0b7dfc83b1a4d7a75b4
parentb69658a37a0cf62a45bc0de89551344b2cf38595 (diff)
downloadrelx-d78af6a84362d828756d6916b84812c0d9429b83.tar.gz
relx-d78af6a84362d828756d6916b84812c0d9429b83.tar.bz2
relx-d78af6a84362d828756d6916b84812c0d9429b83.zip
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.
-rwxr-xr-xpriv/templates/extended_bin11
1 files changed, 11 insertions, 0 deletions
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"
;;