mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #2369 from dokku/u2mejc-issue2366
Fix ssh-keys:add permission error
This commit is contained in:
6
dokku
6
dokku
@@ -56,14 +56,14 @@ if [[ "${args[0]}" =~ ^--.* ]]; then
|
||||
fi
|
||||
! 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)
|
||||
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"
|
||||
if [[ $(id -un) != "root" && $1 =~ ^plugin:.* ]] || [[ $(id -un) != "root" && $1 == "ssh-keys:add" ]]; then
|
||||
dokku_log_fail "This command must be run as root"
|
||||
fi
|
||||
|
||||
if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
|
||||
|
||||
@@ -3,11 +3,11 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
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
|
||||
[[ "$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 "$@"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user