summaryrefslogtreecommitdiff
path: root/sbin/dhclient/clparse.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-03-22 23:58:52 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-03-22 23:58:52 +0000
commit69f28996217b3d38429590a7202bd7e55b7f6e97 (patch)
tree27faec8ad309a9a152cca896d913972351a592e7 /sbin/dhclient/clparse.c
parent699d62499842d9055e3dba86bdfb10b9c92b611c (diff)
Ignore client-identifier option in leases from a server. They're not supposed
to be there! Instead, always record the client-identifier used to obtain the lease. Ignore recorded leases that have a different client-identifier than the one currently in force. If a client-identifier is not specified in the dhclient.conf file, construct one from the network type and MAC, like most other clients out there do these days. Thus, if one plugs in a different USB network adapter, renewing the previous lease (which upsets servers due to the MAC being different) is skipped and DISCOVER is attempted at once. Issue noted and fix tested by tedu@.
Diffstat (limited to 'sbin/dhclient/clparse.c')
-rw-r--r--sbin/dhclient/clparse.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index afd1e65f209..d84dae96370 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.54 2013/03/21 12:41:12 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.55 2013/03/22 23:58:51 krw Exp $ */
/* Parser for dhclient config and lease files... */
@@ -413,6 +413,7 @@ void
parse_client_lease_statement(FILE *cfile, int is_static)
{
struct client_lease *lease, *lp, *pl;
+ struct option_data *opt1, *opt2;
int token;
token = next_token(NULL, cfile);
@@ -442,6 +443,19 @@ parse_client_lease_statement(FILE *cfile, int is_static)
token = next_token(NULL, cfile);
/*
+ * If the new lease is for an obsolete client-identifier, toss it.
+ */
+ opt1 = &lease->options[DHO_DHCP_CLIENT_IDENTIFIER];
+ opt2 = &config->send_options[DHO_DHCP_CLIENT_IDENTIFIER];
+ if (opt1->len && opt2->len && (opt1->len != opt2->len ||
+ memcmp(opt1->data, opt2->data, opt1->len))) {
+ note("Obsolete client identifier (%s) in recorded lease",
+ pretty_print_option( DHO_DHCP_CLIENT_IDENTIFIER, opt1, 0));
+ free_client_lease(lease);
+ return;
+ }
+
+ /*
* The new lease may supersede a lease that's not the active
* lease but is still on the lease list, so scan the lease list
* looking for a lease with the same address, and if we find it,