Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a script that can execute commands as super user

Status
Not open for further replies.

dl01

Technical User
Jun 25, 2001
15
NL
I want to add a script to my crontab to delete some logs that grow very quickly on a weekly basis. Unfortunatlty when the files are created only root has the delete privledges. How can I run a script from a regular users login that will change to super user, delete the files then change back?
 
Hi DDAANN,

the best solution is to install sudo and give this user the appropriate rights to delete these files.

mrjazz [pc2]
 
You could make any script run commands as root as setting the owner of the script to be root (chown root script_name) then making the script run as setuid using chmod BUT this is a very bad idea as it is virtually impossible to make the script "hacker proof" and therefore you end up with a major security violation. By using any number of well known and well published tricks a malicious user could use your setuid script to gain root access to your system and then wreak havoc.

The securest method of doing this task is to write a program in C that will run as setuid root but only assumes root powers for the barest minimum time and has strict control coded in to limit which files can be deleted.
 
Have you though of modifying the crontab entry for the root and adding Ur deletion script there ?
amit
crazy_indian@lycos.com

to bug is human to debug devine
 
newmangj's concerns are legitimate, and brings up another issue: several flavors of unix ignore suid bits on shell scripts for exactly this reason.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top