The settings I'm talking about are IP, subnet mask and default gateway (set and get). For setting all of these I use the ioctl
function along with options like SIOCSIFADDR
and SIOCSIFNETMASK
. For getting the IP and mask I use the same approach but with options like SIOCGIFADDR
. For getting default gateway I parse the file /proc/net/route
and read the corresponding default gateway address for the interface.
This whole thing works perfectly, but with root privilege. Is there any method to change these settings without giving root user ? This is a requirement which I could not resolve. Changing the ownership like this question may solve the problem by putting the code inside a separate executable and change ownership of that executable to root then calling it from the main application.
I just want to know if it is possible to change such settings without giving root access to the application.