diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-27 15:51:49 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-27 15:51:49 +0000 |
commit | 38e62cad30f7f4cc961b14e43c7b532a1cfe1f02 (patch) | |
tree | 0f64cd7f7e08d91f274778805a41e4a3c07db219 /sbin/dhclient | |
parent | 2339e83e2ae9a132194138fccdd6c58d5192295e (diff) |
Clean up parsing of option lists. Part 6.
Treat 'ignore' option lists the same as 'request' and 'require'
option lists. i.e. keep a list of the options rather than using
an ACTION flag. So overriding a previous ignore list will not leave
breadcrumbs and incorrect ACTIONs lying around.
The list will be applied when the new lease is created, and will
override any ACTION specified for the option.
Mention in dhclient.conf(5) that each request/require/ignore statement
will override any previous one.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/clparse.c | 17 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 22 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.conf.5 | 21 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 5 |
4 files changed, 45 insertions, 20 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 33f1f8c8c26..c22072c6696 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.47 2012/11/27 14:14:16 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.48 2012/11/27 15:51:48 krw Exp $ */ /* Parser for dhclient config and lease files... */ @@ -154,7 +154,7 @@ void parse_client_statement(FILE *cfile) { u_int8_t optlist[256]; - int token, code, count, i; + int token, code, count; switch (next_token(NULL, cfile)) { case TOK_SEND: @@ -170,11 +170,6 @@ parse_client_statement(FILE *cfile) if (code != -1) config->default_actions[code] = ACTION_SUPERSEDE; return; - case TOK_IGNORE: - count = parse_option_list(cfile, optlist, sizeof(optlist)); - for (i = 0; i < count; i++) - config->default_actions[optlist[i]] = ACTION_IGNORE; - return; case TOK_APPEND: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) @@ -207,6 +202,14 @@ parse_client_statement(FILE *cfile) sizeof(config->required_options)); } return; + case TOK_IGNORE: + count = parse_option_list(cfile, optlist, sizeof(optlist)); + if (count > 0) { + config->ignored_option_count = count; + memcpy(config->ignored_options, optlist, + sizeof(config->ignored_options)); + } + return; case TOK_LINK_TIMEOUT: parse_lease_time(cfile, &config->link_timeout); return; diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index f405309e901..fbd5bc16032 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.181 2012/11/25 12:49:56 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.182 2012/11/27 15:51:48 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1896,19 +1896,23 @@ struct client_lease * apply_defaults(struct client_lease *lease) { struct client_lease *newlease; - int i; + int i, j; newlease = clone_lease(lease); for (i = 0; i < 256; i++) { - switch (config->default_actions[i]) { - case ACTION_IGNORE: - if (newlease->options[i].len != 0) + for (j = 0; j < config->ignored_option_count; j++) { + if (config->ignored_options[j] == i) { free(newlease->options[i].data); - newlease->options[i].data = NULL; - newlease->options[i].len = 0; - break; - + newlease->options[i].data = NULL; + newlease->options[i].len = 0; + break; + } + } + if (j < config->ignored_option_count) + continue; + + switch (config->default_actions[i]) { case ACTION_SUPERSEDE: if (newlease->options[i].len != 0) free(newlease->options[i].data); diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5 index e3a351db0e8..39ec2f0b327 100644 --- a/sbin/dhclient/dhclient.conf.5 +++ b/sbin/dhclient/dhclient.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.conf.5,v 1.25 2012/10/30 18:39:44 krw Exp $ +.\" $OpenBSD: dhclient.conf.5,v 1.26 2012/11/27 15:51:48 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 30 2012 $ +.Dd $Mdocdate: November 27 2012 $ .Dt DHCLIENT.CONF 5 .Os .Sh NAME @@ -188,6 +188,11 @@ statement causes the client to discard values provided by the server for the specified options. Only the option names should be specified in the ignore statement \- not option parameters. +Only the last +.Ic ignore +statement has any effect, overriding any previous +.Ic ignore +statement. .It Xo .Ic request Op Ar option .Oo , Ar ... option Oc ; @@ -198,6 +203,11 @@ statement causes the client to request that any server responding to the client send the client its values for the specified options. Only the option names should be specified in the request statement \- not option parameters. +Only the last +.Ic request +statement has any effect, overriding any previous +.Ic request +statement. .It Xo .Ic require Op Ar option .Oo , Ar ... option Oc ; @@ -206,6 +216,13 @@ The .Ic require statement lists options that must be sent in order for an offer to be accepted. Offers that do not contain all the listed options will be ignored. +Only the option names should be specified in the require statement \- not +option parameters. +Only the last +.Ic require +statement has any effect, overriding any previous +.Ic require +statement. .It Xo .Ic send No { Op Ar option declaration .Oo , Ar ... option declaration Oc } diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 03cd18df5cc..6105a28bcb1 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.94 2012/11/25 12:49:56 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.95 2012/11/27 15:51:48 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -120,7 +120,6 @@ struct client_config { struct option_data defaults[256]; enum { ACTION_DEFAULT, - ACTION_IGNORE, ACTION_SUPERSEDE, ACTION_PREPEND, ACTION_APPEND @@ -129,8 +128,10 @@ struct client_config { struct option_data send_options[256]; u_int8_t required_options[256]; u_int8_t requested_options[256]; + u_int8_t ignored_options[256]; int requested_option_count; int required_option_count; + int ignored_option_count; time_t timeout; time_t initial_interval; time_t link_timeout; |