|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem in using sudo
I'm trying to setup sudo in my php script I need to execute a process to perform some processing. in my /etc/sudoer file I currently have the line (I used "visudo" to edit it)
nobody ALL = NOPASSWD : /root/test/processreq and in my php script I have exec("sudo /root/test/processreq $param1 $param2"); However when I run the script it doesn't run the processing request. Is there something else I'm missing here? Also, do I need to reboot the linux box after I do visudo for it to take effect? |
|
#2
|
|||
|
|||
|
No you don't need to restart it.. But your problem is probably one of a few things (though none of them are php issues)..
1. Your machine is probably waiting for a user input for the sudo password (unless you set it so the user doesn't have to supply one) 2. You may be better off running a .sh to execute that if #1 is the case There are a few others, but I figure we should start with those obvious ones |
|
#3
|
||||
|
||||
|
Or as a quick hacklike fix, you can enable the root account. However, this causes issues around security.
Then again, I tend to agree with the idea that it is waiting for the password. Try the shell script, that might just work without causing too much security issues. |
|
#4
|
|||
|
|||
|
thanks is there any good example how do I do this with shell script and supply the parameter from php? sorry I'm new with linux
Quote:
|
|
#5
|
||||
|
||||
|
Well, I found this site
and this one But it still feels like you are setting yourself up to get hacked. Is this PHP script coming from the command line or on your web server? If it is from the web, perhaps you need to work on some creative CRON job running as a priviledged user. Also, search the ubuntu forums, there you can find a way to enable the root account so you can make a script run as root, but once again, you could be setting yourself up for a seriously bad day by running a script that requires root privileges from PHP, can you perhaps tell us what exactly you are trying to do? |
|
#6
|
|||
|
|||
|
If my linux box is setup as SELinux, will I still be able to do this?
Oh btw to get back to your question php script will be run as web server, it will submit a request for the user by running the executable in the background. the executable has only limited things that it can do and cannot take input from the user directly. Quote:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > Problem in using sudo |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|