File pacemaker#3446-0001-Fix-tools-crm_verify-respects-verbosity-for-configur.patch of Package pacemaker.36799
From 987e0d2828e23f8b51e1d657315087a622ed0c20 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 30 Apr 2024 12:15:03 -0500
Subject: [PATCH 1/3] Fix: tools: crm_verify respects verbosity for
configuration issues
Because crm_verify previously set the configuration error/warning handlers to
out->err(), they were always displayed, regardless of quiet/verbose options.
Regression introduced by 2aa8a9e2ee0 (not yet released)
---
tools/crm_verify.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
Index: pacemaker-2.1.7+20231219.0f7f88312/tools/crm_verify.c
===================================================================
--- pacemaker-2.1.7+20231219.0f7f88312.orig/tools/crm_verify.c
+++ pacemaker-2.1.7+20231219.0f7f88312/tools/crm_verify.c
@@ -43,6 +43,7 @@ struct {
char *xml_file;
gboolean xml_stdin;
char *xml_string;
+ unsigned int verbosity;
} options;
static GOptionEntry data_entries[] = {
@@ -112,6 +113,30 @@ build_arg_context(pcmk__common_args_t *a
return context;
}
+/*!
+ * \internal
+ * \brief Output a configuration issue
+ *
+ * \param[in] ctx Output object
+ * \param[in] msg printf(3)-style format string
+ * \param[in] ... Format string arguments
+ */
+G_GNUC_PRINTF(2, 3)
+static void
+output_config_issue(void *ctx, const char *msg, ...)
+{
+ va_list ap;
+ char *buf = NULL;
+ pcmk__output_t *out = ctx;
+
+ va_start(ap, msg);
+ CRM_ASSERT(vasprintf(&buf, msg, ap) > 0);
+ if (options.verbosity > 0) {
+ out->err(out, "%s", buf);
+ }
+ va_end(ap);
+}
+
int
main(int argc, char **argv)
{
@@ -159,8 +184,14 @@ main(int argc, char **argv)
pcmk__register_lib_messages(out);
- pcmk__set_config_error_handler((pcmk__config_error_func) out->err, out);
- pcmk__set_config_warning_handler((pcmk__config_warning_func) out->err, out);
+ pcmk__set_config_error_handler(output_config_issue, out);
+ pcmk__set_config_warning_handler(output_config_issue, out);
+
+ if (pcmk__str_eq(args->output_ty, "xml", pcmk__str_none)) {
+ args->verbosity = 1;
+ }
+
+ options.verbosity = args->verbosity;
crm_info("=#=#=#=#= Getting XML =#=#=#=#=");
@@ -261,7 +288,7 @@ main(int argc, char **argv)
if (crm_config_error) {
rc = pcmk_rc_schema_validation;
- if (args->verbosity > 0 || pcmk__str_eq(args->output_ty, "xml", pcmk__str_none)) {
+ if (options.verbosity > 0 || pcmk__str_eq(args->output_ty, "xml", pcmk__str_none)) {
g_set_error(&error, PCMK__RC_ERROR, rc,
"Errors found during check: config not valid");
} else {
@@ -272,7 +299,7 @@ main(int argc, char **argv)
} else if (crm_config_warning) {
rc = pcmk_rc_schema_validation;
- if (args->verbosity > 0 || pcmk__str_eq(args->output_ty, "xml", pcmk__str_none)) {
+ if (options.verbosity > 0 || pcmk__str_eq(args->output_ty, "xml", pcmk__str_none)) {
g_set_error(&error, PCMK__RC_ERROR, rc,
"Warnings found during check: config may not be valid");
} else {