You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Only root can do this, and usually not fatal if it doesn't work, so */
#ifdef SO_BINDTODEVICE
if (channel->local_dev_name[0]) {
if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE,
channel->local_dev_name, sizeof(channel->local_dev_name))) {
/* Only root can do this, and usually not fatal if it doesn't work, so */
/* just continue on. */
}
}
#endif
However, SO_BINDTODEVICE works without needing root on at least Debian GNU/Linux and Alpine GNU/Linux. I suspect the same is true on other GNU/Linux distros as well.
On https://c-ares.haxx.se/ares_set_local_dev.html
ares_set_local_dev() says it needs root for this function to work, based on the code here:
c-ares/src/lib/ares_process.c
Line 1007 in 809d5e8
However, SO_BINDTODEVICE works without needing root on at least Debian GNU/Linux and Alpine GNU/Linux. I suspect the same is true on other GNU/Linux distros as well.
I use
ares_set_local_dev()
here: https://gitlab.com/kop316/mmsd/-/blob/master/src/service.c#L1287and SO_BINDTODEVICE here: https://gitlab.com/kop316/mmsd/-/blob/master/src/service.c#L3100
Both without root successfully. I suggest changing the documentation to reflect that root is not needed.
The text was updated successfully, but these errors were encountered: