Skip to content

Commit debd415

Browse files
author
Andrei Zavada
committed
cleaner su in launcher script
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.
1 parent cb67886 commit debd415

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

rel/files/riak

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ fi
3838

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

0 commit comments

Comments
 (0)