summaryrefslogtreecommitdiff
path: root/sbin/dhclient
AgeCommit message (Collapse)Author
2018-07-22No need to re-implement realloc(). Just use itKenneth R Westerback
the way the man page says. ok tb@
2018-07-22Tweak comment about truncating NULs to reflect newKenneth R Westerback
reality.
2018-07-22When finished pulling an option out of a buffer, skip directly to theKenneth R Westerback
next option. Don't rely on truncated NULs being ignored because NUL == DHO_PAD. ok tb@
2018-07-21Reading past the end of a buffer is bad, Even if theKenneth R Westerback
extra byte is always there. Even if the byte contains innocuous data that isn't used. Eeven if a particular level of optimization of a particular compiler avoids it by processing things backwards. Bad. So simplify and correct logic. Perhaps even proof the code against future generations of clever compilers. Pointed out by Brandon Falk. Thanks! ok millert@ tb@
2018-07-04Print the amount of bytes written, as intended, instead of -1 whenMartin Pieuchot
an error occurs. ok krw@
2018-06-20dhclient.c r1.569 started writing some files before calling daemon(),Stuart Henderson
which involved doing a write_option_db() call at a different point in bind_lease(). However one of the parameters was in a variable that was also used for iterating a TAILQ so this did not have the intended contents (it was always NULL at the end of TAILQ_FOREACH*, resulting in a null deref when dhclient -L is used). Fix by using a new temporary variable. ok krw@
2018-06-13Add a cloning direct route to the default route gateway when theKenneth R Westerback
gateway is not reachable via the IP address/netmask provided by the lease. Allows OpenBSD to work as well as iOS in certain weird/misconfigured/overly clever hotspots. A generalization of the handling of the /32 addresses handed out by Goggle Cloud, suggested by claudio@ Error in initial diff pointed out by henning@. Feedback from job@, mpi@, kn@. Tweaks & ok claudio@
2018-06-03Fix previous by restoring inadvertantly deleted check forKenneth R Westerback
get_recorded_lease() returning NULL. Should fix segmentation fault reported by Klemens Nanni on bugs@.
2018-05-23Some interfaces (e.g. cdce(4)) can't tell if they are connected. TheyKenneth R Westerback
always report a link status of UNKNOWN. Do not use recorded leases to configure such interfaces. In such cases only use the address in the recorded lease to ask for a new lease. Avoids debilitating /etc/resolv.conf changes by unplugged higher priority interfaces given to the tender mercies of dhclient after a working interface has already set /etc/resolv.conf correctly. Reported for cdce(4) by guenther@ at p2k18.
2018-05-19Add '-r', which causes running dhclient to releaseKenneth R Westerback
lease and exit. Man page tweaks from jmc@. Request, tests & ok tb@. ok millert@ on previous version.
2018-05-17Any IPv4 address change could alter which interface has the activeKenneth R Westerback
default route and thus 'owns' resolv.conf. So check if resolv.conf should be (re)written after all IPv4 RTM_NEWADDR or RTM_DELADDR messages.
2018-05-16Always record the client identifier used to obtain a lease. ServersKenneth R Westerback
obeying RFC 2131 will never echo the identifier in OFFER/ACK packets. Servers obeying RFC 6842 will always echo the identifier. Confused servers may or may not do the echoing. This permits more reliable association of recorded leases with the MAC address in use at the time the lease was obtained. Requested by & ok tb@
2018-05-12Document current behaviour of 'ignore' directive and 'append',Kenneth R Westerback
'prepend', 'default' and 'supersede' directives with respect to 'ignore'. Document 'filename', 'fixed-address', 'next-server' and 'server-name' directives.
2018-05-11Write out updated dhclient.leases.<if>, /etc/resolv.conf and any -LKenneth R Westerback
file before going daemon. Alleviates a race scripts (e.g. the installer in autoinstall mode) can encounter under the reasonable assumption that all related information is available when dhclient(8) returns control to the script as a result of going daemon. Pointed out by rpe@.
2018-04-24Make dhclient show imsg pipe poll error messages in debug output only.Stefan Sperling
ok krw@
2018-03-31The rarely used '-L' option does not need a PATH_MAX staticKenneth R Westerback
array. Just point at the provided optarg like '-l' does. Also, no need to initialize a static pointer to NULL.
2018-03-31Fix '-i' to discard previously defined values for the options to beKenneth R Westerback
ignored.
2018-03-31Move 'require' declaration into 'DHCP Options' sectionKenneth R Westerback
alongside 'request'.
2018-03-20pretty_print_option() returns a pointer to a 0 length string, notKenneth R Westerback
NULL, on failure. Eliminates possible "option = ;' lines in lease files.
2018-02-28Now that log_debug() has been decyphered, replace DPRINTF() instancesKenneth R Westerback
with log_debug() so -v unleashes all debug output without having to compile a custom dhclient.
2018-02-27Typo: 'tftp-server' -> 'tftp-server-name'.Kenneth R Westerback
Spotted by Pontus Lundkvis. Thanks!
2018-02-11Ooops. After getting a NAK in response to a renewal REQUEST, we deleteKenneth R Westerback
the interface's address and thus the cached configuration data becomes invalid and must be discarded. Issue found & fix tested by Christer Solskogen. Thanks!
2018-02-11Make "invalid host name" messages log_debug() since the invalid hostKenneth R Westerback
name does not cause the lease to be rejected. It just causes the containing option or field to be ignored.
2018-02-10Fix 'ignore ;' so that it really does reset the ignore list.Kenneth R Westerback
Mkae 'ignore', 'request' and 'require' cumulative so all options don't have to be jammed into one line.
2018-02-09If there is no link after link_timeout seconds don't forgetKenneth R Westerback
to go_daemon() while waiting for the RTM_IFINFO message. Problem spotted by Holger Mikolon.
2018-02-08Don't update first_sending in state_selecting() and thusKenneth R Westerback
fix the accounting for the interval since we started the process of getting a lease. Fixes the 'no lease ... got lease' messaging at a minimum.
2018-02-07Keep track of the last proposal used to configure the interface andKenneth R Westerback
compare that to the offered proposal to determine if there are any changes to configure. Simpler, and fixes issue where using a recorded lease meant the interface was continually being configured with the same information.
2018-02-06Abstract "no link ..." and "no lease ..." message generationKenneth R Westerback
into a function tick_msg(). Now both work the same way, dot dot dotting as time passes until they 'sleep'. Tested by tb@ as part of a larger diff.
2018-02-06Nuke unused state S_REBINDING. We just use the timeKenneth R Westerback
to decide between unicast and broadcast for REQUEST.
2018-02-06When binding a lease from the dhclient.leasees.<if> file andKenneth R Westerback
the renewal time is in the past wait retry_interval before trying to renew the lease.
2018-02-06Fix fprintf() to include "\n" where needed. Prefix "no lease"Kenneth R Westerback
messages with interface name. Spotted by & ok tb@
2018-02-06Flip -q (be quiet) into -v (be noisy), making terseness the defaultKenneth R Westerback
behaviour. Always go daemon after link_timeout seconds and complete lease negotiations in the background if necessary. No hanging around in the foreground for the full 64 seconds waiting for a server to appear. Log a more relevant message when a default route can't be obtained via RTM_GET. i.e. "no default route" rather than "No such process". -q -> -v ok mpi@
2018-02-05Ensure that the "bound to ..." message appears in the log unlessKenneth R Westerback
dhclient was started with '-d'. Move the "yielding responsibility" message to log_debug(). Stop logging duplicate "bound to ..." messages now that one is guaranteed to be present when the address is first bound. Thins out logs. Especially if you run with '-q'.
2018-02-05Always run through state_preboot() when starting up or theKenneth R Westerback
link status changes. Simplifies some logic.
2018-02-05Nuke unused parameter to go_daemon().Kenneth R Westerback
2018-01-30Expand "bound to ..." message to include the source of the lease,Kenneth R Westerback
either the server IP/MAC or the name of the leases file. Prompted by phessler@ and landry@ feedback to another diff. ok phessler@
2018-01-29Repair botched retry loop when generating RTM_PROPOSALKenneth R Westerback
messages at startup. Reproducible situation found on vnet(4) and fix tested by jca@.
2018-01-29Missed a couple of log_info()'s in previous commit. Use #ifdef DEBUGKenneth R Westerback
instead of #if DEBUG.
2018-01-29Use log_init(), log_setverbose() and log_debug() moreKenneth R Westerback
appropriately. Fixes '-q' logging oddities. Prompted by phessler@ plea for '-v'-like behaviour rather than putting everything under DPRINTF()'s.
2018-01-28Refactor and simplify the logic to select and invoke theKenneth R Westerback
appropriate function to process a packet.
2018-01-28A few fatal() -> fatalx() where errno is notKenneth R Westerback
relevant.
2018-01-25Add DPRINTF() and use it to replace log_debug() statements insideKenneth R Westerback
#ifdef DEBUG/#endif blocks. Suggestions on correct idiom (C99 vs gcc) from millert@ ok tom@
2018-01-24Don't display the seconds until renewal. i.e. "em0: bound to 1.2.3.4Kenneth R Westerback
-- renewal in 300000 seconds" becomes simply "em0: bound to 1.2.3.4" While here avoid setting timeouts before the current time. ok florian@
2018-01-05Complete and fix grammar in comments and bring grammar terms,Kenneth R Westerback
function names and function code into sync.
2018-01-04Compact some whitespace, unsplit now shorter lines.Kenneth R Westerback
2018-01-04Comments and grammar use '_decl' so use _decl instead of _declarationKenneth R Westerback
in the names of the respective parsing functions.
2018-01-04parse_lease_time() is an unnecessary abstraction. Just useKenneth R Westerback
parse_number('L') since it is parsing unsigned 32bit integers.
2018-01-04We only parse decimal numbers, so parse_decimal() -> parse_number() toKenneth R Westerback
match grammar comments and improve euphony.
2018-01-02More grammar comments improvements.Kenneth R Westerback
2018-01-01Tweak syntax comments into consistency and completeness.Kenneth R Westerback