From 9c68cd53fce6c30573aca286babf7889ba824a7f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 20 Sep 2019 01:25:42 -0400 Subject: [PATCH] refactor: remove ssh-keys user-auth trigger in favor of direct check in dokku binary --- dokku | 4 ++-- plugins/ssh-keys/user-auth | 14 -------------- 2 files changed, 2 insertions(+), 16 deletions(-) delete mode 100755 plugins/ssh-keys/user-auth diff --git a/dokku b/dokku index 80a902e88..1cf34149d 100755 --- a/dokku +++ b/dokku @@ -87,13 +87,13 @@ if [[ "${args[0]}" =~ ^--.* ]]; then fi ! 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) sudo -u dokku -E -H "$0" "$@" exit $? 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 dokku_log_fail "This command must be run as root" else diff --git a/plugins/ssh-keys/user-auth b/plugins/ssh-keys/user-auth deleted file mode 100755 index 6fea1dca8..000000000 --- a/plugins/ssh-keys/user-auth +++ /dev/null @@ -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