From 6ffdd5ef2f196916525182b2c178db73562e510d Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Tue, 26 Jun 2018 04:02:25 +0000 Subject: [PATCH] config(8): Flip the order of concatenation for `hints` and `env` As previously noted, kernel's processing of these means that the first appearance of a hint/variable wins. Flipping the order of concatenation means that later variables override earlier variables, as expected when one does: hints x hints y Where perhaps x is: hint.aw_sid.0.disable=1 and y is: hint.aw_sid.0.disable=0 The expectation would be that a later appearing variable would override an earlier appearing variable, such as with `device`/`nodevice`, device.hints, and other similarly structured data files. --- usr.sbin/config/config.5 | 14 +++++++++----- usr.sbin/config/config.y | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/usr.sbin/config/config.5 b/usr.sbin/config/config.5 index fa745feb05f0..c33661f93937 100644 --- a/usr.sbin/config/config.5 +++ b/usr.sbin/config/config.5 @@ -129,8 +129,9 @@ All .Ic env and .Ic envvar -directives will be processed and added to the staitc environment in the order of -appearance. +directives will be processed and added to the static environment in reversed +order of appearance so that later specified variables properly override earlier +specified variables. Note that within .Ar filename , the first appearance of a given variable will be the first one seen by the @@ -150,8 +151,9 @@ All .Ic env and .Ic envvar -directives will be processed and added to the staitc environment in the order of -appearance. +directives will be processed and added to the static environment in reversed +order of appearance so that later specified variables properly override earlier +specified variables. .\" -------- FILES -------- .Pp .It Ic files Ar filename @@ -178,7 +180,9 @@ The file must conform to the syntax specified by .Xr device.hints 5 . Multiple hints lines are allowed. -The resulting hints will be the files concatenated in the order of appearance. +The resulting hints will be the files concatenated in reverse order of +appearance so that hints in later files properly override hints in earlier +files. .\" -------- IDENT -------- .Pp .It Ic ident Ar name diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index c79bc376b788..33658c54a823 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -200,7 +200,7 @@ Config_spec: if (hint == NULL) err(EXIT_FAILURE, "calloc"); hint->hint_name = $2; - STAILQ_INSERT_TAIL(&hints, hint, hint_next); + STAILQ_INSERT_HEAD(&hints, hint, hint_next); hintmode = 1; } @@ -360,7 +360,7 @@ newenvvar(char *name, bool is_file) err(EXIT_FAILURE, "calloc"); envvar->env_str = name; envvar->env_is_file = is_file; - STAILQ_INSERT_TAIL(&envvars, envvar, envvar_next); + STAILQ_INSERT_HEAD(&envvars, envvar, envvar_next); envmode = 1; }