mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Cory Tusar <Cory.Tusar@zii.aero>
To: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Cc: Chris Healy <Chris.Healy@zii.aero>
Subject: [PATCH 2/2] common: blspec: Both environment and config file machine-id must match
Date: Fri, 14 Jun 2019 20:35:11 +0000	[thread overview]
Message-ID: <20190614203438.18900-3-cory.tusar@zii.aero> (raw)
In-Reply-To: <20190614203438.18900-1-cory.tusar@zii.aero>

The original logic for determining whether or not to consider a blspec
entry as "matching" would return a false positive for cases in which a
machine-id was specified in a particular blspec configuration file, but
no such value was present in the environment.

This commit modifies that logic such that a machine-id is considered to
be "matching" ONLY if the values are identical in both the environment
and configuration file, OR if there is no machine-id specified in either
the environment or the configuration file.

Instances where a machine-id is specified in only one location will no
longer be considered a match, nor will instances where the UUID values
themselves differ.

Tested on a number of ZII platforms where we use a machine-id value to
differentiate between active and inactive OS partitions.

Signed-off-by: Cory Tusar <cory.tusar@zii.aero>
---
 common/blspec.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index 41f2a4c53..59859c9b3 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -430,16 +430,14 @@ out:
 
 static bool entry_is_match_machine_id(struct blspec_entry *entry)
 {
-	int ret = true;
 	const char *env_machineid = getenv_nonempty("global.boot.machine_id");
+	const char *machineid = blspec_entry_var_get(entry, "machine-id");
+	bool ret = !!env_machineid == !!machineid;
 
-	if (env_machineid) {
-		const char *machineid = blspec_entry_var_get(entry, "machine-id");
-		if (!machineid || strcmp(machineid, env_machineid)) {
-			pr_debug("ignoring entry with missmatched machine-id " \
-				"\"%s\" != \"%s\"\n", env_machineid, machineid);
-			ret = false;
-		}
+	if (env_machineid && machineid && strcmp(env_machineid, machineid)) {
+		pr_info("ignoring entry with mismatched machine-id " \
+			"\"%s\" != \"%s\"\n", env_machineid, machineid);
+		ret = false;
 	}
 
 	return ret;
-- 
2.21.0

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2019-06-14 20:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 20:35 [PATCH 0/2] Fix machine-id operation Cory Tusar
2019-06-14 20:35 ` [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id Cory Tusar
2019-06-17 12:21   ` Sascha Hauer
2019-06-17 18:06     ` Cory Tusar
2019-06-14 20:35 ` Cory Tusar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190614203438.18900-3-cory.tusar@zii.aero \
    --to=cory.tusar@zii.aero \
    --cc=Chris.Healy@zii.aero \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox