summaryrefslogtreecommitdiff
path: root/sbin/dhclient/clparse.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2019-03-20 20:10:01 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2019-03-20 20:10:01 +0000
commit6c7e3f67345e07fce71d20f99fc6fe22c11f620b (patch)
treecc95053ab34647621f070b50d3b5c6bd144b4c29 /sbin/dhclient/clparse.c
parentceaa56f81bdfd1b57594eaf9b9973fe9a1d390cc (diff)
Do not accept dhclient.conf(5) "prepend" or "append" statements when
the option data cannot be prepended or appended to. Instead, treat "prepend" as "supersede" and "append" as "default". This preserves the safe aspects of current behaviour. Issue a parsing warning when appropriate to encourage people to fix their configuration files. Eliminate egregious repeated code by abstracting merge_option_data().
Diffstat (limited to 'sbin/dhclient/clparse.c')
-rw-r--r--sbin/dhclient/clparse.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 24ee95634fa..6998056e8fb 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.183 2019/02/12 16:50:44 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.184 2019/03/20 20:10:00 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -257,7 +257,7 @@ parse_conf_decl(FILE *cfile, char *name)
{
uint8_t list[DHO_COUNT];
char *val;
- int i, count, token;
+ int action, count, i, token;
uint32_t t;
token = next_token(NULL, cfile);
@@ -265,7 +265,10 @@ parse_conf_decl(FILE *cfile, char *name)
switch (token) {
case TOK_APPEND:
if (parse_option(cfile, &i, config->defaults) == 1) {
- config->default_actions[i] = ACTION_APPEND;
+ action = code_to_action(i, ACTION_APPEND);
+ if (action == ACTION_DEFAULT)
+ parse_warn("'append' treated as 'default'");
+ config->default_actions[i] = action;
parse_semi(cfile);
}
break;
@@ -356,7 +359,10 @@ parse_conf_decl(FILE *cfile, char *name)
break;
case TOK_PREPEND:
if (parse_option(cfile, &i, config->defaults) == 1) {
- config->default_actions[i] = ACTION_PREPEND;
+ action = code_to_action(i, ACTION_PREPEND);
+ if (action == ACTION_SUPERSEDE)
+ parse_warn("'prepend' treated as 'supersede'");
+ config->default_actions[i] = action;
parse_semi(cfile);
}
break;