summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient
Commit message (Collapse)AuthorAgeFilesLines
* MFC r314655:ngie2017-05-301-1/+1
| | | | | | bin: normalize paths using SRCTOP-relative paths or :H when possible This simplifies make logic/output
* MFC:n_hibma2017-05-222-22/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r317923 | n_hibma | 2017-05-07 23:11:28 +0200 (Sun, 07 May 2017) | 8 lines Fix the output of very large rebind, renew and lease time options in 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. ------------------------------------------------------------------------ r317915 | n_hibma | 2017-05-07 21:59:37 +0200 (Sun, 07 May 2017) | 16 lines Fix handling of large DHCP expiry values. 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
* MFC 316283:n_hibma2017-04-071-7/+24
| | | | | | | | | | | | | | | | | | | | Allow superseding the lease renewal and rebind times. 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. and 316285: Make dhcp-lease-time option supersedable as well. Note: It is not recommended to set this value to above the value that the server provided, unless that value is bogus.
* MFC r315199,r315200,r315203:ngie2017-03-202-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | r315199: sbin/dhclient: fix a memory leak in parse_client_lease_statement(..) The memory stored by `lease` would have previously been leaked if an unterminated lease declaration was found in an early-return code path. CID: 1007114 r315200: Fix -Wunused-but-set-warning with `ret` While here, resolve Coverity warnings by demonstrating that vfprintf's return value is being explicitly ignored. Tested with: clang, gcc 4.2.1, gcc 6.3.0 r315203: sbin/dhclient: fix `vendor` storage leak in parse_option_decl(..) 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. CID: 1007111-1007113
* MFC r311160, r311210, r311288, r311292, r311298, r311340asomers2017-02-021-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r311160: misc minor fixes in mpr(4) sys/dev/mpr/mpr_sas.c * Fix a potential null pointer dereference (CID 1305731) * Check for overrun of the ccb_scsiio.cdb_io.cdb_bytes buffer (CID 1211934) sys/dev/mpr/mpr_sas_lsi.c * Nullify a dangling pointer in mprsas_get_sata_identify * Fix a memory leak in mprsas_SSU_to_SATA_devices (CID 1211935) Reported by: Coverity (partially) CID: 1305731 1211934 1211935 Reviewed by: slm MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8880 r311210: Quell Coverity for diskinfo(8) * CID 1198994: Don't run the speed disk on a disk with no sectors * CID 1011442: Don't call close(2) if open(2) fails * CID 1011161: Use snprintf instead of sprintf * CID 1009825: Check the return value of lseek Reported by: Coverity CID: 1198994 1011442 1011161 1009825 MFC after: 4 weeks Sponsored by: Spectra Logic Corp r311288: Delete dead code in chat(8) It's always been dead, ever since first import in 1994. It's still dead in OpenBSD's version, too. Reported by: Coverity CID: 270586 MFC after: 4 weeks Sponsored by: Spectra Logic Corp r311292: Remove dead code in rpc_parse.c It's been dead ever since it was imported from TI-RPC in 1995. The dead code is still present in Illumos today, but was removed from NetBSD in 2006. Reported by: Coverity CID: 270097 Obtained from: NetBSD MFC after: 4 weeks Sponsored by: Spectra Logic Corp r311298: Remove dead code in dhclient(8) 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 r311340: Misc Coverity fixes for tail(1) CID 1006402: Initialize stack variable CID 271580: Don't leak memory when ENOMEM. Reported by: Coverity CID: 271580 1006402 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
* MFC r309027:brooks2016-11-301-2/+2
| | | | | | | | | | | | | | | | | Allocate a struct ifreq rather than using a (wrong) computed size for 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 Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8445
* dhclient(1): correct obvious mismatch in get_char().pfg2016-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
* dhclient: Fix the trivial buffer overruns correctlycem2016-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
* Revert r299512cem2016-05-181-14/+10
| | | | | | | | | | It broke client identifiers because I misunderstood the intent of the code. There is still a minor issue detected by Coverity (at least, I can't find where the code proves it isn't an issue). I'll follow up with a better fix for the CIDs. Reported by: Ian FREISLICH Sponsored by: EMC / Isilon Storage Division
* dhclient: Fix some trivial buffer overrunscem2016-05-121-10/+14
| | | | | | | | | | There was some confusion about how to limit a hardware address to at most 16 bytes. In some cases it would overrun a byte off the end of the array. Correct the types and rectify the overrun. Reported by: Coverity CIDs: 1008682, 1305550 Sponsored by: EMC / Isilon Storage Division
* Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedngie2016-05-041-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | after r298107 Summary of changes: - Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that namespacing is kept with FILES appropriately, and that this shouldn't need to be repeated if the namespace changes -- only the definition of PACKAGE needs to be changed - Allow PACKAGE to be overridden by callers instead of forcing it to always be `tests`. In the event we get to the point where things can be split up enough in the base system, it would make more sense to group the tests with the blocks they're a part of, e.g. byacc with byacc-tests, etc - Remove PACKAGE definitions where possible, i.e. where FILES wasn't used previously. - Remove unnecessary TESTSPACKAGE definitions; this has been elided into bsd.tests.mk - Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES; ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk. - Fix installation of files under data/ subdirectories in lib/libc/tests/hash and lib/libc/tests/net/getaddrinfo - Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup) Document the proposed changes in share/examples/tests/tests/... via examples so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of replacing FILES. share/mk/bsd.README didn't seem like the appropriate method of communicating that info. MFC after: never probably X-MFC with: r298107 PR: 209114 Relnotes: yes Tested with: buildworld, installworld, checkworld; buildworld, packageworld Sponsored by: EMC / Isilon Storage Division
* dhclient: Log a warning instead of bailing upon "illegal" optionssephe2016-04-201-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Azure, the DHCP servers add private option (id 0xf5), which contains binary form of an IPv4 address. Once this option is converted to string form, it could contain '$', e.g. IPv4 address: 100.72.36.54 binary form: 0x64 0x48 0x24 0x36 string form: "dH$6" dhclient bails upon "illegal" options like the above example, thus the VM bring-up will fail. Also as a side note, this "illegal" option detection was added in OpenBSD ~11years ago: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sbin/dhclient/dhclient.c?rev=1.50&content-type=text/x-cvsweb-markup And it was removed along with the removal of script support in OpenBSD ~3years ago: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sbin/dhclient/dhclient.c?rev=1.159&content-type=text/x-cvsweb-markup Reported by: Hongxiong Xian <v-hoxian microsoft com> Reviewed by: jhb, Dexuan Cui <decui microsoft com> Tested by: Hongxiong Xian <v-hoxian microsoft com> Analyzed by: Dong Liu <doliu microsoft com> MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5853
* MFHgjb2016-03-101-0/+20
|\ | | | | | | Sponsored by: The FreeBSD Foundation
| * DIRDEPS_BUILD: Connect MK_TESTS.bdrewery2016-03-091-0/+20
| | | | | | | | Sponsored by: EMC / Isilon Storage Division
* | Explicitly add more files to the 'runtime' package.gjb2016-02-091-0/+1
| | | | | | | | Sponsored by: The FreeBSD Foundation
* | First pass to fix the 'tests' packages.gjb2016-02-021-0/+4
|/ | | | Sponsored by: The FreeBSD Foundation
* Fix LDADD/DPADD that should be LIBADD.bdrewery2015-12-041-2/+1
| | | | Sponsored by: EMC / Isilon Storage Division
* Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) andngie2015-10-121-2/+0
| | | | | | | | | | | | netbsd-tests.test.mk (r289151) - Eliminate explicit OBJTOP/SRCTOP setting - Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk - Remove unnecessary TESTSDIR setting - Use SRCTOP where possible for clarity MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Divison
* Add META_MODE support.sjg2015-06-131-0/+20
|\ | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp
| * dirdeps.mk now sets DEP_RELDIRsjg2015-06-081-2/+0
| |
| * Merge sync of headsjg2015-05-273-4/+3
| |\
| * \ Merge from head@274682sjg2014-11-192-11/+1
| |\ \
| * \ \ Merge head from 7/28sjg2014-08-197-15/+11
| |\ \ \
| * | | | Updated dependenciessjg2014-05-161-1/+0
| | | | |
| * | | | Updated dependenciessjg2014-05-101-0/+2
| | | | |
| * | | | Merge from headsjg2014-05-081-1/+1
| |\ \ \ \
| * \ \ \ \ Merge headsjg2014-04-286-7/+420
| |\ \ \ \ \
| * \ \ \ \ \ Merge from headsjg2013-09-057-150/+272
| |\ \ \ \ \ \
| * | | | | | | Updated dependenciessjg2013-03-111-0/+1
| | | | | | | |
| * | | | | | | Updated dependenciessjg2013-02-161-2/+0
| | | | | | | |
| | | | | | | |
| | \ \ \ \ \ \
| *-. \ \ \ \ \ \ Sync from headsjg2012-11-042-0/+12
| |\ \ \ \ \ \ \ \
| * | | | | | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.marcel2012-08-221-0/+21
| | |/ / / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net>
* | | | | | | | | Add CAP_FCNTL to the lease file capsicum rights, and limit topkelsey2015-05-281-2/+6
| |_|_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CAP_FCNTL_GETFL. Without CAP_FCNTL_GETFL, the lease file truncation in rewrite_client_leases() will fail to trim old data when rewriting the file with a lesser amount of data. Reviewed by: pjd, rwatson Approved by: jmallett (mentor) MFC after: 1 week
* | | | | | | | mdoc: improvements to SEE ALSO.joel2014-12-272-2/+2
| | | | | | | |
* | | | | | | | Convert sbin/ to LIBADDbapt2014-11-251-2/+1
| |_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | Reduce overlinking
* | | | | | | Since r270929 raw sockets expect network byte order.glebius2014-09-111-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: avg
* | | | | | | Add LIBUTIL to DPADDngie2014-08-181-0/+1
| |_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will fix "make checkdpadd" MFC after: 5 days PR: 192759 Approved by: rpaulo (mentor)
* | | | | | Remove duplicated includes.pjd2014-06-262-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | Submitted by: Mariusz Zaborski <oshogbo@FreeBSD.org>
* | | | | | use .Mt to mark up email addresses consistently (part1)bapt2014-06-205-11/+11
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco@lastsummer.de>
* | | | | Use src.opts.mk in preference to bsd.own.mk except where we need stuffimp2014-05-061-1/+1
| |_|_|/ |/| | | | | | | | | | | from the latter.
* | | | Update most userspace consumers of capability.h to use capsicum.h instead.rwatson2014-03-162-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | auditdistd is not updated as I will make the change upstream and then do a vendor import sometime in the next week or two. MFC after: 3 weeks
* | | | Migrate tools/regression/sbin/ to the new tests layout.jmmv2014-03-164-0/+413
| | | | | | | | | | | | | | | | | | | | Pretty much all that this change does is shuffles the code around and hooks it into the regular build. The code of the old tests has not changed.
* | | | Use CAP_EVENT instead of the deprecated CAP_POLL_EVENT.brueffer2014-02-062-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PR: 185382 (based on) Submitted by: Loganaden Velvindron Reviewed by: pjd MFC after: 1 week
* | | | dhclient: change the pidfile's permissions to 644eadler2014-02-031-1/+1
| |_|/ |/| | | | | | | | | | | | | | | | | This change permits non-root users to determine if dhclient is running ('service dhclient status wlan0'). Discussed with: mjg, cperciva
* | | Change the cap_rights_t type from uint64_t to a structure that we can extendpjd2013-09-052-16/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the future in a backward compatible (API and ABI) way. The cap_rights_t represents capability rights. We used to use one bit to represent one right, but we are running out of spare bits. Currently the new structure provides place for 114 rights (so 50 more than the previous cap_rights_t), but it is possible to grow the structure to hold at least 285 rights, although we can make it even larger if 285 rights won't be enough. The structure definition looks like this: struct cap_rights { uint64_t cr_rights[CAP_RIGHTS_VERSION + 2]; }; The initial CAP_RIGHTS_VERSION is 0. The top two bits in the first element of the cr_rights[] array contain total number of elements in the array - 2. This means if those two bits are equal to 0, we have 2 array elements. The top two bits in all remaining array elements should be 0. The next five bits in all array elements contain array index. Only one bit is used and bit position in this five-bits range defines array index. This means there can be at most five array elements in the future. To define new right the CAPRIGHT() macro must be used. The macro takes two arguments - an array index and a bit to set, eg. #define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL) We still support aliases that combine few rights, but the rights have to belong to the same array element, eg: #define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL) #define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL) #define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP) There is new API to manage the new cap_rights_t structure: cap_rights_t *cap_rights_init(cap_rights_t *rights, ...); void cap_rights_set(cap_rights_t *rights, ...); void cap_rights_clear(cap_rights_t *rights, ...); bool cap_rights_is_set(const cap_rights_t *rights, ...); bool cap_rights_is_valid(const cap_rights_t *rights); void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src); void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src); bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little); Capability rights to the cap_rights_init(), cap_rights_set(), cap_rights_clear() and cap_rights_is_set() functions are provided by separating them with commas, eg: cap_rights_t rights; cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT); There is no need to terminate the list of rights, as those functions are actually macros that take care of the termination, eg: #define cap_rights_set(rights, ...) \ __cap_rights_set((rights), __VA_ARGS__, 0ULL) void __cap_rights_set(cap_rights_t *rights, ...); Thanks to using one bit as an array index we can assert in those functions that there are no two rights belonging to different array elements provided together. For example this is illegal and will be detected, because CAP_LOOKUP belongs to element 0 and CAP_PDKILL to element 1: cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL); Providing several rights that belongs to the same array's element this way is correct, but is not advised. It should only be used for aliases definition. This commit also breaks compatibility with some existing Capsicum system calls, but I see no other way to do that. This should be fine as Capsicum is still experimental and this change is not going to 9.x. Sponsored by: The FreeBSD Foundation
* | | Fix dhclient for interfaces that are down. The discover_interfaces() functionpjd2013-07-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | that looks for interface skips interfaces that are not UP. We need to call dhclient-script PREINIT before we call discover_interfaces(), so the script has a chance to bring the interface UP. Reported by: alfred
* | | MFp4 @229488:pjd2013-07-031-0/+3
| | | | | | | | | | | | | | | | | | | | | Sandbox unprivileged process using capability mode. Reviewed by: brooks Sponsored by: The FreeBSD Foundation
* | | MFp4 @229487:pjd2013-07-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Revoke all capability rights from STDIN and allow only for write to STDOUT and STDERR. All those descriptors are redirected to /dev/null. Reviewed by: brooks Sponsored by: The FreeBSD Foundation
* | | MFp4 @229486:pjd2013-07-031-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | Once PID is written to the pidfile, revoke all capability rights. We just want to keep the pidfile open. Reviewed by: brooks Sponsored by: The FreeBSD Foundation
* | | MFp4 @229485:pjd2013-07-031-0/+5
| | | | | | | | | | | | | | | | | | | | | Only allow to overwrite lease file. Reviewed by: brooks Sponsored by: The FreeBSD Foundation
OpenPOWER on IntegriCloud