Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ares_set_local_dev() works without root On Debian GNU/Linux and Alpine GNU/Linux #405

Open
kop316 opened this issue Jun 9, 2021 · 0 comments

Comments

@kop316
Copy link

kop316 commented Jun 9, 2021

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:

/* 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.

I use ares_set_local_dev() here: https://gitlab.com/kop316/mmsd/-/blob/master/src/service.c#L1287

and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants