File pacemaker#3658-0001-Fix-libcib-treat-empty-variant-variables-same-as-uns.patch of Package pacemaker.36873
From a63a7b4947aa05924a2ea211e398f46465b58da7 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 17 Sep 2024 09:45:30 -0500
Subject: [PATCH] Fix: libcib: treat empty variant variables same as unset
Previously, an empty environment variable such as CIB_file= or
CIB_port= would trigger the relevant CIB variant even though it
couldn't work. Now, ignore an empty variable the same as if it were
unset.
Also improve logs.
---
lib/cib/cib_client.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
Index: pacemaker-2.0.5+20201202.ba59be712/lib/cib/cib_client.c
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/lib/cib/cib_client.c
+++ pacemaker-2.0.5+20201202.ba59be712/lib/cib/cib_client.c
@@ -293,39 +293,37 @@ cib_new(void)
{
const char *value = getenv("CIB_shadow");
- if (value && value[0] != 0) {
+ if (!pcmk__str_empty(value)) {
return cib_shadow_new(value);
}
value = getenv("CIB_file");
- if (value) {
+ if (!pcmk__str_empty(value)) {
return cib_file_new(value);
}
value = getenv("CIB_port");
- if (value) {
+ if (!pcmk__str_empty(value)) {
gboolean encrypted = TRUE;
int port = crm_parse_int(value, NULL);
const char *server = getenv("CIB_server");
const char *user = getenv("CIB_user");
const char *pass = getenv("CIB_passwd");
- value = getenv("CIB_encrypted");
- if (value && crm_is_true(value) == FALSE) {
- crm_info("Disabling TLS");
+ if (!crm_is_true(getenv("CIB_encrypted"))) {
encrypted = FALSE;
}
- if (user == NULL) {
+ if (pcmk__str_empty(user)) {
user = CRM_DAEMON_USER;
- crm_info("Defaulting to user: %s", user);
}
- if (server == NULL) {
+ if (pcmk__str_empty(server)) {
server = "localhost";
- crm_info("Defaulting to localhost");
}
+ crm_debug("Initializing %s remote CIB access to %s:%d as user %s",
+ (encrypted? "encrypted" : "plain-text"), server, port, user);
return cib_remote_new(server, user, pass, port, encrypted);
}