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

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