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

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