summaryrefslogtreecommitdiff
path: root/sbin/dhclient
AgeCommit message (Collapse)Author
2013-01-18tweak -L; ok krwJason McIntyre
2013-01-18-L before -l;Jason McIntyre
2013-01-18Change a bunch of error()'s to warning()'s in the dispatch loop.Kenneth R Westerback
Set 'quit' to exit the loop in those situations, allowing more cleanup() attempts in those error situations.
2013-01-18Add command line option '-L' that specifies an optional file into whichKenneth R Westerback
the most recent offer and effective leases will be written. Intended to allow access to dhcp option information that was formerly passed to dhclient-script.
2013-01-17Try harder to clear out default routes on the interface beingKenneth R Westerback
configured. Only exempt default routes labelled as being the property of another dhclient.
2013-01-16Unrevert last reversion. otto@ pointed out that it wasn't asprintf()Kenneth R Westerback
causing a problem, it was accessing uninitialized pointers.
2013-01-16Revert last. asprintf() breaks something.Kenneth R Westerback
2013-01-16Use the magic of asprintf() to produce more informative errorKenneth R Westerback
and log messages.
2013-01-16Don't tell the priviledged process to discard active_addr if there isKenneth R Westerback
a pending address addition. Should fix "routehandler: interface address added" messages and premature exiting of dhclient seen by henniing@ amoung others.
2013-01-15Add IMSG_WRITE_FILE and associated bits to allow the unprivilegedKenneth R Westerback
process to ask that a file be written by the privileged process. Not yet used.
2013-01-14First convert packet to lease, which validates option data andKenneth R Westerback
discards bad options. THEN check to see if any required options are missing and reject both OFFER and ACK packets that lack required options. Since it is the latter's lease we actual bind. Move required option check into packet_to_lease() instead of duplicating it.
2013-01-13More informative error message.Kenneth R Westerback
2013-01-13Make pretty_print_option() return "" rather than "<fmt error>" whenKenneth R Westerback
the option fails validation tests. Make pretty_print_option() bail on all bad format strings, and on all incorrect option data lengths. Check pretty_print_option() return value rather than repeating validation with check_option(). Do res_hnok() check on host name, domain name, and nis domain while creating lease from packet info. As a result, nuke ipv4addrs() and check_option(). Ignore options that do not validate rather than summarily rejecting offered lease. Treat all options whose names start with "option-" as unknown rather than relying on a big switch on DHO_ names. Started when reading dhclient(8) -u verbiage.
2013-01-13Tweak whitespace, add missing #defines, use DHO_RELAY_AGENT_INFORMATIONKenneth R Westerback
rather than DHO_DHCP_AGENT_OPTIONS. Makes these files identical again.
2013-01-13Add DHO_ defines for all known options. Use same names as ISC whereKenneth R Westerback
available. No functional change.
2013-01-13Check results of strdup() of domainname and nameservers options.Kenneth R Westerback
Original diff from lteo@, tweaked by me. ok lteo@
2013-01-06Make buffer for lease_as_string() 8192 bytes. A pathological leaseKenneth R Westerback
string listing all possible option names turns out to be about 6900 characters long.
2013-01-05Change write_client_lease() into lease_as_string() and modifyKenneth R Westerback
rewrite_client_leases() to use lease_as_string(), writing out complete leases at a time. While here replace hand formatting of dates with strftime(). This will add leading zeros to months and days, but not affect the ability of dhclient to parse the resulting files.
2013-01-05Apply same fix to UDP length check as was just committed in dhcpd.Kenneth R Westerback
2013-01-02Only check '-l' parameter for regular-fileness. Not built-in defaultKenneth R Westerback
path. And only error out if the file is successfully lstat()'d and is not a regular file. i.e. aleady exists. Fixes (U)pdate. Removes some accidentally duplicated code.
2013-01-02Sync dhcpd and dhclient list of dhcp options. There's only oneKenneth R Westerback
dhcp-options(5) so lists of defined option names should be the same. In this case add relay-agent-information, tftp-config-file, voip-configuration-server and autoproxy-script option names. Prompted by a man page update from Marcus Merighi via tech@.
2013-01-02Delete misleading comment and a pointless check of !ifi. Since ifiKenneth R Westerback
is either successfully calloc'd or dhclient dies early.
2012-12-29Make HUP to either one of the processes cause a restart that willKenneth R Westerback
have dhclient re-read dhclient.conf and get a new lease. Constrain the filename passed to '-l' (alternate dhclient.lease.if location) to be a regular file for the moment. Original suggestion from phessler@. Feedback from deraadt@ and espie@.
2012-12-21When binding to a new lease, wait for the RTM_NEWADDR message inKenneth R Westerback
S_BOUND state, which prevents confusion when another DHCPACK arrives. Problem found and fix tested by kettenis@.
2012-12-19Don't attempt to delete an address that has already been deletedKenneth R Westerback
by a new dhclient (or anyone else). Instead, use add_address(..., INADDR_ANY, ...) to tell the privileged process that its active address is gone. Thus the cleanup process doesn't try to delete it. Eliminates extraneous log entries complaining that the address can't be deleted. Narrows race window where old dhclient might delete the address the new dhclient has just added. Make rapid-fire starting of dhclient even more reliable.
2012-12-18Don't clean up twice when the non-privileged process exits. Let theKenneth R Westerback
privileged process now cleans up itself. Continuous rapid repeated running of dhclient now more reliable.
2012-12-17Don't daemonize until the RTM_NEWADDR message is received. ShuffleKenneth R Westerback
things a bit so configuring the address and default route are done last. This makes it much more likely that all the work is done when the 'bound to ...' message is displayed. Amoung other things fixes a problem with the install scripts, where the first (hostname-associated) dhclient can exit so quickly the interface doesn't yet have an address and a second (free-floating) dhclient is therefore often run. Noted by rpe@, who also tested the fix.
2012-12-16Prevent a potential segfault that could occur if certain calloc() andLawrence Teo
strdup() calls happen to return NULL. If they do return NULL, error out to be consistent with what most of the rest of the code does when memory allocation fails. feedback/ok krw
2012-12-15Nuke unused parameter 'ifname' to get_ifname().Kenneth R Westerback
2012-12-10add -i to usage(); ok krwJason McIntyre
2012-12-09Add a new option to the dhclient command line interface. '-i' takesKenneth R Westerback
a list of option names, and any values provided for those options in leases will be ignored. Requested by phessler@ and djm@. Tested by phessler@. Possible non-optimality of ignoring list in case of error pointed out by tedu@. ok phessler@ todd@ beck@
2012-12-05Archeological investigation shows dhclient-script did not overwriteKenneth R Westerback
resolv.conf unless at least one of domain-name or domain-name-servers were provided in the lease being bound. Tweak priv_resolv_conf() to do the same. i.e. don't overwrite resolv.conf with resolv.conf.tail when neither domain-name nor domain-name-servers are provided in the lease.
2012-12-05If there is no domain-name and no domain-name-servers provided inKenneth R Westerback
the lease (or if they are 'ignore'd in dhclient.conf), and there is no resolv,conf.tail then do not remove any existing resolv.conf. Restores the behaviour ajacoutot@ expected and todd@ thinks makes sense.
2012-12-04Eliminate hand-rolled pseudo-strerror() %m strangeness by replacingKenneth R Westerback
all occurances of %m with strerror(errno). And then nuking do_percentm() and related buffer shuffling. Also simplify parse_warn() so it takes a simple char * of the error, and thus rely on pointing to error location in input for details. Makes sense to beck@
2012-12-03Backout last. It breaks existing 'ifconfig down ; dhclient' usage.Kenneth R Westerback
Pointed out by deraadt@
2012-12-03Cleanup after a 'ifconfig down', but stick around so 'ifconfig up'Kenneth R Westerback
will get a new lease without having to restart dhclient. Also tweak cleanup() to cancel any existing timeout, so one doesn't fire between 'down' and 'up'. Makes sense to chris@ beck@.
2012-12-02Try harder to cleanup when exiting. In particular catch signalsKenneth R Westerback
SIGHUP, SIGINT, SIGTERM, SIGUSR1, SIGUS2 and cleanup before exiting when getting them. Cleanup meaning removing routes and the interface address added. Tweaks and feedback from phessler@, sthen@, otto@, deraadt@
2012-12-01Make privileged process daemonize too. Using same function as theKenneth R Westerback
non-privileged process, go_daemon(). As pointed out by kettenis@, otherwise it is still attached to a controlling terminal and subject to the dangers thereof. Prep for having the privileged process pay attention to signals.
2012-12-01A couple of whitespace nits.Kenneth R Westerback
2012-11-29Nobody looks at the result of fork_privchld(), so make it returnKenneth R Westerback
void and not int/pid_t.
2012-11-29Nuke unused 'extern' declaration.Kenneth R Westerback
2012-11-27Clean up parsing of option lists. Part 7 (and final).Kenneth R Westerback
Allow 'request ;', 'require ;' and 'ignore ;' as requests to create empty lists of options. Thus enabling the removal of built-in lists or the removal of global lists inside an 'interface' declaration.
2012-11-27Clean up parsing of option lists. Part 6.Kenneth R Westerback
Treat 'ignore' option lists the same as 'request' and 'require' option lists. i.e. keep a list of the options rather than using an ACTION flag. So overriding a previous ignore list will not leave breadcrumbs and incorrect ACTIONs lying around. The list will be applied when the new lease is created, and will override any ACTION specified for the option. Mention in dhclient.conf(5) that each request/require/ignore statement will override any previous one.
2012-11-27Clean up parsing of option lists. Part 5.Kenneth R Westerback
Don't toss away an existing request/require list unless the new list is successfully parsed.
2012-11-25Clean up parsing of option lists. Part 3.Kenneth R Westerback
Storing an option in a list more than once is silly, wastes space and is possibly confusing to sensitive dhcp servers. Make it a syntax error to attempt to store an option in a list more than once.
2012-11-25Clean up parsing of option lists. Part 2.Kenneth R Westerback
DHO_PAD ("pad") and DHO_END ("option-end") are not really options and it makes no sense to require, request, or ignore them. And probably would confuse some sensitive dhcp servers.
2012-11-25Clean up parsing of option lists. Part 1.Kenneth R Westerback
1) Add config->required_options_count so that syntactically incorrect request statement in dhclient.conf is completely ignored. 2) Pass size of buffer being filled instead of assuming 256. 3) Always zero (a.k.a. DHO_PAD) the passed in buffer. 4) Check for out of bounds index before using it, not after. Add TOK_IGNORE to syntax in comment. No intentional functional change other than catching bad request statements.
2012-11-24Don't segfault if no subnet-mask is provided, or is marked 'ignore'Kenneth R Westerback
in dhclient.conf. Always zero out stack masks rather than using stack garbage when no subnet-mask is provided.
2012-11-23Missed file from last commit.Kenneth R Westerback
2012-11-23Use the libutil imsg framework rather than a hand-rolled localKenneth R Westerback
version. This is the last hand-rolled imsg implementation I could spot. Doesn't seem to break sparc64. Suggested by chris@, tweaks from brad@ and reyk@. ok reyk@