Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP running a root system command (mount)

dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,095
#1: Jul 13 '09
Has anyone done anything that requires PHP to be it's normal user (i.e. apache, and not running as root) but still execute a root level shell command such as mount?

Solutions so far that has failed to work is:

"Write a C++ program that will do the mount and execute it with permission rws instead of rwx"

It still prompts for sudo password. If i'm doing something wrong here, I'll post it in the Linux section, but for now are there any routes to this problem?



Thanks,




Dan

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,948
#2: Jul 13 '09

re: PHP running a root system command (mount)


Funnily enough, I'm in the processing of writing a (extension) wrapper for gksu - basically providing a way for PHP to run commands as a super-user.

I'll get back to you when I'm done.

Edit: I see that is probably not what you want. Do you want to avoid asking for the password altogether?
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,095
#3: Jul 13 '09

re: PHP running a root system command (mount)


Yes, no password asking.

I'm in a secure environment and not worried about any internet-facing holes that it may have. I have the freedom to loosen up my leash.

Let me know how your program goes (especially if it accomplishes my task).

Thanks n00b ;)



Dan
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,948
#4: Jul 13 '09

re: PHP running a root system command (mount)


It may be a possibility - I'll do some playing about with the API, see if it allows you to hardcode the password in. Other than hard-coding it, my plans are of no use to you! :P

Thanks ... Dan

Mark (wishes Dan had a sordid past that I knew of!)
Reply

Tags
mount, php, root command