?
Solved

sudo not working for apache in php

Posted on 2005-03-24
4
Medium Priority
?
1,172 Views
Last Modified: 2012-06-27
I am trying tp get php to add a system user using sudo on redhat 9.  
Apache is running under user apache, the PHP and sudo command (sudo /usr/sbin/useradd -gpods -d/home/test11 -m test11 -p q) is correct I have edited the visudo for both users apache and steve, when I type in the command (under user steve) it works, but not when running it from php

$output = system("sudo /usr/sbin/useradd -gpods -d/home/test11 -m test11 -p q", $result1);

$result1 comes out as 127

any clues as it runs fine on suse 9.1
0
Comment
Question by:iqula
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:veedar
ID: 13626279
I assume it works by hand when you try it.

As a test replace useradd with /usr/bin/id
Does it say your root?
0
 

Author Comment

by:iqula
ID: 13629370
Thanks for that I have discovered that a 127 is some sort of PHP system error code, I tryed what you suggested and a few other non (root/sudo) commands like whoami and get the same result 127.  I think it has something to do with with PHP running the system command, I get the same result with exec and passthru.

any ideas would be appreciated
0
 
LVL 16

Accepted Solution

by:
manav_mathur earned 2000 total points
ID: 13630852
Apache supports its own sudo mechanism called suexec. Have a look at

http://httpd.apache.org/docs/suexec.html

0
 

Author Comment

by:iqula
ID: 13636327
I had to add the ini file so apache could run it.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

​Being a Managed Services Provider (MSP) has presented you  with challenges in the past— and by meeting those challenges you’ve reaped the rewards of success.  In 2014, challenges and rewards remain; but as the Internet and business environment evol…
Fine Tune your automatic Updates for Ubuntu / Debian
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question