diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-01-26 22:55:11 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-01-26 22:55:11 +0000 |
commit | 35a2c30f49d348965291d8b7e740bc7d577fb3a8 (patch) | |
tree | ed848b581711bec043c208c37baa9d9bf8aa0eac | |
parent | 25cccb8ab675d83706381b00d965acb18aafe83e (diff) |
Add 'uselease' statement to allow the disabling of built-in or
previously specified 'append', 'default', 'ignore', 'prepend', or
'supersede' actions on the values provided in leases.
-rw-r--r-- | sbin/dhclient/clparse.c | 25 | ||||
-rw-r--r-- | sbin/dhclient/conflex.c | 5 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.conf.5 | 25 | ||||
-rw-r--r-- | sbin/dhclient/dhctoken.h | 3 |
4 files changed, 52 insertions, 6 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index af4042aec2a..fc77de4bf9d 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.180 2019/01/18 02:16:31 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.181 2019/01/26 22:55:10 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -333,6 +333,29 @@ parse_conf_decl(FILE *cfile, char *name) if (parse_ip_addr(cfile, &config->next_server) == 1) parse_semi(cfile); break; + case TOK_NOACTION: + memset(list, 0, sizeof(list)); + count = 0; + if (parse_option_list(cfile, &count, list) == 1) { + enum actions *p = config->default_actions; + if (count == 0) { + for (i = 0; i < DHO_COUNT; i++) { + free(config->defaults[i].data); + config->defaults[i].data = NULL; + config->defaults[i].len = 0; + p[i] = ACTION_NONE; + } + } else { + for (i = 0; i < count; i++) { + free(config->defaults[list[i]].data); + config->defaults[list[i]].data = NULL; + config->defaults[list[i]].len = 0; + p[list[i]] = ACTION_NONE; + } + } + parse_semi(cfile); + } + break; case TOK_PREPEND: if (parse_option(cfile, &i, config->defaults) == 1) { config->default_actions[i] = ACTION_PREPEND; diff --git a/sbin/dhclient/conflex.c b/sbin/dhclient/conflex.c index 2d97346e4aa..0ca5e1eeb76 100644 --- a/sbin/dhclient/conflex.c +++ b/sbin/dhclient/conflex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conflex.c,v 1.48 2017/11/06 13:27:19 krw Exp $ */ +/* $OpenBSD: conflex.c,v 1.49 2019/01/26 22:55:10 krw Exp $ */ /* Lexical scanner for dhclient config file. */ @@ -381,7 +381,8 @@ static const struct keywords { { "server-name", TOK_SERVER_NAME }, { "ssid", TOK_SSID }, { "supersede", TOK_SUPERSEDE }, - { "timeout", TOK_TIMEOUT } + { "timeout", TOK_TIMEOUT }, + { "uselease", TOK_NOACTION } }; int kw_cmp(const void *k, const void *e); diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5 index feddf48971a..8f3b701d956 100644 --- a/sbin/dhclient/dhclient.conf.5 +++ b/sbin/dhclient/dhclient.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.conf.5,v 1.44 2018/05/12 12:50:17 krw Exp $ +.\" $OpenBSD: dhclient.conf.5,v 1.45 2019/01/26 22:55:10 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: May 12 2018 $ +.Dd $Mdocdate: January 26 2019 $ .Dt DHCLIENT.CONF 5 .Os .Sh NAME @@ -216,6 +216,27 @@ or .Ic supersede for .Ar option . +.It Ic uselease Op Ar option , ... ; +Use the unmodified values provided in the lease for +any specified +.Ar option . +.Ic uselease +statements are cumulative. +If no +.Ar option +is specified all lease option values will be used unmodified. +.Ic uselease +for +.Ar option +overrides any previous +.Ic append , +.Ic default , +.Ic ignore , +.Ic prepend +or +.Ic supersede +for +.Ar option . .El .Sh OTHER DECLARATIONS .Bl -tag -width Ds diff --git a/sbin/dhclient/dhctoken.h b/sbin/dhclient/dhctoken.h index cdf39ebbbcb..bef9cf9a070 100644 --- a/sbin/dhclient/dhctoken.h +++ b/sbin/dhclient/dhctoken.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhctoken.h,v 1.14 2017/11/06 13:27:19 krw Exp $ */ +/* $OpenBSD: dhctoken.h,v 1.15 2019/01/26 22:55:10 krw Exp $ */ /* Tokens for config file lexer and parser. */ @@ -74,6 +74,7 @@ #define TOK_IGNORE 295 #define TOK_SSID 296 #define TOK_EPOCH 297 +#define TOK_NOACTION 298 #define is_identifier(x) ((x) >= TOK_FIRST_TOKEN && \ (x) != TOK_STRING && \ |