LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-24-2010, 11:04 AM   #1
wingram77090
LQ Newbie
 
Registered: Feb 2010
Posts: 1

Rep: Reputation: 0
Question 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);

Last edited by wingram77090; 02-25-2010 at 09:17 AM. Reason: update to be more specific and answer questions from posts
 
Old 02-24-2010, 11:41 AM   #2
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,081

Rep: Reputation: 231Reputation: 231Reputation: 231
What is your crontab line? It may be a PATH problem. You can set PATH in the crontab or specify full path to program.
 
Old 02-24-2010, 12:39 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,797

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Moved to Programming
 
Old 02-24-2010, 01:46 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,006

Rep: Reputation: 110Reputation: 110
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.

Last edited by tuxdev; 02-24-2010 at 01:47 PM.
 
Old 02-24-2010, 07:38 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 15,000

Rep: Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681Reputation: 1681
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...
 
  


Reply

Tags
cron, setuid


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I have a script owned as root and run as root by a user: setuid? stickey bit? abefroman Linux - Newbie 9 04-19-2008 05:15 PM
How To Run Cron As Root Harpo Suse/Novell 11 03-18-2007 10:23 AM
Can't run cron jobs as user, only root Kropotkin Linux - Newbie 5 11-10-2004 09:30 AM
setuid programs hang when run by non-root users in RH9 jbkrash Red Hat 0 09-21-2004 01:17 PM
setuid question, or how to run a program with different ID linuxfond Linux - Newbie 3 07-09-2004 04:27 AM


All times are GMT -5. The time now is 03:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration