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

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