Blame SOURCES/bz2113970-2-config-Add-enable-authfile-option.patch

f651e6
From 466246c2fa8ea1bcc06593fbf7b900d0665606b1 Mon Sep 17 00:00:00 2001
f651e6
From: Jan Friesse <jfriesse@redhat.com>
f651e6
Date: Tue, 26 Jul 2022 18:39:38 +0200
f651e6
Subject: [PATCH] config: Add enable-authfile option
f651e6
f651e6
This option enables (or disables) usage of authfile. Can be 'yes' or 'no'.
f651e6
Default is 'no'.
f651e6
f651e6
Booth usage of authfile was broken for long time (since commit
f651e6
da79b8ba28ad4837a0fee13e5f8fb6f89fe0e24c).
f651e6
f651e6
Pcs was adding authfile by default, but it was not used. Once booth bug
f651e6
was fixed problem appears because mixed clusters (with fixed version and
f651e6
without fixed one) stops working.
f651e6
f651e6
This non-upstream option is added and used to allow use of
f651e6
authfile without breaking compatibility for clusters
f651e6
consisting of mixed versions (usually happens before all nodes are
f651e6
updated) of booth (user have to explicitly
f651e6
enable usage of authfile).
f651e6
f651e6
This patch is transitional and will be removed in future major version of
f651e6
distribution.
f651e6
f651e6
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
f651e6
---
f651e6
 docs/boothd.8.txt |  7 +++++++
f651e6
 src/config.c      | 17 +++++++++++++++++
f651e6
 src/config.h      |  1 +
f651e6
 src/main.c        |  2 +-
f651e6
 4 files changed, 26 insertions(+), 1 deletion(-)
f651e6
f651e6
diff --git a/docs/boothd.8.txt b/docs/boothd.8.txt
f651e6
index f58f27e..12f66f9 100644
f651e6
--- a/docs/boothd.8.txt
f651e6
+++ b/docs/boothd.8.txt
f651e6
@@ -230,6 +230,13 @@ will always bind and listen to both UDP and TCP ports.
f651e6
 	parameter to a higher value. The time skew test is performed
f651e6
 	only in concert with authentication.
f651e6
 
f651e6
+*'enable-authfile'*::
f651e6
+	Enables (or disables) usage of authfile. Can be 'yes' or 'no'.
f651e6
+	Default is 'no'.
f651e6
+	This is non-upstream option used to allow use of authfile without
f651e6
+	breaking compatibility for clusters consisting of mixed
f651e6
+	versions of booth.
f651e6
+
f651e6
 *'site'*::
f651e6
 	Defines a site Raft member with the given IP. Sites can
f651e6
 	acquire tickets. The sites' IP should be managed by the cluster.
f651e6
diff --git a/src/config.c b/src/config.c
f651e6
index 8e41553..b9df3e3 100644
f651e6
--- a/src/config.c
f651e6
+++ b/src/config.c
f651e6
@@ -729,6 +729,23 @@ no_value:
f651e6
 			booth_conf->maxtimeskew = atoi(val);
f651e6
 			continue;
f651e6
 		}
f651e6
+
f651e6
+		if (strcmp(key, "enable-authfile") == 0) {
f651e6
+			if (strcasecmp(val, "yes") == 0 ||
f651e6
+			    strcasecmp(val, "on") == 0 ||
f651e6
+			    strcasecmp(val, "1") == 0) {
f651e6
+				booth_conf->enable_authfile = 1;
f651e6
+			} else if (strcasecmp(val, "no") == 0 ||
f651e6
+			    strcasecmp(val, "off") == 0 ||
f651e6
+			    strcasecmp(val, "0") == 0) {
f651e6
+				booth_conf->enable_authfile = 0;
f651e6
+			} else {
f651e6
+				error = "Expected yes/no value for enable-authfile";
f651e6
+				goto err;
f651e6
+			}
f651e6
+
f651e6
+			continue;
f651e6
+		}
f651e6
 #endif
f651e6
 
f651e6
 		if (strcmp(key, "site") == 0) {
f651e6
diff --git a/src/config.h b/src/config.h
f651e6
index bca73bc..da1e917 100644
f651e6
--- a/src/config.h
f651e6
+++ b/src/config.h
f651e6
@@ -297,6 +297,7 @@ struct booth_config {
f651e6
 	struct stat authstat;
f651e6
 	char authkey[BOOTH_MAX_KEY_LEN];
f651e6
 	int authkey_len;
f651e6
+	int enable_authfile;
f651e6
     /** Maximum time skew between peers allowed */
f651e6
 	int maxtimeskew;
f651e6
 
f651e6
diff --git a/src/main.c b/src/main.c
f651e6
index b4a174f..0fdb295 100644
f651e6
--- a/src/main.c
f651e6
+++ b/src/main.c
f651e6
@@ -364,7 +364,7 @@ static int setup_config(int type)
f651e6
 	if (rv < 0)
f651e6
 		goto out;
f651e6
 
f651e6
-	if (booth_conf->authfile[0] != '\0') {
f651e6
+	if (booth_conf->authfile[0] != '\0' && booth_conf->enable_authfile) {
f651e6
 		rv = read_authkey();
f651e6
 		if (rv < 0)
f651e6
 			goto out;
f651e6
-- 
f651e6
2.37.1
f651e6