Blame SOURCES/0015-TOOLS-fixed-handling-of-init-error.patch

1c5238
From bd16242ef6780fd2808bf03f79eda5d940094bc5 Mon Sep 17 00:00:00 2001
1c5238
From: Alexey Tikhonov <atikhono@redhat.com>
1c5238
Date: Sun, 6 Nov 2022 12:25:37 +0100
1c5238
Subject: [PATCH 15/16] TOOLS: fixed handling of init error
1c5238
MIME-Version: 1.0
1c5238
Content-Type: text/plain; charset=UTF-8
1c5238
Content-Transfer-Encoding: 8bit
1c5238
1c5238
Before execution of `tool_cmd_init()` `init_err` wasn't set,
1c5238
so `sss_tools_handles_init_error()` check was a no-op.
1c5238
1c5238
Consequently, a proper check after `tool_cmd_init()` was missing.
1c5238
1c5238
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
1c5238
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
1c5238
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
1c5238
(cherry picked from commit 7af46ba0e925da61b7b4003c3fa6d51c05c1116e)
1c5238
1c5238
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
1c5238
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
1c5238
---
1c5238
 src/tools/common/sss_tools.c | 17 ++++-------------
1c5238
 src/tools/common/sss_tools.h |  1 -
1c5238
 2 files changed, 4 insertions(+), 14 deletions(-)
1c5238
1c5238
diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c
1c5238
index 47b85bdd2..38ae88306 100644
1c5238
--- a/src/tools/common/sss_tools.c
1c5238
+++ b/src/tools/common/sss_tools.c
1c5238
@@ -336,22 +336,13 @@ static errno_t sss_tool_route(int argc, const char **argv,
1c5238
             cmdline.argc = argc - 2;
1c5238
             cmdline.argv = argv + 2;
1c5238
 
1c5238
-            if (!sss_tools_handles_init_error(&commands[i], tool_ctx->init_err)) {
1c5238
-                DEBUG(SSSDBG_FATAL_FAILURE,
1c5238
-                      "Command %s does not handle initialization error [%d] %s\n",
1c5238
-                      cmdline.command, tool_ctx->init_err,
1c5238
-                      sss_strerror(tool_ctx->init_err));
1c5238
-                return tool_ctx->init_err;
1c5238
-            }
1c5238
-
1c5238
             if (!tool_ctx->print_help) {
1c5238
                 ret = tool_cmd_init(tool_ctx, &commands[i]);
1c5238
-                if (ret == ERR_SYSDB_VERSION_TOO_OLD) {
1c5238
-                    tool_ctx->init_err = ret;
1c5238
-                } else if (ret != EOK) {
1c5238
+
1c5238
+                if (!sss_tools_handles_init_error(&commands[i], ret)) {
1c5238
                     DEBUG(SSSDBG_FATAL_FAILURE,
1c5238
-                          "Command initialization failed [%d] %s\n",
1c5238
-                          ret, sss_strerror(ret));
1c5238
+                          "Command %s does not handle initialization error [%d] %s\n",
1c5238
+                          cmdline.command, ret, sss_strerror(ret));
1c5238
                     return ret;
1c5238
                 }
1c5238
             }
1c5238
diff --git a/src/tools/common/sss_tools.h b/src/tools/common/sss_tools.h
1c5238
index 578186633..75dc15391 100644
1c5238
--- a/src/tools/common/sss_tools.h
1c5238
+++ b/src/tools/common/sss_tools.h
1c5238
@@ -30,7 +30,6 @@ struct sss_tool_ctx {
1c5238
     struct confdb_ctx *confdb;
1c5238
 
1c5238
     bool print_help;
1c5238
-    errno_t init_err;
1c5238
     char *default_domain;
1c5238
     struct sss_domain_info *domains;
1c5238
 };
1c5238
-- 
1c5238
2.37.3
1c5238