refactor: remove ssh-keys user-auth trigger in favor of direct check in dokku binary
This commit is contained in:
1 parent
3b3fc5d5c1
commit
9c68cd53fc
2 files changed
+2
-16
No files matched your search
@@ -87,13 +87,13 @@ 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" ]]; then
|
if [[ $(id -un) != "dokku" ]] && [[ ! $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
|
||||||
|
|
||||||
if [[ $1 =~ ^plugin:.* && $1 != "plugin:help" && $1 != "plugin:list" ]] || [[ $1 == "ssh-keys:add" ]]; 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
|
||||||
dokku_log_fail "This command must be run as root"
|
dokku_log_fail "This command must be run as root"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -eo pipefail
|
|
||||||
[[ $DOKKU_TRACE ]] && set -x
|
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
||||||
|
|
||||||
check_ssh_keys_user() {
|
|
||||||
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:add|ssh-keys:remove) ]]; then
|
|
||||||
check_ssh_keys_user "$@"
|
|
||||||
fi
|
|
||||||
Reference in new issue
Block a user