LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Why won't redhat 4/5 cron run my setuid root program? (https://www.linuxquestions.org/questions/programming-9/why-won%27t-redhat-4-5-cron-run-my-setuid-root-program-791281/)

wingram77090 02-24-2010 11:04 AM

Why won't redhat 4/5 cron run my setuid root program?
 
I have a setuid root program. Works fine from the command line. I am running RedHat RHEL 4 & 5. Will not run when put in my crontab. I have tested the usuals - crontab line is correct (i.e., runs successfully if the program does not suid() to root)

I believe this to be a cron restriction that limits transitioning from root (which is running cron) to the userid of the crontab to run the command in the crontab line back to root (which my program does). If I run the same program under at, I get the same behavior (i.e., the command is scheduled and does not run successfully).

Here is the heart of the program
setuid(rootUid);
setgid(rootGid);
char * myCommand = getCommandString(argc, argv, myUid, myGid);
pid_t pid = fork();
if (pid == 0) system(myCommand);

dive 02-24-2010 11:41 AM

What is your crontab line? It may be a PATH problem. You can set PATH in the crontab or specify full path to program.

pixellany 02-24-2010 12:39 PM

Moved to Programming

tuxdev 02-24-2010 01:46 PM

Aiyaiyai.. this is a rooting just waiting to happen. Please configure and use sudo appropriately. And better yet, upgrade to something more recent than RH 4 or 5, that's like 10 years old by now.

chrism01 02-24-2010 07:38 PM

He probably meant RHEL 4 & 5 :)
People tend to be a bit careless about that, unless they're old enough to remember using RH 4 & 5...


All times are GMT -5. The time now is 07:17 PM.