I require a sudoers to be able to execute following command
sudo -u myAppUser /opt/myapp/bin/myapp.Console.pl Admin::User::Add <some optional parameters>
I've created a group myAppExecGroup
and added myTestUser
to the group
Cmnd_Alias MYAPPADDCMD = /opt/myapp/bin/myapp.Console.pl Admin\:\:User\:\:Add *
%myAppExecGroup ALL= (myAppUser) NOPASSWD: MYAPPADDCMD
as a counter test I tried this simple reboot, which works well
Cmnd_Alias POWER = /sbin/shutdown, /sbin/halt, /sbin/reboot, /sbin/restart
%myAppExecGroup ALL= (root) NOPASSWD: POWER
also tried this, which is not working at all and asks for password
Cmnd_Alias IFCONFIG = /sbin/fdisk --list
%myAppExecGroup ALL= (root) NOPASSWD: IFCONFIG
So I am not clear if I have a general lack of understanding or if I am facing a usage issue, which is hindering my requirement?
update 1:
this script can simulate the above named command
mkdir -p /opt/myapp/bin/
echo > /opt/myapp/bin/myapp.Console.pl
chmod 755 /opt/myapp/bin/myapp.Console.pl
tee -a /opt/myapp/bin/myapp.Console.pl <<EOF
#!/bin/bash
echo \$@
echo \$USER
EOF
update 2:
if using root instead of myAppUser
%myAppExecGroup ALL= (root) NOPASSWD: MYAPPADDCMD
the command executes. But I require myAppUser environment?!?