From 6c7e3f67345e07fce71d20f99fc6fe22c11f620b Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Wed, 20 Mar 2019 20:10:01 +0000 Subject: 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(). --- sbin/dhclient/clparse.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'sbin/dhclient/clparse.c') 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; -- cgit v1.2.3