summaryrefslogtreecommitdiff
path: root/sbin/dhclient/privsep.c
AgeCommit message (Collapse)Author
2020-11-21No need to update resolv.conf when renewing a lease does not result in anyKenneth R Westerback
configuration changges.
2020-05-20Replace fixed 128-byte fields for search domains, static routes andKenneth R Westerback
domain name servers with variable sized uint8_t chunks. Allows larger lists of search domains and static routes while making common situations use much less memory. Original report of breaching the 128-byte limit for static routes from James Cook via misc@. Testing of various versions by Andreas Kusalananda.
2020-05-19Eliminate imsg_propose{}, imsg_revoke{} and imsg_tell_unwind{} asKenneth R Westerback
unnecessary wrappers, since they all contained a single field that could be used as is. Suggested by claudio@
2019-11-19Inform unwind about DNS servers it finds in leases.Kenneth R Westerback
ok florian@
2019-02-12Restructure code to simplifiy imsg communications, further separatingKenneth R Westerback
DHCP knowledge and interface manipulation. Unprivileged process now sends proposal derived from the accepted lease to the privileged process rather than individual interface manipulation requests. The only intended functional change is that /etc/resolv.conf.tail is not re-read each time a new proposal is implemented, rather than once at dhclient startup.
2019-01-19Since dhclient no longer tries to clean up when exiting, there is noKenneth R Westerback
need to start a new copy when LLADDR or SSID changes. Just go back to S_PREBOOT and get a new lease. Fewer log messages, faster join'ing new networks, simpler code.
2019-01-19IMSG_HUP -> IMSG_RESTART. sendhup() -> sendrestart.Kenneth R Westerback
2019-01-19Drop pseudo-signal idiom. Rename INTERNALSIG to TERMINATE. Use RESTARTKenneth R Westerback
instead of overloading SIGHUP.
2017-09-20Tweak, shorten, use more consistant verbiage.Kenneth R Westerback
2017-09-17Create global 'log_procname' and set it to '<ifname>' orKenneth R Westerback
'<ifname> [priv]' as appropriate for the process doing the setting. Use it as the prefix in all log_*() output. Makes tracking messages for an interface or a process much easier.
2017-09-15Use a poll() loop when trying read the default route fromKenneth R Westerback
a routing socket. Fixes at least one cause of resolv.conf confusion and possibly hanging/looping dhclient if the RTM_GET gets lost. Fingered by phessler@ when doing many suspend/resumes while switching between wifi and wired interfaces. Testing & ok phessler@
2017-09-14Strive to rationalize fatal[x]() usage andKenneth R Westerback
verbiage.
2017-08-31Don't delete v4 routes that are going to beKenneth R Westerback
added back. ok mpi@
2017-08-13Simplify HUP handling now that proper errorKenneth R Westerback
checks are done on the imsg socket to detect closure, etc. Die immediately if the priv process notices the interface name can't be turned into an index.
2017-08-12Stop trying to outfox the routing tableKenneth R Westerback
by labelling dhclient routes. Just use the route(8) logic when flushing routes. ok benno@ claudio@
2017-08-11Don't write out resolv.conf unless the contentsKenneth R Westerback
are changed or dhclient's interface takes over the default route.
2017-08-10Add IMSG_SET_RESOLV_CONF and keep the cached contentsKenneth R Westerback
in the priv process, so that they do not have to be continually retransmitted. IMSG_WRITE_RESOLV_CONF now just triggers a write of the cached info. Simplifies a bunch of logic.
2017-08-08Rename resolv_conf_priority() to default_route_index() toKenneth R Westerback
reflect what it does.
2017-08-06Simplify logic seeking/checking the interface overKenneth R Westerback
which the current default route exits. If the dhclient instance owns that interface it owns resolv.conf and will overwrite it no matter who created the default route. Feedback & suggestions claudio@
2017-08-05Bring route creation into line with what route(8) does. InKenneth R Westerback
particular stop providing RFA_IFA, and instead supply the relevant interface index in the RTM_ADD message. Various code simplifications as a result.
2017-07-22Rename *_add_address to *_set_address to reflect that theKenneth R Westerback
lease address replaces all current addresses. Shuffle some code from bind_lease() into set_mtu()/set_address() to shrink bind_lease().
2017-07-21s/set_interface_mtu/set_mtu/gKenneth R Westerback
2017-07-14Replace remaining "!var" expressions withKenneth R Westerback
"<var> == 0", "!(<var> & FLAG)" with "(<var> & FLAG) == 0", "!<func()>" with "<func()> == 0" and "!<define>" with "<define> == 0". And the positive cases as well. A few stray == NULL and != NULL as well.
2017-07-10Use ioctlfd/routefd sockets rather than rolling one's ownKenneth R Westerback
for resolving 'egress' and adding a route. Move creation of main()'s ioctlfd up so it can be used for the 'egress' resolution.
2017-07-07dispatch_imsg() only needs to know name and rdomain.Kenneth R Westerback
No more struct interface_info knowledge in privsep.[ch]
2017-07-02Unbreak tree by putting revised resolv_conf_priority() declaration inKenneth R Westerback
correct place and passing the invocation the correct parameters. Noticed by & initial diff from matthieu@
2017-07-01Eliminate multiple socket openings/closings and passKenneth R Westerback
fd'd from main loops as required. One socket to do ioctl's per process (called ioctlfd) and one socket to do route messages per socket (called routefd). Clean up local variable declaration lists in passing.
2017-06-28Only pass required fields of interface_info to priv_* functionsKenneth R Westerback
and friends. i.e. ifi->name, ifi->rdomain, or both.
2017-06-28Stop trying to clean up addresses, routes and "-L" fileKenneth R Westerback
whenever dhclient dies. Eliminates differences in handling and thus need to intercept signals INT, TERM, USR1, USR2. Eliminates need for 'zapzombies' field and thus entire struct imsg_flushroutes. Eliminates need for 'imsg' parameter to and associated logic in priv_flush_routes(). Address, routes and '-L' file are still cleaned out when binding a lease.
2017-06-24Tweak handling of HUP and new LLADDR. Just use expose and use sighup()Kenneth R Westerback
function. Don't exit dispatch() loop on SIGHUP, wait for privileged child to execvp() dhclient. Eliminate struct imsg_hup since its contents were not being used except in priv_cleanup(). And 'active_addr' works just as well there. Cleaner and eliminates some extraneous log entries.
2017-06-24Use a local variable rather than a global flag to recordKenneth R Westerback
the reception of a IMSG_HUP message and trigger the desired restart. Nuke the now pointless IFI_HUP.
2017-06-23Oops. Remove extraneous 'return' and some braces fromKenneth R Westerback
priv_write_resolv_conf() code that was moved into the dispatch loop.
2017-06-23Take reyk's imsg resolv.conf improvements of a while ago to theirKenneth R Westerback
logical conclusion. Nuke _PATH_RESOLV_CONF since the value is only meant to be known inside priv_write_resolv_conf(). Just use a local const char *. Bring priv_write_resolv_conf() into line with other priv_ functions invoked from the dispatch loop. i.e. don't pass it the imsg, just pass a pointer to the data and a size after ensuring there is data to pass.
2017-04-10Rework -L logic to use the idiom used in handling the leases file.Kenneth R Westerback
i.e. open FILE during program set up and use the FILE created for the rest of the program lifetime after dropping privilege and pledge()'ing. No need for passing messages to the priv process. Tweak lease file handling a bit in passing. Monitoring the -L file with external programs like sysutils/entr still works. Looks good to sthen@.
2017-03-08Shuffle another bit of code closer to its friends.Kenneth R Westerback
2017-02-12Eliminate most strerror() invocations by using log_warn() and fatal()Kenneth R Westerback
instead of log_warnx() and fatalx(). A few log_info() to log_warn() for the same reason. Suggested by millert@.
2017-02-12Switch from 'legacy' errwarn.c to standard daemon logging functions.Kenneth R Westerback
No objections heard. Feedback from millert@ guenther@
2016-09-02Kill 'ifi' global.Martin Pieuchot
ok henning@, krw@
2016-08-23Make the 'ifi' global local to dhclient.c and pass it as an argument toMartin Pieuchot
functions needing it. This is the first step to support multiple interfaces in one dhclient(8) instance. ok krw@
2016-02-06Eliminate #include inside *.h files and include only needed headers inKenneth R Westerback
each *.c file. Inspired by mention of header silliness by Edgar Pettijohn and mmcc@ on tech@.
2015-02-07Add support for interface-mtu (option 26).Kenneth R Westerback
Original request+diff from matthew@ ok dlg@
2015-02-06The write_file() privsep interface was too permissive andReyk Floeter
theoretically allowed the unprivileged child process to write to arbitrary files. Restrict it by replacing it with two specific write_resolv_conf() and write_option_db() privsep interfaces where all the critical decision has been moved to the parent. OK krw@
2014-10-27Zap extraneous whitespace and a stuttered extra 'break;'.Kenneth R Westerback
2014-02-09Missing {} around multi-statement else. Malformed IMSG_HUP messages shouldKenneth R Westerback
not cause privileged process to exit.
2014-01-20more %d type correctness; ok krwTheo de Raadt
2013-06-09Re-apply route adding code refactoring -- it wasn't the problem thatKenneth R Westerback
broke populating the egress group.
2013-06-09Backout static/classless route handling and default route refactoringKenneth R Westerback
since the former relies on the latter and the latter breaks 'egress' group populating.
2013-06-01Refactor the default route adding code to use a general route addingKenneth R Westerback
function that will be reused for future work. ok claudio@
2013-03-30Since deleting all the addresses on an interface removes all theKenneth R Westerback
relevant entries from the arp cache, don't bother asking for/processing arp entries in the route dumps. Thus allowing use of NET_RT_FLAGS with RTF_GATEWAY and AF_INET, to ask for only the routes dhclient wants to expunge rather than all routes in existance. Greatly shrinks and simplifies the code. No intentional functional change. Tested by sthen@.
2013-02-18Rework log messages to be more useful. RenameKenneth R Westerback
IMGS_CLEANUP/imsg_cleanup/cleanup to IMSG_HUP/imsg_hup/sendhup to more accurately reflect intent of causing the privileged process to initiate restart. There should now be one and only one message logged at termination or restart, logged by the process initiating the termination or restart. As part of fixing this, remove duplicate cleanup attempts and exit after sending IMSG_HUP. These make logged messages more consistant and fix issues with incorrect cleanups. More prodding from deraadt@