You need to look into suidperl for running as root (or another user). The notes at suidperl will tell you how to configure it if you don't have it already; look in your Perl docs for more information beyond that.
As for cron, check to see if your system allows a crontab file per user; if so, just put commands in that. | [reply] |
Yes.
Longer answer: if you have the script set as set user ID root, you can run it as root. However, there may well be restrictions as to where the script must be located, what its other permissions must be, etc. And Perl may invoke taint checking when run setuid.
As far as cron, there are crontab entries for both the system (root) and individual users, at least on my Linux system (you don't say what kind of Unix system you have). If you're root, you can add crontab entries that will run as root. | [reply] |
You can but be very very careful. The O'Reilly book CGI Programming has a good write-up on the problems inherent in running CGI scripts as a privileged user.
One problem is that if you run your scripts as root and they receive user input, then a clever user can submit special characters in his strings in order to execute arbitrary commands as root. One trick is to place a semicolon in the input which will indicate the end of a command. If you are submitting your user input as a string for execution using backticks then what comes after can be brand new executing commands that you did not write.
People more clever than I am are also able to induce an error condition using their input. The script can stop but it remains as root with the user logged in. A dangerous condition.
If you go this route try and use Perl's taint module. It warns you if you are executing user input or doing other no-no's. | [reply] |