Search code examples
linuxnetwork-programminginterfacepermissions

how to read/write the /etc/network/interfaces file


I need to allow my local webserver (localhost) to read and write the /etc/network/interfaces file on a linux system (ubuntu).

The data manipulation of the file is done, I just need to know the best way of granting www-data the permission to do it.

I guess I could first log in as root and set permission for all to edit the file (not a big security risk since it is a mediaplayer and won't be accessed by any other user).

I could also do some nifty grouping of the user, I guess... not so seasoned with these linux things.

Anyone have a good suggestion, or input on why my suggested method is bad?


Solution

  • I don't know why would you want to do this, but generally groups are handy for this:

    1. You create a new group, for example networking
    2. then you change the group of the file to this new group (and check that it has g+rw permission)
    3. finally you add www-data user to the networking group.
    4. (And possibly relog, since permissions are often cached; this may not be needed for www-data)