geekman / mdns-repeater

mDNS repeater
GNU General Public License v2.0
193 stars 58 forks source link

Delay dropping of root privileges #22

Closed axkg closed 1 year ago

axkg commented 1 year ago

The early dropping of root privileges as introduced with #18 does not work for me, as binding an interface requires root. Without it mdns-repeater reports an error:

mdns-repeater: send setsockopt(SO_BINDTODEVICE): Operation not permitted

This PR delays the dropping of the root privileges and moves daemonize() post the opening of the sockets to ensure the pid file is created for the same user that is expected to unlink() it on shutdown.

axkg commented 1 year ago

Dropped the flag (and the excess line) as requested, works for me for both cases (with and without -u switch).

geekman commented 1 year ago

Alright, looks good. Thanks!