From c80f1a5c8eb717ea5f56d57fa0c28e67b71694c4 Mon Sep 17 00:00:00 2001 From: krw Date: Thu, 7 Dec 2017 19:03:15 +0000 Subject: [PATCH] Nuke support for defining last-gasp leases in dhclient.conf. --- sbin/dhclient/clparse.c | 10 ++---- sbin/dhclient/dhclient.c | 59 ++--------------------------------- sbin/dhclient/dhclient.conf.5 | 15 ++------- sbin/dhclient/dhcpd.h | 3 +- 4 files changed, 9 insertions(+), 78 deletions(-) diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 5ad556910af..071dbf58fd8 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.151 2017/12/03 20:53:28 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.152 2017/12/07 19:03:15 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -126,7 +126,6 @@ read_client_conf(char *name) new_parse(path_dhclient_conf); - TAILQ_INIT(&config->static_leases); TAILQ_INIT(&config->reject_list); /* Set some defaults. */ @@ -237,7 +236,6 @@ read_client_leases(char *name, struct client_lease_tq *tq) void parse_client_statement(FILE *cfile, char *name, int nested) { - struct client_lease *lp; char *val; int i, token; @@ -288,11 +286,7 @@ parse_client_statement(FILE *cfile, char *name, int nested) ; break; case TOK_LEASE: - if (nested == 1) { - parse_warn("expecting statement."); - skip_to_semi(cfile); - } else if (parse_client_lease_statement(cfile, name, &lp) == 1) - add_lease(&config->static_leases, lp); + skip_to_semi(cfile); break; case TOK_LINK_TIMEOUT: if (parse_lease_time(cfile, &config->link_timeout) == 1) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 6506668b331..e2045a45974 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.536 2017/12/06 13:57:27 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.537 2017/12/07 19:03:15 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -168,7 +168,6 @@ void append_statement(char *, size_t, char *, char *); time_t lease_expiry(struct client_lease *); time_t lease_renewal(struct client_lease *); time_t lease_rebind(struct client_lease *); -int lease_is_static(struct client_lease *); struct client_lease *packet_to_lease(struct interface_info *, struct option_data *); @@ -177,7 +176,6 @@ int rdaemon(int); void take_charge(struct interface_info *, int); void set_default_client_identifier(struct interface_info *); struct client_lease *get_recorded_lease(struct interface_info *); -struct client_lease *get_static_lease(struct interface_info *); #define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) @@ -1073,7 +1071,7 @@ newlease: free_client_lease(lease); } } - if (lease_is_static(ifi->active) == 0 && seen == 0) + if (seen == 0) TAILQ_INSERT_HEAD(&ifi->leases, ifi->active, next); /* Write out new leases file. */ @@ -1359,9 +1357,6 @@ state_panic(struct interface_info *ifi) log_info("%s: no acceptable DHCPOFFERS received", log_procname); ifi->offer = get_recorded_lease(ifi); - if (ifi->offer == NULL) - ifi->offer = get_static_lease(ifi); - if (ifi->offer != NULL) { ifi->state = S_REQUESTING; bind_lease(ifi); @@ -1716,8 +1711,7 @@ free_client_lease(struct client_lease *lease) { int i; - /* Static leases are forever. */ - if (lease == NULL || lease_is_static(lease)) + if (lease == NULL) return; free(lease->interface); @@ -2527,40 +2521,6 @@ get_recorded_lease(struct interface_info *ifi) return lp; } -struct client_lease * -get_static_lease(struct interface_info *ifi) -{ - char ifname[IF_NAMESIZE]; - time_t cur_time; - struct client_lease *lp; - int i; - - time(&cur_time); - - /* Run through the list of leases and see if one can be used. */ - i = DHO_DHCP_CLIENT_IDENTIFIER; - TAILQ_FOREACH(lp, &config->static_leases, next) { - if (lp->ssid_len != ifi->ssid_len) - continue; - if (memcmp(lp->ssid, ifi->ssid, lp->ssid_len) != 0) - continue; - if ((lp->options[i].len != 0) && ((lp->options[i].len != - config->send_options[i].len) || - memcmp(lp->options[i].data, config->send_options[i].data, - lp->options[i].len))) - continue; - if (addressinuse(ifi->name, lp->address, ifname) != 0 && - strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) - continue; - - break; - } - - if (lp != NULL) - time(&lp->epoch); - - return lp; -} void set_default_client_identifier(struct interface_info *ifi) @@ -2648,16 +2608,3 @@ lease_rebind(struct client_lease *lease) return lease->epoch + rebind; } - -int -lease_is_static(struct client_lease *lease) -{ - struct client_lease *lp; - - TAILQ_FOREACH(lp, &config->static_leases, next) { - if (lp == lease) - return 1; - } - - return 0; -} diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5 index b68babbadda..4fd59754949 100644 --- a/sbin/dhclient/dhclient.conf.5 +++ b/sbin/dhclient/dhclient.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.conf.5,v 1.36 2017/10/20 13:04:50 krw Exp $ +.\" $OpenBSD: dhclient.conf.5,v 1.37 2017/12/07 19:03:15 krw Exp $ .\" .\" Copyright (c) 1997 The Internet Software Consortium. .\" All rights reserved. @@ -36,7 +36,7 @@ .\" see ``http://www.isc.org/isc''. To learn more about Vixie .\" Enterprises, see ``http://www.vix.com''. .\" -.Dd $Mdocdate: October 20 2017 $ +.Dd $Mdocdate: December 7 2017 $ .Dt DHCLIENT.CONF 5 .Os .Sh NAME @@ -206,16 +206,7 @@ Apply any .Ar declaration only to the named interface. .Ar interface -declarations cannot be nested and cannot contain -.Ar lease -declarations. -.It Ic lease No { Ar declaration ; ... ; No } -Define a lease that can be used when no lease is obtained from a server. -See -.Xr dhclient.leases 5 -for the complete description of the -.Ic lease -format. +declarations cannot be nested. .It Ic reject Ar ip-address ; Discard leases from the specified address. If more than one diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index b3510425ab2..6b46965fce4 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.239 2017/12/06 13:57:27 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.240 2017/12/07 19:03:15 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -111,7 +111,6 @@ struct client_config { char *resolv_tail; char *filename; char *server_name; - struct client_lease_tq static_leases; }; -- 2.20.1