Fix ssh-keys:add permission error

This commit is contained in:
Justin Clark committed 2016-08-12 16:01:05 -07:00
1 parent 3651e56ca5
commit 98ec2979ea
2 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -56,14 +56,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:* ]]; then if [[ $(id -un) != "dokku" ]] && [[ ! $1 =~ plugin:* ]] && [[ ! $1 == "ssh-keys:add" ]]; 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 if [[ $(id -un) != "root" && $1 =~ ^plugin:.* ]] || [[ $(id -un) != "root" && $1 == "ssh-keys:add" ]]; then
dokku_log_fail "plugin:* commands must be run as root" dokku_log_fail "This command must be run as root"
fi fi
if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
+2 -2
View File
@@ -3,11 +3,11 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
check_ssh_keys_user() { check_ssh_keys_user() {
declare desc="check user running ssh-keys" declare desc="check user passed by user-auth for ssh-keys plugin"
local SSH_USER=$1 SSH_NAME=$2 local SSH_USER=$1 SSH_NAME=$2
[[ "$SSH_USER" == "root" || "$SSH_NAME" == *admin* ]] || dokku_log_fail "You must be root, or a dokku admin, to execute this command" [[ "$SSH_USER" == "root" || "$SSH_NAME" == *admin* ]] || dokku_log_fail "You must be root, or a dokku admin, to execute this command"
} }
if [[ "$3" == ssh-keys* ]]; then if [[ "$3" =~ (ssh-keys:add|ssh-keys:remove) ]]; then
check_ssh_keys_user "$@" check_ssh_keys_user "$@"
fi fi