rename to tsudo

This commit is contained in:
Jakobus Schürz 2024-10-28 17:51:50 +01:00
parent c5ddb22e60
commit 842c32a14e

View file

@ -1467,21 +1467,28 @@ EOF
eval $SHOPTEXTGLOB eval $SHOPTEXTGLOB
} }
chuser () { if ${SSHS-false}
[ $(id -u) -gt 0 ] && return then
u_id="$(id -u $1)" echo declare tsudo
g_id="$(id -g $1)" tsudo () {
[ $(id -u) -gt 0 ] && return 1
[ $# -eq 0 ] && return 2
local u_id="$(id -u $1)"
local g_id="$(id -g $1)"
local b_rc=$(getbashrcfile)
local v_rc=$(getvimrcfile)
install -o ${u_id} -g ${g_id} -m 0700 /run/user/${u_id} install -d -o ${u_id} -g ${g_id} -m 0700 /run/user/${u_id}
cat << EOF local bashrctmp="/tmp/$(basename ${b_rc})"
u_id: ${u_id} local vimrctmp="/tmp/$(basename ${v_rc})"
g_id: ${g_id} [ -n "${getbashrcfile:-x}" ] && install -o ${u_id} -g ${g_id} -T ${b_rc} "${bashrctmp}"
$(ls /run/user) [ -n "${getvimrcfile:-x}" ] && install -o ${u_id} -g ${g_id} -T ${v_rc} "${vimrctmp}"
EOF sed -i -e 's;\(bashrctmp=\)\(.*$\);\1'${bashrctmp}';' $bashrctmp
cp ${getbashrcfile} /run/user/${u_id}/. sed -i -e 's;\(vimrctmp=\)\(.*$\);\1'${vimrctmp}';' $bashrctmp
cp ${getvimrcfile} /run/user/${u_id}/. sudo -u ${1} /bin/bash --rcfile ${bashrctmp}
} }
fi
#EOF #EOF