permission problems about passthru() function in PHP
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
permission problems about passthru() function in PHP
I am using the passthru() function to permit the client changing the servers IP address in browser. But i found that the passthru() could not perform the ifconfig command. I believe it is the problem related to permission, cause when i change to command to ls the file list comes out.
Could anyone tell me how to relax the permission? or are there any other method to achieve the IP changing function by PHP?
Changing a servers IP address is not something that you would normally want to do. Once done you would then have problems connecting to the server. However having said that the command is normally restricted to the root user however you can give the rights to the web server by using sudo. But you really need to know what the consequences of such an action would be.
I am writing a multiple-server-manager in BS strucure. And each server would respond when i send broadcast. It is WLAN works. So changing IP function is a must in my project. And also i want to use more commands like mdadm to config the raid in the future. So if i work this problem out, i will benefit a lot in the further developing.
I tried your advice like this:
$command = "sudo ifconfig";
passthru($command);
Still there is no output in the browser. Because i've no idea where i should put the root pwd, i might be using it wrong. What changes should i make? Thanks a lot
sudo allows another user to run a command as if they were the superuser, but you need to prepare the groundwork beforehand by permitting you web server to run the selected command, check the man page for sudoers it explains it fairly well. With the sudo command you can provide the password in the -p switch.
I am using ubuntu. i am always logging in the system as the normal user and add sudo before the certain shells. And this time, i run "sudo chmod 640 /etc/sudoers" and found that i cannot use "sudo" anymore because the sudoers is not 440. but i can only change it back to use "sudo". It seems that i am trapped in the dead circle. How can i change the file back?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.