LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-Apr-2008, 08:04 PM
Jacques Sauve
NNTP User
 
Posts: n/a
Default Network Restart Problem

$(UHello to all,

I realize this forum is not meant to support PHP, but I have an issue and I suspect it has more to do with SLES and permissions than the actual PHP code, so if you're a SLES expert, please bear with me and see if you have any ideas!

Thanks!

;-)


We are developing a Web interface that will allow the user to configure the networking parameters for a SLES 10 SP1 server: IP address, mask, DNS, gateway, hostname and domain.

The first issue we came across was the the Apache/PHP user (wwwrun) was not allowed to leave the /srv/www/htdocs to write to the required files, which we determined to be the following:

IP address: /etc/sysconfig/network/ifcfg-eth-<mac address>
Gateway: /etc/sysconfig/network/routes
DNS and domain: /etc/resolv.conf
Hostname: /etc/HOSTNAME

The workaround: set the group ownership of the above files to "www", then create a link to these files under a directory we created under htdocs -> /srv/www/htdocs/etc.

The user then modifies the parameters in the web interface, and the programmers have written the PHP code that writes all of these parameters to the linked files under htdocs/etc.

So far, so good...this works great and all the parameters are properly written to the appropriate files.

The last command of the PHP file that makes all of these changes simply goes like this:

system('sudo /etc/init.d/network restart');

And this is where things go down the toilet...

7 times out 10, after we change the IP address, we just lose all connection to the server. Even if we go directly on the server, we cannot ping anything else on the network. The "ifconfig" command shows the new address we've configured. If we then do "/etc/init.d/network restart", then everything works! All communication to the server is restored. The other 3 times out of 10, then everything works fine: the address is changed and we can immediately connect to the new address!

Things I discovered along the way: to execute the sudo command, we needed to modify the /etc/sudoers file. We added the following line:

wwwrunALL=NOPASSWD: /etc/init.d/network

then flagged the the file 440 (as per a console message when I tried to run a sudo command from a user account).

On the surface...it looks like everything should work fine. But why only 3 TIMES OUT OF 10??

Any ideas would be VERY appreciated, before ALL of my hair turns gray!

Thanks!

Jacques
Reply With Quote
 

Thread Tools
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -6. The time now is 08:36 AM.


© 2007 Novell, Inc. All Rights Reserved.

Search Engine Friendly URLs by vBSEO 3.3.0 RC2