POC service chgt user
This commit is contained in:
parent
a67e5c1a7a
commit
c3d86ec53a
20
poc_service
Executable file
20
poc_service
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
RUNAS="daemon"
|
||||
|
||||
sw_user(){
|
||||
curr_user=$( id -un )
|
||||
echo ">>> current user $curr_user"
|
||||
if [ ! $curr_user = $RUNAS ]
|
||||
then
|
||||
echo ">>> wrong user"
|
||||
echo ">>> commande $@"
|
||||
sudo -nu $RUNAS $@
|
||||
exit $?
|
||||
fi
|
||||
}
|
||||
|
||||
echo ">>> Args: $@"
|
||||
sw_user $0 $@
|
||||
|
||||
echo "Running command as $( id -un ), with args: $@"
|
Loading…
Reference in New Issue
Block a user