1

I have a non root user that executes this C program - link to so that shall set the IP address, Netmask and set the interface up, it returns: SIOCSIFFLAGS: Permission denied

Is there any way I could logged in as a root allow my non root user to run this program that sets the IP?

0

1 Answer 1

0

At least on Linux, you could use capabilities to allow the program to do a limited set of things as if it had root privileges.

The relevant capability seems to be this:

CAP_NET_ADMIN Perform various network-related operations: * interface configuration; * administration of IP firewall, masquerading, and accounting; [...] 

And you can set the capability with setcap:

setcap cap_net_admin+ep /path/to/my_ifconfig 

The alternative, of course would be to make the program setuid root (chmod u+s), which would allow it to do anything root can do. That's obviously more risky, but should work on other systems too, not just Linux.

You may want to limit which users can execute the file with extra permissions with the usual file permission bits, for example to only allow members of the netadmins group to run it:

chown root.netadmins /path/to/my_ifconfig chmod 0710 /path/to/my_ifconfig 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.