summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2018-05-16 19:51:11 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2018-05-16 19:51:11 +0000
commite439e7b8d7e1876d76befea9072e5c6fb88f1241 (patch)
treed0dc7f2998bae98d5ff2510d51f4bbc5d3d0ca46 /sbin
parent7c94e99b319b07e7823ba259dbca8f15755ef4b4 (diff)
Always record the client identifier used to obtain a lease. Servers
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@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 8a8fab3959e..3c0fb4caf58 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.569 2018/05/11 15:44:15 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.570 2018/05/16 19:51:10 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -1270,6 +1270,21 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
lease->filename[DHCP_FILE_LEN] = '\0';
}
+ /*
+ * Record the client identifier used to obtain the lease. We already
+ * checked that the packet client identifier is absent (RFC 2131) or
+ * matches what we sent (RFC 6842),
+ */
+ i = DHO_DHCP_CLIENT_IDENTIFIER;
+ if (lease->options[i].len == 0 && config->send_options[i].len != 0) {
+ lease->options[i].len = config->send_options[i].len;
+ lease->options[i].data = malloc(lease->options[i].len);
+ if (lease->options[i].data == NULL)
+ fatal("lease client-identifier");
+ memcpy(lease->options[i].data, config->send_options[i].data,
+ lease->options[i].len);
+ }
+
time(&lease->epoch);
return lease;