Shell wrapper for sudo
I posted about sudo here:
https://forum.puppylinux.com/viewtopic.php?p=117577#p117577
Which has brought this issue back to my attention. I really don't know why sudo was working and then it wasn't.
Anyway, I developed a simple alternative, named 'sudo-sh', see these blog posts mid-2023:
https://bkhome.org/news/202306/goodbye-sudo-package.html
https://bkhome.org/news/202306/light-weight-replacement-for-sudo.html
But what about an app that calls the sudo executable? EasyOS doesn't have sudo, QV does but it doesn't work.
To fix this, I created a shell script named 'sudo'. I don't know if an app will refuse to run it, if it sees it isn't a binary executable, or doesn't have suid bit set. Also, it ignores all commandline options. Anyway, here it is, /usr/bin/sudo:
#!/bin/ash
C=''
while [ -n "$1" ];do
case "$1" in
-*)
case "$1" in
-g|-p|-U|-u|-C|-r|-t)
shift
;;
esac
;;
*)
C="$@"
;;
esac
shift
done
if [ -n "$C" ];then
exec sudo-sh ${PPID} ${C}
fi
This will only work in EasyOS and QV, that have sudo-sh. A simple test:
# su spot
# sudo urxvt
...a window pops up asking for the root password, then the urxvt terminal runs.
That sudo script is very simple, could be written in C.
Tags: quirky