aboutsummaryrefslogtreecommitdiff
path: root/sbin/dhclient
Commit message (Collapse)AuthorAgeFilesLines
* dhclient(8): Bugfixes for some issues reported by mandocGordon Bergling2020-10-032-4/+4
| | | | | | | | | | - no blank before trailing delimiter - new sentence, new line MFC after: 1 week Notes: svn path=/head/; revision=366407
* dhclient: improve error handling parsing option 119Ed Maste2020-08-311-0/+2
| | | | | | | | | | Reported by: Shlomi Oberman, JSOF Submitted by: delphij Reviewed by: markj Tested by: markj Notes: svn path=/head/; revision=364994
* dhclient: Fix a logic bug remove_protocol().Mark Johnston2020-06-041-4/+7
| | | | | | | | | | | | A logic bug in remove_protocol() meant that it would remove (leak) all structures in the list preceding the one intended for removal. PR: 245971 Submitted by: joost@jodocus.org (original version) MFC after: 1 week Notes: svn path=/head/; revision=361793
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-1/+2
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-111-0/+8
| | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/head/; revision=355616
* Fix braino in previous bugfix r300174Conrad Meyer2019-11-291-1/+1
| | | | | | | | | | | | | | | | | | | The previous revision missed the exact same error in a copy paste block of the same code in another function. Fix the identical case, too. A DHCP client identifier is simply the hardware type (one byte) concatenated with the hardware address (some variable number of bytes, but at most 16). Limit the size of the temporary buffer to match and the rest of the calculations shake out correctly. PR: 238022 Reported by: Young <yangx92 AT hotmail.com> Submitted by: Young <yangx92 AT hotmail.com> MFC after: I don't plan to but you should feel free Security: yes Notes: svn path=/head/; revision=355204
* dhclient: support option 114, default-url asciiDave Cottlehuber2019-11-224-3/+9
| | | | | | | | | | | | | | | | | | | This will enable further automation of HTTP UEFI boot loader support by providing a specific option for providing the boot URL to FreeBSD. Documented in: https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcp-options https://tools.ietf.org/html/rfc3679 Approved by: emaste MFC after: 2 weeks Sponsored by: SkunkWerks, GmbH Differential Revision: https://reviews.freebsd.org/D22475 Notes: svn path=/head/; revision=355019
* Free DHCP options with length zero.Mark Johnston2019-06-261-2/+1
| | | | | | | | | | | | | | Otherwise they are leaked, allowing an attacker to trigger memory exhaustion. This is options.c rev. 1.70 from OpenBSD. admbugs: 552 Obtained from: OpenBSD MFC after: 3 days Notes: svn path=/head/; revision=349439
* Avoid a divide-by-zero when bad checksum counters overflow.Mark Johnston2019-06-261-2/+2
| | | | | | | | | | | | | | | A mixture of IP or UDP packets with valid and invalid checksum could cause {ip,udp}_packets_bad_checksum to wrap around to 0, resulting in a division by zero. This is packet.c rev. 1.27 from OpenBSD. admbugs: 552 Obtained from: OpenBSD MFC after: 3 days Notes: svn path=/head/; revision=349438
* Further refine r336195: do not even attempt to verify/update interface'sMaxim Sobolev2019-02-231-1/+9
| | | | | | | | | | | | MTU if we've set it once and there were no changes on the DHCP server side since the last refresh. This is consistent I believe with how dhclient handles other settings like IP address, mask etc. Approved by: cem, eugen Differential Revision: https://reviews.freebsd.org/D18546 Notes: svn path=/head/; revision=344488
* dhclient: Return non-zero status when script exits due to a signalJilles Tjoelker2019-02-081-1/+2
| | | | | | | | | | | | | | | r343896 made it such that a non-zero exit status was passed through, but was still wrong if the script exits on a signal. POSIX does not say what the WEXITSTATUS macro returns in this case and in practice 0 is a common value. Instead, translate the wait status into 8 bits the same way as the shell calculates $?. Reviewed by: kib, Nash Kaminski MFC after: 1 week Notes: svn path=/head/; revision=343922
* Correctly return exit status from the exited process.Konstantin Belousov2019-02-081-1/+1
| | | | | | | | | | | This is also OpenBSD rev. 1.117, as pointed out by Ryan Moeller <ryan@ixsystems.com>. Submitted by: Nash Kaminski <nashkaminski@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=343896
* capsicum: use a new capsicum helpers in toolsMariusz Zaborski2018-11-042-13/+17
| | | | | | | Use caph_{rights,ioctls,fcntls}_limit to simplify the code. Notes: svn path=/head/; revision=340138
* Move dhclient.conf to sbin/dhclient/.Brad Davis2018-09-182-0/+9
| | | | | | | | | | This also leverages CONFS for handling config files. Approved by: re (gjb), will (mentor) Differential Revision: https://reviews.freebsd.org/D17160 Notes: svn path=/head/; revision=338740
* Remove dhclient.conf from here in prep for the move of it from etc/.Brad Davis2018-09-181-39/+0
| | | | | | | | | | This is being done a separate step to ease importing into other VCSes. Approved by: re (gjb), will (mentor) Differential Revision: https://reviews.freebsd.org/D17160 Notes: svn path=/head/; revision=338739
* Allow dhclient and ping to build WITHOUT_DYNAMICROOTEd Maste2018-09-091-1/+3
| | | | | | | | | | | | | | | | | dhclient and ping normally use libcasper services. These are not available in statically-linked binaries, so when WITHOUT_DYNAMICROOT is set disable libcasper use, as with rescue builds. Also emit a warning as it's undesirable to build this way. Reported by: Michael Dexter Reviewed by: rgrimes Tested by: Michael Dexter Approved by: re (kib) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17074 Notes: svn path=/head/; revision=338543
* dhclient: Enter capability mode before dropping privileges.Mark Johnston2018-08-071-9/+11
| | | | | | | | | | | | This is needed to be able to chroot in the fallback case where Capsicum is not available. Reported by: Daniel Braniss <danny@cs.huji.ac.il> X-MFC with: r337382 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=337415
* dhclient: Don't chroot if we are in capability mode.Mark Johnston2018-08-062-14/+31
| | | | | | | | | | | | | | | | | | The main dhclient process is Capsicumized but also chroots to restrict filesystem access. With r322369, pidfile(3) maintains a directory descriptor for the pidfile, which can cause the chroot to fail in certain cases. To minimize the problem, only chroot if we fail to enter capability mode, and store dhclient pidfiles in a subdirectory of /var/run, thus restricting access via pidfile(3)'s directory descriptor. PR: 223327 Reviewed by: cem, oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D16584 Notes: svn path=/head/; revision=337382
* Make dhclient(8) verify if new MTU (option 26) differs from current one and ↵Eugene Grosbein2018-07-111-3/+15
| | | | | | | | | | | | | | | | skip unneeded MTU change. This check eliminates infinite loop of MTU change / link flap / lease verification / MTU change / link flap etc. in case of some NIC drivers like em(4) or igb(4). N.B.: obsolete u_int16_t is used in consistency with the rest of the file. PR: 229432 Approved by: mav (mentor) MFC after: 1 week Notes: svn path=/head/; revision=336195
* dhclient: recorrect __progname to getprogname()Eitan Adler2018-06-251-5/+2
| | | | | | | | | | | A more correct way to modernize code that uses __progname is to just replace each occurance of it with a call to getprogname(3) Reported by: ian Reviewed by: imp Notes: svn path=/head/; revision=335612
* dhclient: build with WARNS=6Eitan Adler2018-06-2410-38/+37
| | | | | | | | | | | | - add static in a number of places - initialize __progname rather than rely on magical extern values - use nitems() instead of manually spelling it out - unshadow 'idi' - teach 'error' that it is '__dead2' - add missing 'break' Notes: svn path=/head/; revision=335602
* Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski2018-06-191-1/+3
| | | | | | | No functional change intended. Notes: svn path=/head/; revision=335395
* dhclient(8): allow to supersede interface-mtu optionConrad Meyer2018-05-312-4/+24
| | | | | | | | | | | | | | | | In some cases broken DHCP servers might send invalid MTU value, so allow to use 'supersede' in dhclient.conf to override this. When superseded value is 0, MTU value is not updated at all. PR: 206721 Submitted by: novel@ Reported by: <jimp AT pfsense.org> MFC after: 37 minutes (if you care about 11, please MFC to 11.2) Relnotes: yes (potentially surprising behavior change w/ broken dhcpd mtu) Differential Revision: https://reviews.freebsd.org/D15484 Notes: svn path=/head/; revision=334443
* dhclient violates RFC2131 when sending early DHCPREQUEST message to ↵David Bright2018-02-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | re-obtain old IP When dhclient first starts, if an old IP address exists in the dhclient.leases file, dhclient(8) sends early DHCPREQUEST message(s) in an attempt to re-obtain the old IP address again. These messages contain the old IP as a requested-IP-address option in the message body (correct) but also use the old IP address as the packet's source IP (incorrect). RFC2131 sec 4.1 states: DHCP messages broadcast by a client prior to that client obtaining its IP address must have the source address field in the IP header set to 0. The use of the old IP as the packet's source address is incorrect if (a) the computer is now on a different network or (b) it is on the same network, but the old IP has been reallocated to another host. Fix dhclient to use 0.0.0.0 as the source IP in this circumstance without removing any existing functionality. Any previously-used old IP is still requested in the body of an early DHCPREQUEST message. PR: 199378 Submitted by: J.R. Oldroyd <fbsd@opal.com> Reported by: J.R. Oldroyd <fbsd@opal.com> Reviewed by: cem, asomers, vangyzen MFC after: 1 week Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D14527 Notes: svn path=/head/; revision=330085
* dhclient: raise WARNS to 4Alan Somers2018-02-2114-78/+97
| | | | | | | | | | | | | | | | Mostly const-correctness fixes. There were also some variable-shadowing, unused variable, and a couple of sockaddr type-correctness changes. I also had trouble with cast-align warnings. I was able to prove that one of them was a false positive. But ultimately I had to disable the warning program-wide to deal with the others. Reviewed by: cem MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D14460 Notes: svn path=/head/; revision=329754
* Use daemonfd(3) in the dhclient(8).Mariusz Zaborski2018-02-021-5/+1
| | | | | | | | Reviewed by: brooks@ Differential Revision: https://reviews.freebsd.org/D13603 Notes: svn path=/head/; revision=328803
* dhclient(8): add missing includeAlan Somers2018-01-121-0/+2
| | | | | | | | | | stdbool is technically needed, though we can get away without it due to header pollution. MFC after: 3 days Notes: svn path=/head/; revision=327862
* dhclient(8): raise WARNS to 3Alan Somers2017-12-1411-57/+70
| | | | | | | | | | Mostly had to fix a lot of signed/unsigned comparison warnings MFC after: 3 weeks Sponsored by: Spectra Logic Corp Notes: svn path=/head/; revision=326853
* dhclient(8): Don't shift through the sign bit of a signed intAlan Somers2017-12-131-2/+2
| | | | | | | | | PR: 208007 Submitted by: Michael McConville <mmcco@mykolab.com> MFC after: 3 weeks Notes: svn path=/head/; revision=326834
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2019-19/+61
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* dhclient(8) should not close stdio using daemon(3) function.Mariusz Zaborski2017-11-121-1/+1
| | | | | | | | | | | | | | | dhclient(8) is chrooted so opening /dev/null always will fail. In capability world this is also annoying because we getting error that open(2) is not permitted in Capsicum. dhclient(8) is closing stdio by precaching fd to /dev/null before chroot. This is done few lines below daemon(3) function so let's not try to do that in daemon(3) function. Reviewed by: cem@ Differential Revision: https://reviews.freebsd.org/D12826 Notes: svn path=/head/; revision=325741
* Use syslog service in dhclient(8).Mariusz Zaborski2017-11-125-17/+46
| | | | | | | | | | | | | dhclient(8) is failing during boot to connect to the syslog service, because syslog daemon is started after dhclient(8). This can be reproduced by stooping syslog daemon and ktrace the dhclient or use kern.trap_enotcap sysctl and boot the machine. Using the Casper syslog service fix the problem. Reviewed by: bapt@ Differential Revision: https://reviews.freebsd.org/D12825 Notes: svn path=/head/; revision=325740
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-312-2/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* parse.c parse_stringStephen J. Kiernan2017-05-311-2/+8
| | | | | | | | | | | | | | | | | | | When parse_semi fails, free s before returning parse.c parse_numeric_aggregate The memory assigned to bufp is complicated, it can either be from the input parameter buf or allocated locally. Introduce a new variable lbufp to track when it is assigned locally and to free it when appropriate. Submitted by: Thomas Rix <trix@juniper.net> Reviewed by: jhb Approved by: sjg (mentor) Obtained from: Juniper Networks, Inc. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D9899 Notes: svn path=/head/; revision=319361
* Fix the output of very large rebind, renew and lease time options inNick Hibma2017-05-071-2/+2
| | | | | | | | | | | | lease file. Some routers set very large values for rebind time (Netgear) and these are erroneously reported as negative in the leasefile. This was due to a wrong printf format specification of %ld for an unsigned long on 32-bit platforms. Notes: svn path=/head/; revision=317923
* Fix handling of large DHCP expiry values.Nick Hibma2017-05-071-19/+21
| | | | | | | | | | | | | | | | | | | They would overflow a signed 32-bit time_t on 32 bit architectures. This was taken care of, but a compiler optimisation makes this behave erratically. This could be resolved by adding a -fwrapv flag, but instead we can check the value before adding the current timestamp to it. In the lease file values are still wrong though: option dhcp-rebinding-time -644245096; PR: 218980 Reported by: Bob Eager MFC after: 2 weeks Notes: svn path=/head/; revision=317915
* Make dhcp-lease-time option supersedable as well.Nick Hibma2017-03-301-1/+5
| | | | | | | | Note: It is not recommended to set this value to above the value that the server provided, unless that value is bogus. Notes: svn path=/head/; revision=316285
* Allow superseding the lease renewal and rebind times.Nick Hibma2017-03-301-6/+19
| | | | | | | | | | | | | | Also make sure that the renewal is never more than 1/2 * expiry and rebind never more than 7/4 * renewal (the default values in the spec). This should allow adjusting high values from the server as well as making sure the values from the server make sense. Renewal and rebind times will be adjusted down if the expiry time is set very high in a server, not the other way around. This change just makes sure the values keep making sense. Notes: svn path=/head/; revision=316283
* sbin/dhclient: fix `vendor` storage leak in parse_option_decl(..)Enji Cooper2017-03-131-0/+3
| | | | | | | | | | | | | | | This ensures the storage isn't leaked when non-NULL and the function returns early, prior to the `free(vendor)` later on in the function. MFC after: 1 week Reported by: Coverity CID: 1007111-1007113 Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision: D9993 Notes: svn path=/head/; revision=315203
* Fix -Wunused-but-set-warning with `ret`Enji Cooper2017-03-131-3/+2
| | | | | | | | | | | | | While here, resolve Coverity warnings by demonstrating that vfprintf's return value is being explicitly ignored. MFC after: 1 week Reported by: gcc 6.3.0 Tested with: clang, gcc 4.2.1, gcc 6.3.0 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315200
* sbin/dhclient: fix a memory leak in parse_client_lease_statement(..)Enji Cooper2017-03-131-0/+1
| | | | | | | | | | | | | | | The memory stored by `lease` would have previously been leaked if an unterminated lease declaration was found in an early-return code path. MFC after: 1 week Reported by: clang static analyzer, Coverity CID: 1007114 Submitted by: Tom Rix <trix@juniper.net> Sponsored by: Dell EMC Isilon; Juniper, Inc Differential Revision: D9992 Notes: svn path=/head/; revision=315199
* sbin: normalize paths using SRCTOP-relative paths or :H when possibleEnji Cooper2017-03-041-1/+1
| | | | | | | | | | This simplifies make logic/output MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314656
* Remove dead code in dhclient(8)Alan Somers2017-01-041-6/+2
| | | | | | | | | | | | | The offending code has been dead ever since the import from OpenBSD in r195805. OpenBSD later deleted that entire function. Reported by: Coverity CID: 500059 MFC after: 4 weeks Sponsored by: Spectra Logic Corp Notes: svn path=/head/; revision=311298
* Allocate a struct ifreq rather than using a (wrong) computed size forBrooks Davis2016-11-221-2/+2
| | | | | | | | | | | | | | | | | | | | the BIOCSETIF ioctl. The kernel always copies an entire struct ifreq and IPv4 addresses will always fit in an ifreq. On systems with pointers larger than 64-bits, the computed size will be less than the size of struct ifreq, potentially resulting in the kernel attempting to copyin memory from outside the allocation. Reviewed by: jhb Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8445 Notes: svn path=/head/; revision=309027
* dhclient(8): Enable numbered user class ID optionConrad Meyer2016-09-201-0/+1
| | | | | | | | | | | | | By adding it to the option priorities table. PR: 184117 Submitted by: Lowell Gilbert <freebsd-bugs-local at be-well.ilk.org> Reported by: Tomek CEDRO <cederom at tlen.pl> Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D7911 Notes: svn path=/head/; revision=306053
* dhclient: add support for interface-mtu (26)Conrad Meyer2016-09-026-1/+73
| | | | | | | | | | | | | | | | Make dhclient set interface MTU if it was provided. This version implements MTU setting in dhclient itself before it runs dhclient-script. PR: 206721 Submitted by: novel@ Reported by: Jarrod Petz <jlpetz at gmail.com> Reviewed by: cem, allanjude Differential Revision: https://reviews.freebsd.org/D5675 Notes: svn path=/head/; revision=305306
* dhclient(1): correct obvious mismatch in get_char().Pedro F. Giffuni2016-06-031-2/+2
| | | | | | | | | | | | Correct switch between current and previous line buffers when encountering a carriage return in the input. CID: 1305719 Obtained from: OpenBSD (CVS rev. 1.30) MFC after: 3 days Notes: svn path=/head/; revision=301235
* dhclient: Fix the trivial buffer overruns correctlyConrad Meyer2016-05-181-1/+1
| | | | | | | | | | | | | | | A DHCP client identifier is simply the hardware type (one byte) concatenated with the hardware address (some variable number of bytes, but at most 16). Limit the size of the temporary buffer to match and the rest of the calculations shake out correctly. This is a follow-up to the incorrect r299512, reverted in r300172. CIDs: 1008682, 1305550 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=300174