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

3382c2
From 466246c2fa8ea1bcc06593fbf7b900d0665606b1 Mon Sep 17 00:00:00 2001
3382c2
From: Jan Friesse <jfriesse@redhat.com>
3382c2
Date: Tue, 26 Jul 2022 18:39:38 +0200
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
3382c2
index f58f27e..12f66f9 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
 
3382c2
+*'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
+
3382c2
 *'site'*::
3382c2
 	Defines a site Raft member with the given IP. Sites can
3382c2
 	acquire tickets. The sites' IP should be managed by the cluster.
3382c2
diff --git a/src/config.c b/src/config.c
3382c2
index 8e41553..b9df3e3 100644
3382c2
--- a/src/config.c
3382c2
+++ b/src/config.c
3382c2
@@ -729,6 +729,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
-- 
3382c2
2.37.1
3382c2