sssd/0030-sssctl-Showing-help-even-when-sssd-not-configured.patch
Fabiano Fidêncio d6e60d0953 Resolves: upstream#3634 - sssctl COMMAND --help fails if sssd is not configured
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
(cherry picked from commit 64b69ec813)
(cherry picked from commit d5953555e4)
(cherry picked from commit 54dfcbfa15)
2018-04-27 22:31:22 +02:00

102 lines
3.4 KiB
Diff

From 3d0fd106754c7614f5d9fb3875d0b40092d200f3 Mon Sep 17 00:00:00 2001
From: amitkuma <amitkuma@redhat.com>
Date: Thu, 15 Feb 2018 18:21:10 +0530
Subject: [PATCH] sssctl: Showing help even when sssd not configured
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On a clean and unconfigured system, it's not possible
to use --help.
1) dnf install sssd-tools
2) sssctl cache-remove --help
Shows:
[confdb_get_domains] (0x0010): No domains configured, fatal error!
Solution: Donot check for confdb initialization when sssctl 3rd
command line argument passed is '--help'.
Please note when we run 'sssctl --help' on unconfigured system
confdb check is not done and proper o/p is seen.
Resolves: https://pagure.io/SSSD/sssd/issue/3634
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
(cherry picked from commit b8db8c2d83d1d75c42c1e17145d3907211b3a146)
---
src/tools/common/sss_tools.c | 19 ++++++++++++-------
src/tools/common/sss_tools.h | 1 +
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c
index 4832db5a0..d45584ce1 100644
--- a/src/tools/common/sss_tools.c
+++ b/src/tools/common/sss_tools.c
@@ -58,11 +58,14 @@ static void sss_tool_common_opts(struct sss_tool_ctx *tool_ctx,
poptContext pc;
int debug = SSSDBG_DEFAULT;
int orig_argc = *argc;
+ int help = 0;
int opt;
struct poptOption options[] = {
{"debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_STRIP, &debug,
0, _("The debug level to run with"), NULL },
+ {"help", '?', POPT_ARG_VAL | POPT_ARGFLAG_DOC_HIDDEN, &help,
+ 1, NULL, NULL },
POPT_TABLEEND
};
@@ -74,6 +77,7 @@ static void sss_tool_common_opts(struct sss_tool_ctx *tool_ctx,
/* Strip common options from arguments. We will discard_const here,
* since it is not worth the trouble to convert it back and forth. */
*argc = poptStrippedArgv(pc, orig_argc, discard_const_p(char *, argv));
+ tool_ctx->print_help = help;
DEBUG_CLI_INIT(debug);
@@ -187,7 +191,6 @@ errno_t sss_tool_init(TALLOC_CTX *mem_ctx,
}
sss_tool_common_opts(tool_ctx, argc, argv);
-
*_tool_ctx = tool_ctx;
return EOK;
@@ -341,12 +344,14 @@ errno_t sss_tool_route(int argc, const char **argv,
return tool_ctx->init_err;
}
- ret = tool_cmd_init(tool_ctx, &commands[i]);
- if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE,
- "Command initialization failed [%d] %s\n",
- ret, sss_strerror(ret));
- return ret;
+ if (!tool_ctx->print_help) {
+ ret = tool_cmd_init(tool_ctx, &commands[i]);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Command initialization failed [%d] %s\n",
+ ret, sss_strerror(ret));
+ return ret;
+ }
}
return commands[i].fn(&cmdline, tool_ctx, pvt);
diff --git a/src/tools/common/sss_tools.h b/src/tools/common/sss_tools.h
index 848009365..0e4308ee6 100644
--- a/src/tools/common/sss_tools.h
+++ b/src/tools/common/sss_tools.h
@@ -29,6 +29,7 @@
struct sss_tool_ctx {
struct confdb_ctx *confdb;
+ bool print_help;
errno_t init_err;
char *default_domain;
struct sss_domain_info *domains;
--
2.14.3