Blame SOURCES/rhel-specific-0001-config-Add-enable-authfile-option.patch

88faad
From 87c8545816cca03d19c2f3ef54031940f7e19d50 Mon Sep 17 00:00:00 2001
cea3ae
From: Jan Friesse <jfriesse@redhat.com>
88faad
Date: Fri, 18 Nov 2022 11:57:46 +0100
cea3ae
Subject: [PATCH] config: Add enable-authfile option
cea3ae
cea3ae
This option enables (or disables) usage of authfile. Can be 'yes' or 'no'.
cea3ae
Default is 'no'.
cea3ae
cea3ae
Booth usage of authfile was broken for long time (since commit
cea3ae
da79b8ba28ad4837a0fee13e5f8fb6f89fe0e24c).
cea3ae
cea3ae
Pcs was adding authfile by default, but it was not used. Once booth bug
cea3ae
was fixed problem appears because mixed clusters (with fixed version and
cea3ae
without fixed one) stops working.
cea3ae
cea3ae
This non-upstream option is added and used to allow use of
cea3ae
authfile without breaking compatibility for clusters
cea3ae
consisting of mixed versions (usually happens before all nodes are
cea3ae
updated) of booth (user have to explicitly
cea3ae
enable usage of authfile).
cea3ae
cea3ae
This patch is transitional and will be removed in future major version of
cea3ae
distribution.
cea3ae
cea3ae
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
cea3ae
---
cea3ae
 docs/boothd.8.txt |  7 +++++++
cea3ae
 src/config.c      | 17 +++++++++++++++++
cea3ae
 src/config.h      |  1 +
cea3ae
 src/main.c        |  2 +-
cea3ae
 4 files changed, 26 insertions(+), 1 deletion(-)
cea3ae
cea3ae
diff --git a/docs/boothd.8.txt b/docs/boothd.8.txt
88faad
index 0f3d2c1..c7a8413 100644
cea3ae
--- a/docs/boothd.8.txt
cea3ae
+++ b/docs/boothd.8.txt
cea3ae
@@ -230,6 +230,13 @@ will always bind and listen to both UDP and TCP ports.
cea3ae
 	parameter to a higher value. The time skew test is performed
cea3ae
 	only in concert with authentication.
cea3ae
 
88faad
+'enable-authfile'::
cea3ae
+	Enables (or disables) usage of authfile. Can be 'yes' or 'no'.
cea3ae
+	Default is 'no'.
cea3ae
+	This is non-upstream option used to allow use of authfile without
cea3ae
+	breaking compatibility for clusters consisting of mixed
cea3ae
+	versions of booth.
cea3ae
+
88faad
 'debug'::
88faad
 	Specifies the debug output level. Alternative to
88faad
 	command line argument. Effective only for 'daemon'
cea3ae
diff --git a/src/config.c b/src/config.c
88faad
index f0ca4aa..e1f25f0 100644
cea3ae
--- a/src/config.c
cea3ae
+++ b/src/config.c
88faad
@@ -732,6 +732,23 @@ no_value:
cea3ae
 			booth_conf->maxtimeskew = atoi(val);
cea3ae
 			continue;
cea3ae
 		}
cea3ae
+
cea3ae
+		if (strcmp(key, "enable-authfile") == 0) {
cea3ae
+			if (strcasecmp(val, "yes") == 0 ||
cea3ae
+			    strcasecmp(val, "on") == 0 ||
cea3ae
+			    strcasecmp(val, "1") == 0) {
cea3ae
+				booth_conf->enable_authfile = 1;
cea3ae
+			} else if (strcasecmp(val, "no") == 0 ||
cea3ae
+			    strcasecmp(val, "off") == 0 ||
cea3ae
+			    strcasecmp(val, "0") == 0) {
cea3ae
+				booth_conf->enable_authfile = 0;
cea3ae
+			} else {
cea3ae
+				error = "Expected yes/no value for enable-authfile";
cea3ae
+				goto err;
cea3ae
+			}
cea3ae
+
cea3ae
+			continue;
cea3ae
+		}
cea3ae
 #endif
cea3ae
 
cea3ae
 		if (strcmp(key, "site") == 0) {
cea3ae
diff --git a/src/config.h b/src/config.h
cea3ae
index bca73bc..da1e917 100644
cea3ae
--- a/src/config.h
cea3ae
+++ b/src/config.h
cea3ae
@@ -297,6 +297,7 @@ struct booth_config {
cea3ae
 	struct stat authstat;
cea3ae
 	char authkey[BOOTH_MAX_KEY_LEN];
cea3ae
 	int authkey_len;
cea3ae
+	int enable_authfile;
cea3ae
     /** Maximum time skew between peers allowed */
cea3ae
 	int maxtimeskew;
cea3ae
 
cea3ae
diff --git a/src/main.c b/src/main.c
cea3ae
index b4a174f..0fdb295 100644
cea3ae
--- a/src/main.c
cea3ae
+++ b/src/main.c
cea3ae
@@ -364,7 +364,7 @@ static int setup_config(int type)
cea3ae
 	if (rv < 0)
cea3ae
 		goto out;
cea3ae
 
cea3ae
-	if (booth_conf->authfile[0] != '\0') {
cea3ae
+	if (booth_conf->authfile[0] != '\0' && booth_conf->enable_authfile) {
cea3ae
 		rv = read_authkey();
cea3ae
 		if (rv < 0)
cea3ae
 			goto out;
cea3ae
-- 
88faad
2.27.0
cea3ae