LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Automating Linux Administration through Web Interface (http://www.linuxquestions.org/questions/linux-server-73/automating-linux-administration-through-web-interface-824358/)

Hi_This_is_Dev 08-05-2010 09:30 AM

Automating Linux Administration through Web Interface
 
Hi,


The question that I am posting here is quite interesting as it was asked in the interview I attended today. And, honestly, I could not provide a solution.

Ok, here goes the problem statement:

Design a Web Interface that has three text fields:

IP Address:
Subnet Mask:
Default Gateway:


And a button:

Submit

When we click the Submit button, the two entries must be set in the concerned files and then the network service must be restarted to bring the new IP Address, Subnet Mask, and Default Gateway in effect.

As we all know that these settings can be done by the root user or a user who has those priveleges.

So, finally, how can we achieve it?

The complete web interface needs to be done only in PHP. Some Shell Script can be used if required.

SciFi-Bob 08-05-2010 06:46 PM

One method, is to make a shell (bash) script to do it, and put it in sudoers, so that the web service can execute it.

I have a few of these "root scripts" that works just fine.

An example on ubuntu, in /etc/sudoers:

www-data ALL=NOPASSWD: /www/scanfile.sh

This allows me to run "exec('/usr/bin/sudo /www/scanfile.sh')"
in PHP as root.


All times are GMT -5. The time now is 10:36 AM.