Skip to content

-S: if not valid IP addr, treat it as a device name to bind to - #212

Closed
Jimmy-Z wants to merge 1 commit into
aarond10:masterfrom
Jimmy-Z:master
Closed

Jimmy-Z wants to merge 1 commit into
aarond10:masterfrom
Jimmy-Z:master

Conversation

@Jimmy-Z

@Jimmy-Z Jimmy-Z commented Aug 8, 2026 •

Copy link
Copy Markdown

solves #209

basically adds a single line of code, ares already has the facility to bind device, curl side doesn't need any change since the api takes address or interface name.

Comment thread src/dns_poller.c
} else {
WLOG("Bootstrap source address '%s' is not a valid IP literal", source_addr);
// otherwise treat it as a device/interface name
ares_set_local_dev(channel, source_addr);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? The ares docs say:

If SO_BINDTODEVICE is not supported or the setsocktop call fails (probably because of permissions), the error is silently ignored.

main.c daemon()izes before dns_poller_init which is the caller of this function dropping root will break this and running on a non-linux system will also not work but will no longer show a warning.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it without daemonizing and dropping root, it works.

@baranyaib90

Copy link
Copy Markdown
Contributor

This is fine by me.

@aarond10

Copy link
Copy Markdown
Owner

This is trivial enough to do if you need it but I don't like this patch in that it's a niche use case and it introduces a flag that is fundamentally incompatible with daemonizing, which is something that is generally a very good idea to do for security.

@aarond10 aarond10 closed this Sep 26, 2026
@Jimmy-Z

Jimmy-Z commented Sep 26, 2026

Copy link
Copy Markdown
Author

I don't get it, if a user doesn't use bind to device, daemonizing and dropping root would still work, this doesn't hurt anybody.

If a user do use it, we can still secure it by simply not start the program by root, and use capabilities to allow it to bind to device, which is better and modern practice.

BTW, daemonizing is not related to security, dropping root is.

@aarond10

aarond10 commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Sorry. I'll add something for this but will make it invalid to try to use options that won't work together.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants