Reputation: 31
Is there a special group or a capability (similar to Linux' CAP_NET_xxx) that would enable a user to change network settings programmatically on Mac OS X? The settings I am interested in are the IP address and netmask of an interface, set programmatically from a C program (via an ioctl call, sending an ifreq struct). The user type I am using at the moment is a stock "Admin" account on my Mac laptop. Ultimately, I wish for my program to add the user once to such a convenient group so that in subsequent runs the user can manipulate the IP address of interfaces without prompting.
Thanks
Upvotes: 2
Views: 868
Reputation: 94829
Mac OS X will pretty much require root
privileges to change any network settings. You would need to run the program as root
in order to change the settings. As mentioned by @edufinn, the sudo
command is ideal for this.
However, if you want to change the configuration in a supported manner you should try one of the following approaches:
scutil
command.networksetup
command, which allows easy getting/setting of values.Changing the configuration through these APIs will inform applications that the network configuration has changed so they can react appropriately - e.g. make/reset a connection.
Upvotes: 1
Reputation: 2447
Mac OS X is BSD system. You can run your program with sudo
command. It's not very obvious from your post what is exactly a problem?
Upvotes: 0