ensure we run plugin commands as root. closes #1768
This commit is contained in:
4
Makefile
4
Makefile
@@ -72,10 +72,10 @@ version:
|
|||||||
git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ~dokku/VERSION
|
git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ~dokku/VERSION
|
||||||
|
|
||||||
plugin-dependencies: plugn
|
plugin-dependencies: plugn
|
||||||
dokku plugin:install-dependencies --core
|
sudo -E dokku plugin:install-dependencies --core
|
||||||
|
|
||||||
plugins: plugn docker
|
plugins: plugn docker
|
||||||
dokku plugin:install --core
|
sudo -E dokku plugin:install --core
|
||||||
|
|
||||||
dependencies: apt-update sshcommand plugn docker help2man man-db
|
dependencies: apt-update sshcommand plugn docker help2man man-db
|
||||||
$(MAKE) -e stack
|
$(MAKE) -e stack
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ elif [[ -n $DOKKU_TAG ]]; then
|
|||||||
elif [[ "$major" -eq "0" ]] && [[ "$minor" -ge "4" ]] && [[ "$patch" -ge "0" ]]; then
|
elif [[ "$major" -eq "0" ]] && [[ "$minor" -ge "4" ]] && [[ "$patch" -ge "0" ]]; then
|
||||||
export DOKKU_CHECKOUT="$DOKKU_SEMVER"
|
export DOKKU_CHECKOUT="$DOKKU_SEMVER"
|
||||||
dokku_install_package
|
dokku_install_package
|
||||||
dokku plugin:install-dependencies --core
|
sudo -E dokku plugin:install-dependencies --core
|
||||||
else
|
else
|
||||||
export DOKKU_CHECKOUT="$DOKKU_TAG"
|
export DOKKU_CHECKOUT="$DOKKU_TAG"
|
||||||
dokku_install_source
|
dokku_install_source
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
dokku_install_package
|
dokku_install_package
|
||||||
dokku plugin:install-dependencies --core
|
sudo -E dokku plugin:install-dependencies --core
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
6
dokku
6
dokku
@@ -49,12 +49,16 @@ if [[ "${args[0]}" =~ ^--.* ]]; then
|
|||||||
fi
|
fi
|
||||||
! has_tty && DOKKU_QUIET_OUTPUT=1
|
! has_tty && DOKKU_QUIET_OUTPUT=1
|
||||||
|
|
||||||
if [[ $(id -un) != "dokku" && $1 != plugin:*install* && $1 != "plugin:update" ]]; then
|
if [[ $(id -un) != "dokku" ]] && [[ ! $1 =~ plugin:* ]]; 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
|
||||||
|
|
||||||
|
if [[ $(id -un) != "root" && $1 =~ plugin:.* ]]; then
|
||||||
|
dokku_log_fail "plugin:* commands must be run as root"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
|
if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
|
||||||
export -n SSH_ORIGINAL_COMMAND
|
export -n SSH_ORIGINAL_COMMAND
|
||||||
if [[ $1 =~ config-* ]] || [[ $1 =~ docker-options* ]]; then
|
if [[ $1 =~ config-* ]] || [[ $1 =~ docker-options* ]]; then
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ teardown() {
|
|||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
|
run bash -c "sudo -E -u nobody dokku plugin:uninstall $TEST_PLUGIN_NAME"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_failure
|
||||||
|
|
||||||
run bash -c "dokku plugin:disable $TEST_PLUGIN_NAME"
|
run bash -c "dokku plugin:disable $TEST_PLUGIN_NAME"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
@@ -43,3 +48,25 @@ teardown() {
|
|||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_failure
|
assert_failure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(plugin) plugin:install, plugin:disable, plugin:uninstall as non-root user failure" {
|
||||||
|
run bash -c "sudo -E -u nobody dokku plugin:install $TEST_PLUGIN_GIT_REPO"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run bash -c "dokku plugin | grep enabled | grep $TEST_PLUGIN_NAME"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run bash -c "sudo -E -u nobody dokku plugin:disable $TEST_PLUGIN_NAME"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user