LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2009, 08:20 PM   #1
RaySwen
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Rep: Reputation: 0
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?

Thanks
 
Old 04-07-2009, 10:13 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 04-07-2009, 10:50 PM   #3
RaySwen
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Hi Graemef, thanks 4 your reply.

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
 
Old 04-07-2009, 11:02 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 04-08-2009, 03:49 AM   #5
RaySwen
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
I just made a big mistake!

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?
 
Old 04-08-2009, 04:08 AM   #6
RaySwen
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
I've fixed that stupid mistake, and came back to the main issue. Wish i could worked it out soon.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Debian as a passthru router w/sniffer Gen_Hawk Linux - Networking 2 07-07-2008 05:59 PM
calling a function from within another function in php jayakrishnan Programming 2 06-19-2007 08:36 AM
Passing one php function result as a parameter to another php function davee Programming 13 09-12-2004 12:08 PM
File Permission Error in PHP fopen() function tuka Linux - Software 2 08-12-2003 08:16 PM
PHP EXEC() and PASSTHRU() Security crazyace Linux - Security 2 12-29-2002 07:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration