From febd54d35458f17529829eece5323538c18d6ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 11 Jan 2023 09:47:46 +0100 Subject: [PATCH] improve sudo for sshs --- functions.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/functions.sh b/functions.sh index 3d1c0ad..c2c5bd8 100755 --- a/functions.sh +++ b/functions.sh @@ -50,24 +50,35 @@ function cpb() { function sudo() { local SUDO local BASH + local C # SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi ) SUDO=$(which sudo) - [ getbashrcfile ] && BASH="bash --rcfile $(getbashrcfile) -c " || unset BASH + if $SSHS ; then - logwarning "TEMPCONFIG" + logdebug "TEMPCONFIG" + logdebug "\$1: $1" + [ -e "$(which $1 2>/dev/null)" ] && C="x" + logdebug "C: $C" + [ getbashrcfile ] && BASH="bash --rcfile $(getbashrcfile) ${C:+-c}" || unset BASH + logdebug "BASH1: $BASH" + [ -z "${C:-x}" ] && unset BASH + logdebug "BASH2: $BASH" else - logwarning "NO Tempconfig" + logdebug "NO Tempconfig" + unset BASH fi + logdebug "SUDO: $SUDO" + logdebug "BASH3: $BASH" + logdebug "SHLVL: $SHLVL" + logdebug "@: $@" + [ -z "${C:-x}" ] && logwarn "run $1 -> $(which $1)" - logwarning "SUDO: $SUDO" - logwarning "BASH: $BASH" - logwarning "SHLVL: $SHLVL" - logwarning $SUDO \ + logdebug $SUDO \ GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \ GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \ GIT_COMMITTER_EMAIL="$GIT_COMMITTER_EMAIL" \ @@ -79,7 +90,7 @@ function sudo() { SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \ http_proxy="$http_proxy" \ $BASH \ - "$@" + $@ $SUDO \ GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \ GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \ @@ -92,8 +103,8 @@ function sudo() { SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \ http_proxy="$http_proxy" \ $BASH \ - "$@" - + $@ + } create_symlinks() {