这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ version:
git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ~dokku/VERSION

plugin-dependencies: plugn
dokku plugin:install-dependencies --core
sudo -E dokku plugin:install-dependencies --core

plugins: plugn docker
dokku plugin:install --core
sudo -E dokku plugin:install --core

dependencies: apt-update sshcommand plugn docker help2man man-db
$(MAKE) -e stack
Expand Down
4 changes: 2 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ elif [[ -n $DOKKU_TAG ]]; then
elif [[ "$major" -eq "0" ]] && [[ "$minor" -ge "4" ]] && [[ "$patch" -ge "0" ]]; then
export DOKKU_CHECKOUT="$DOKKU_SEMVER"
dokku_install_package
dokku plugin:install-dependencies --core
sudo -E dokku plugin:install-dependencies --core
else
export DOKKU_CHECKOUT="$DOKKU_TAG"
dokku_install_source
fi
else
dokku_install_package
dokku plugin:install-dependencies --core
sudo -E dokku plugin:install-dependencies --core
fi

}
Expand Down
6 changes: 5 additions & 1 deletion dokku
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ if [[ "${args[0]}" =~ ^--.* ]]; then
fi
! 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)
sudo -u dokku -E -H $0 "$@"
exit $?
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
export -n SSH_ORIGINAL_COMMAND
if [[ $1 =~ config-* ]] || [[ $1 =~ docker-options* ]]; then
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/40_plugin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ teardown() {
echo "status: "$status
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"
echo "output: "$output
echo "status: "$status
Expand All @@ -43,3 +48,25 @@ teardown() {
echo "status: "$status
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
}