improve sudo for sshs
This commit is contained in:
parent
3384f79c62
commit
febd54d354
1 changed files with 21 additions and 10 deletions
29
functions.sh
29
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,7 +103,7 @@ function sudo() {
|
|||
SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \
|
||||
http_proxy="$http_proxy" \
|
||||
$BASH \
|
||||
"$@"
|
||||
$@
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue