Skip to content

Commit

Permalink
cleaner su in launcher script
Browse files Browse the repository at this point in the history
The `-` option is there primarily for one side effect: it does`cd` to
riak user's HOME (/var/lib/riak).  Critically, this dir has the
erlang cookie file, which is read from the new node started as part of
some riak-admin commands (e.g., riak-admin test). It, however, creates
a barrier for env vars, which is undesirable.

If we cd manually into riak's HOME before the call to `su`, the piggy
node now can find the cookie in its cwd, and execution of the command
succeeds.
  • Loading branch information
Andrei Zavada committed Dec 29, 2021
1 parent c9ca1b5 commit 757084e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions rel/files/riak
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ fi

function maybe_su {
if [[ $EUID -ne 0 ]]; then
NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} PIPE_DIR=${PIPE_DIR} $*
$*
else
# freebsd su is fairly limited, so:
f=$RUNNER_GEN_DIR/su_piggy
cat >$f <<EOF
#!/bin/sh
NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} PIPE_DIR=$PIPE_DIR $*
EOF
chmod +x $f
$SU - riak $f
# if we are executing an admin command that spins up a
# (hidden) node to then execute custom erlang code via -eval,
# we need to cd to a dir containing the erlang cookie
# (previously implicitly done by su -, which option we have
# removed in order to allow any env vars to be available for
# the ultimate invocation of riak/riak-cs/stanchion)
cd {{platform_base_dir}}
$SU riak -c "$*"
fi
}

Expand Down

0 comments on commit 757084e

Please sign in to comment.