Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

exec() problem

Links for php scripts

Moderators: macek, egami, gesf

exec() problem

Postby DeathRipple » Tue Nov 19, 2002 7:09 am

i have a problem: i need to execute in a php script some commands that require root access. of course this can't be done just by typing exec($cmd) since all the statements in a php file will be executed under user apache (of whatever user you have set in httpd.conf).
example:
$cmd="useradd user";
$cmd="smbpasswd -a user pass";

can anyone please help me? (if possible please give me full detals about all steps that are to be taken)

thanks
DeathRipple
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Nov 19, 2002 6:00 am

Re: exec() problem

Postby WiZARD » Wed Nov 20, 2002 1:32 am

DeathRipple wrote:i have a problem: i need to execute in a php script some commands that require root access. of course this can't be done just by typing exec($cmd) since all the statements in a php file will be executed under user apache (of whatever user you have set in httpd.conf).
example:
$cmd="useradd user";
$cmd="smbpasswd -a user pass";

can anyone please help me? (if possible please give me full detals about all steps that are to be taken)

thanks

Hi!
At your place i'll be create new user under Unix/Linux with permissions to create/manage users (cuted admin). But not recomended using root account to do this.
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby DeathRipple » Wed Nov 20, 2002 6:06 am

it's not the account that bothers me...iyou suggest to create such an user and to put the web server to run with it (to modify httpd.conf)? i don't want that....i just want a way to put me in the position of executing command as another user within the php, than to get back to the apache user.....got it?
DeathRipple
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Nov 19, 2002 6:00 am

Postby WiZARD » Sat Nov 23, 2002 7:27 am

DeathRipple wrote:it's not the account that bothers me...iyou suggest to create such an user and to put the web server to run with it (to modify httpd.conf)? i don't want that....i just want a way to put me in the position of executing command as another user within the php, than to get back to the apache user.....got it?

Sorry if don't understand you firstly...
Yes you may do it, but you need create 2 scripts under C/Bash shell for login_for and logout_for for SU command and after that you may do all what you want.
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron