From 222a1a48e8af33b5bc9cadbaa1579d28d9061736 Mon Sep 17 00:00:00 2001 From: krw Date: Mon, 18 Dec 2017 14:17:58 +0000 Subject: [PATCH] Stop inserting and paying attention to 'interface ;' inside 'lease {}' declarations. We don't keep leases from multiple interfaces in dhclient.leases. files. One less thing to parse and keep in memory. More rope for those wanting to do unspeakable things with their lease files. --- sbin/dhclient/clparse.c | 18 +++++------------- sbin/dhclient/dhclient.c | 8 +------- sbin/dhclient/dhclient.leases.5 | 10 ++-------- sbin/dhclient/dhcpd.h | 3 +-- 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index db82ae7de12..722b7aee15b 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.158 2017/12/17 14:24:04 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.159 2017/12/18 14:17:58 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -543,13 +543,7 @@ parse_lease(FILE *cfile, char *name, } if (token == '}') { token = next_token(NULL, cfile); - if (lease->interface != NULL && - strcmp(name, lease->interface) == 0) - *lp = lease; - else { - *lp = NULL; - free_client_lease(lease); - } + *lp = lease; return 1; } parse_lease_declaration(cfile, lease, name); @@ -607,11 +601,9 @@ parse_lease_declaration(FILE *cfile, struct client_lease *lease, return; break; case TOK_INTERFACE: - if (parse_string(cfile, NULL, &val) == 0) - return; - free(lease->interface); - lease->interface = val; - break; + /* 'interface' is just a comment. */ + skip_to_semi(cfile); + return; case TOK_NEXT_SERVER: if (parse_ip_addr(cfile, &lease->next_server) == 0) return; diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index fce081c919a..d193457758a 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.541 2017/12/16 20:47:53 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.542 2017/12/18 14:17:58 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -1683,7 +1683,6 @@ free_client_lease(struct client_lease *lease) if (lease == NULL) return; - free(lease->interface); free(lease->server_name); free(lease->filename); for (i = 0; i < DHO_COUNT; i++) @@ -1883,11 +1882,6 @@ lease_as_string(char *ifname, char *type, struct client_lease *lease) strlcat(string, " {\n", sizeof(string)); strlcat(string, BOOTP_LEASE(lease) ? " bootp;\n" : "", sizeof(string)); - buf = pretty_print_string(ifname, strlen(ifname), 1); - if (buf == NULL) - return NULL; - append_statement(string, sizeof(string), " interface ", buf); - append_statement(string, sizeof(string), " fixed-address ", inet_ntoa(lease->address)); append_statement(string, sizeof(string), " next-server ", diff --git a/sbin/dhclient/dhclient.leases.5 b/sbin/dhclient/dhclient.leases.5 index 430b3930bf4..782f71f3ad0 100644 --- a/sbin/dhclient/dhclient.leases.5 +++ b/sbin/dhclient/dhclient.leases.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.leases.5,v 1.13 2017/11/09 17:30:22 jmc Exp $ +.\" $OpenBSD: dhclient.leases.5,v 1.14 2017/12/18 14:17:58 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: November 9 2017 $ +.Dd $Mdocdate: December 18 2017 $ .Dt DHCLIENT.LEASES 5 .Os .Sh NAME @@ -140,12 +140,6 @@ The IPv4 address of the lease. This is required for all lease statements. The IPv4 address is specified as a dotted quad (e.g. 12.34.56.78). .Pp -.It Ic interface Qq Ar string -The interface on which the lease is valid. -Every lease must contain an -.Ic interface -declaration. -.Pp .It Ic next-server Ar ip-address The IPv4 address of the boot server. The IPv4 address is specified as a dotted quad (e.g. 12.34.56.78). diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 2cd04e1bf7b..19782e52554 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.242 2017/12/16 20:47:53 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.243 2017/12/18 14:17:58 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -56,7 +56,6 @@ struct reject_elem { struct client_lease { TAILQ_ENTRY(client_lease) next; - char *interface; time_t epoch; struct in_addr address; struct in_addr next_server; -- 2.20.1