Would be possible to run a custom bash function with different priviledges?
#!/bin/bash
function RunStefano() {
while [ 1 ]; do
echo "Ciao, ´/usr/bin/whoami´"
sleep 10;
done &
}
export -f RunStefano;
echo "Welcome, ´/usr/bin/whoami´"
sudo -u stefano -c "RunStefano"
If I run this script with 'root' user, I want to receive as output:
Welcome, root
Ciao, stefano
(...)
Ciao, stefano
Would it be possibile?
Yes, this is possible
#!/bin/bash
function1(){
echo `whoami`
}
export -f function1
su username -c "bash -c function1"
exit 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With