improve sudo for sshs

This commit is contained in:
Jakobus Schürz 2023-01-11 09:47:46 +01:00
parent 3384f79c62
commit febd54d354

View file

@ -50,24 +50,35 @@ function cpb() {
function sudo() { function sudo() {
local SUDO local SUDO
local BASH local BASH
local C
# SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi ) # SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi )
SUDO=$(which sudo) SUDO=$(which sudo)
[ getbashrcfile ] && BASH="bash --rcfile $(getbashrcfile) -c " || unset BASH
if $SSHS ; then 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 else
logwarning "NO Tempconfig" logdebug "NO Tempconfig"
unset BASH
fi 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_EMAIL="$GIT_AUTHOR_EMAIL" \
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \ GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
GIT_COMMITTER_EMAIL="$GIT_COMMITTER_EMAIL" \ GIT_COMMITTER_EMAIL="$GIT_COMMITTER_EMAIL" \
@ -79,7 +90,7 @@ function sudo() {
SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \ SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \
http_proxy="$http_proxy" \ http_proxy="$http_proxy" \
$BASH \ $BASH \
"$@" $@
$SUDO \ $SUDO \
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \ GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \ GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
@ -92,7 +103,7 @@ function sudo() {
SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \ SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \
http_proxy="$http_proxy" \ http_proxy="$http_proxy" \
$BASH \ $BASH \
"$@" $@
} }