I have developed a perl script which provides a menu driven functionality to allow users to carry out some simple tasks.
I need the users to be able to carry out tasks such as copying files (keeping the current date and permissions), running other programs (such as less or vi) as a different user. The script uses alot of use of the system() function. I want the users to start the menu by calling:
sudo -u perluser /usr/bin/perl /data/perlscripts/scripta.pl
This should start the script as perl user, which it does, and then carry out different tasks depending on what the user selects. The problem is that whenever I use a system call such as
system("clear");
I get the following error
Can't exec "clear": Permission denied at /data/perlscripts/scripta.pl line 3
If I run the script by logging in as perluser then it all runs succesfully.
Is there any way to get this working? I do not want users to be able to log in as perluser as I need to control what they are able to run. I also do not want to run a command like
system("sudo -u perluser clear");
as I would then require a different team to set up all the sudo commands I wanted to run (which they will probably refuse to do) and this would not be scalable if I have to add extra commands at somepoint.
Thanks,
I think you probably need to add the
-ioption (“simulate initial login”) tosudo:That will ensure that
.profileor.loginor whatnot is run properly, and therefore that$PATHis set up properly and so on. It will really be, in almost all respects, as ifperluserwere actually logging in and running/usr/bin/perl /data/perlscripts/scripta.plat the shell.