fix: drop tmpdir environment variables when not running as dokku user
This ensures that tmpdir (and related calls) respect the system defaults for temporary directory access. Critically, changing user via 'sudo' will leave the root temp directory in place, which causes dokku to have undefined behavior when writing to temporary files under libpam-tmpdir. This may break cases where users have redefined tmpdir or related variables, but those cases can be remedied by specifying a value for TMPDIR (and related variables) in /etc/default/dokku. Closes #3149
This commit is contained in:
5
dokku
5
dokku
@@ -88,11 +88,14 @@ if [[ "${args[0]}" =~ ^--.* ]]; then
|
|||||||
fi
|
fi
|
||||||
! has_tty && DOKKU_QUIET_OUTPUT=1
|
! has_tty && DOKKU_QUIET_OUTPUT=1
|
||||||
|
|
||||||
if [[ $(id -un) != "dokku" ]] && [[ ! $1 =~ plugin:* ]] && [[ $1 != "ssh-keys:add" ]] && [[ $1 != "ssh-keys:remove" ]]; then
|
if [[ $(id -un) != "dokku" ]]; then
|
||||||
|
unset TMP TMPDIR TEMP TEMPDIR
|
||||||
|
if [[ ! $1 =~ plugin:* ]] && [[ $1 != "ssh-keys:add" ]] && [[ $1 != "ssh-keys:remove" ]]; then
|
||||||
export SSH_USER=$(id -un)
|
export SSH_USER=$(id -un)
|
||||||
sudo -u dokku -E -H "$0" "$@"
|
sudo -u dokku -E -H "$0" "$@"
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $1 =~ ^plugin:.* && $1 != "plugin:help" && $1 != "plugin:list" ]] || [[ $1 == "ssh-keys:add" ]] || [[ $1 == "ssh-keys:remove" ]]; then
|
if [[ $1 =~ ^plugin:.* && $1 != "plugin:help" && $1 != "plugin:list" ]] || [[ $1 == "ssh-keys:add" ]] || [[ $1 == "ssh-keys:remove" ]]; then
|
||||||
if [[ $(id -un) != "root" ]]; then
|
if [[ $(id -un) != "root" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user