fix sudo when sshs to other server

when myshellconfig is configured for root and you logged in via sshs,
sudo does not work correctly.

not it takes the temporary bashrc for sshs also for sudo
This commit is contained in:
Jakobus Schürz 2022-11-16 11:36:09 +01:00
parent 64025490e1
commit 66d7bf5263

View file

@ -49,8 +49,11 @@ function cpb() {
function sudo() {
local SUDO
local BASH
# SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi )
SUDO=$(which sudo)
[ getbashrcfile ] && BASH="bash --rcfile $(getbashrcfile)" || unset BASH
$SUDO \
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
@ -62,6 +65,7 @@ function sudo() {
SSH_TTY="$SSH_TTY" \
SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \
http_proxy="$http_proxy" \
$BASH \
"$@"
}
@ -339,9 +343,12 @@ mkcd () {
sshmyshellconfig() {
ENTRY
[ -z "${MSC_SUBPATH+x}" ] && MSC_SUBPATH=".local/myshellconfig"
[ -z "${MSC_BASE+x}" ] && MSC_BASE="${HOME}/${MSC_SUBPATH}"
#MSC_GIT_REMOTE_NAME=$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)
echo MSC_GIT_REMOTE_NAME: $MSC_GIT_REMOTE_NAME
MSC_GIT_REMOTE_NAME=$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)
echo MSC_GIT_REMOTE_NAME: $MSC_GIT_REMOTE_NAME
MSC_BASE_PARENT="$(dirname $MSC_BASE)"
if [ $1 == "localhost" ]; then
@ -352,6 +359,7 @@ sshmyshellconfig() {
local CMD="$SSH -T $@"
fi
$CMD /bin/bash << EOF
set -x
[ -e /etc/bashrc ] && . /etc/bashrc
[ -e /etc/bash.bashrc ] && . /etc/bash.bashrc
echo "modify ~/.bashrc"
@ -365,8 +373,8 @@ sshmyshellconfig() {
rm -rf ~/server-config && echo rm -rf ~/server-config
echo mkdir -p ~/.local
mkdir -p ~/.local
echo git clone --recurse-submodules $(git remote get-url origin) \${HOME}/${MSC_SUBPATH}
git clone --recurse-submodules $(git remote get-url origin) \${HOME}/${MSC_SUBPATH}
echo git clone --recurse-submodules $(git remote get-url $MSC_GIT_REMOTE_NAME) \${HOME}/${MSC_SUBPATH}
git clone --recurse-submodules $(git remote get-url $MSC_GIT_REMOTE_NAME) \${HOME}/${MSC_SUBPATH}
date "+%s" > \${HOME}/${MSC_SUBPATH}/.last_update_submodules
# date "+%s" > \${HOME}/${MSC_SUBPATH}/.last_update_repo
@ -558,6 +566,7 @@ getbashrcfile () {
ENTRY
if [ -z ${BASHRC+x} ] ; then
loginfo "bash uses default"
return 1
else
cat /proc/$$/cmdline | xargs -0 echo|awk '{print $3}'
fi
@ -568,6 +577,7 @@ catbashrcfile () {
ENTRY
if [ -z ${BASHRC+x} ] ; then
loginfo "bash uses default"
return 1
else
#cat $(cat /proc/$$/cmdline | xargs -0 echo|awk '{print $3}')
cat $(getbashrcfile)