[SSSD] [sssd PR#515][synchronized] sssctl: Showing help even when sssd not configured
URL: https://github.com/SSSD/sssd/pull/515 Author: amitkumar50 Title: #515: sssctl: Showing help even when sssd not configured Action: synchronized To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/515/head:pr515 git checkout pr515 From 81901701e5230cf62e856ba7cec837e6d0f112b0 Mon Sep 17 00:00:00 2001 From: amitkuma Date: Thu, 15 Feb 2018 18:21:10 +0530 Subject: [PATCH 1/2] sssctl: Showing help even when sssd not configured 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 --- 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; From 2e1eaf298e0643fde6e1439c24137448e6813521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Tue, 3 Apr 2018 10:20:29 +0200 Subject: [PATCH 2/2] sssctl: move check for version error to correct place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This check was added here: 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 490) int sss_tool_main(int argc, const char **argv, 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 491) struct sss_route_cmd *commands, 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 492) void *pvt) 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 493) { 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 494) struct sss_tool_ctx *tool_ctx; 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 495) uid_t uid; e98ccef2 (Pavel Březina 2016-06-09 16:13:34 +0200 496) errno_t ret; 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 497) 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 498) uid = getuid(); 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 499) if (uid != 0) { 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 500) DEBUG(SSSDBG_CRIT_FAILURE, "Running under %d, must be root\n", uid); 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 501) ERROR("%1$s must be run as root\n", argv[0]); 284937e6 (Pavel Březina 2015-07-22 10:02:02 +0200 502) retur
[SSSD] [sssd PR#515][synchronized] sssctl: Showing help even when sssd not configured
URL: https://github.com/SSSD/sssd/pull/515 Author: amitkumar50 Title: #515: sssctl: Showing help even when sssd not configured Action: synchronized To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/515/head:pr515 git checkout pr515 From b26157a84c6e773b74932d29d6485216a4a09a08 Mon Sep 17 00:00:00 2001 From: amitkuma Date: Thu, 15 Feb 2018 18:21:10 +0530 Subject: [PATCH] sssctl: Showing help even when sssd not configured 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 --- src/tools/common/sss_tools.c | 27 --- src/tools/common/sss_tools.h | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index e491a1286..46b7e12c8 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); @@ -179,7 +183,6 @@ errno_t sss_tool_init(TALLOC_CTX *mem_ctx, } sss_tool_common_opts(tool_ctx, argc, argv); - *_tool_ctx = tool_ctx; return EOK; @@ -333,13 +336,17 @@ 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 == ERR_SYSDB_VERSION_TOO_OLD) { +tool_ctx->init_err = ret; + } else 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); } @@ -503,9 +510,7 @@ int sss_tool_main(int argc, const char **argv, } ret = sss_tool_init(NULL, &argc, argv, &tool_ctx); -if (ret == ERR_SYSDB_VERSION_TOO_OLD) { -tool_ctx->init_err = ret; -} else if (ret != EOK) { +if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create tool context\n"); return EXIT_FAILURE; } 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; ___ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
[SSSD] [sssd PR#515][synchronized] sssctl: Showing help even when sssd not configured
URL: https://github.com/SSSD/sssd/pull/515 Author: amitkumar50 Title: #515: sssctl: Showing help even when sssd not configured Action: synchronized To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/515/head:pr515 git checkout pr515 From c5cbcdbebb753cec5ed0c918b5d00a1ec97d3129 Mon Sep 17 00:00:00 2001 From: amitkuma Date: Thu, 15 Feb 2018 18:21:10 +0530 Subject: [PATCH] sssctl: Showing help even when sssd not configured 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 --- src/tools/common/sss_tools.c | 36 ++-- src/tools/common/sss_tools.h | 5 +++-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index e491a1286..aee6bfcae 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -53,16 +53,20 @@ static struct poptOption *sss_tool_common_opts_table(void) } static void sss_tool_common_opts(struct sss_tool_ctx *tool_ctx, - int *argc, const char **argv) + int *argc, const char **argv, + bool *_help) { 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 +78,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)); +*_help = help; DEBUG_CLI_INIT(debug); @@ -168,7 +173,8 @@ static errno_t sss_tool_domains_init(TALLOC_CTX *mem_ctx, errno_t sss_tool_init(TALLOC_CTX *mem_ctx, int *argc, const char **argv, - struct sss_tool_ctx **_tool_ctx) + struct sss_tool_ctx **_tool_ctx, + bool *_help) { struct sss_tool_ctx *tool_ctx; @@ -178,8 +184,7 @@ errno_t sss_tool_init(TALLOC_CTX *mem_ctx, return ENOMEM; } -sss_tool_common_opts(tool_ctx, argc, argv); - +sss_tool_common_opts(tool_ctx, argc, argv, _help); *_tool_ctx = tool_ctx; return EOK; @@ -296,7 +301,7 @@ static int tool_cmd_init(struct sss_tool_ctx *tool_ctx, errno_t sss_tool_route(int argc, const char **argv, struct sss_tool_ctx *tool_ctx, struct sss_route_cmd *commands, - void *pvt) + void *pvt, bool help) { struct sss_cmdline cmdline; const char *cmd; @@ -333,13 +338,15 @@ 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 (!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); } @@ -494,6 +501,7 @@ int sss_tool_main(int argc, const char **argv, struct sss_tool_ctx *tool_ctx; uid_t uid; errno_t ret; +bool _help = false; uid = getuid(); if (uid != 0) { @@ -502,7 +510,7 @@ int sss_tool_main(int argc, const char **argv, return EXIT_FAILURE; } -ret = sss_tool_init(NULL, &argc, argv, &tool_ctx); +ret = sss_tool_init(NULL, &argc, argv, &tool_ctx, &_help); if (ret == ERR_SYSDB_VERSION_TOO_OLD) { tool_ctx->init_err = ret; } else if (ret != EOK) { @@ -510,7 +518,7 @@ int sss_tool_main(int argc, const char **argv, return EXIT_FAILURE; } -ret = sss_tool_route(argc, argv, tool_ctx, commands, pvt); +ret = sss_tool_route(argc, argv, tool_ct
[SSSD] [sssd PR#515][synchronized] sssctl: Showing help even when sssd not configured
URL: https://github.com/SSSD/sssd/pull/515 Author: amitkumar50 Title: #515: sssctl: Showing help even when sssd not configured Action: synchronized To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/515/head:pr515 git checkout pr515 From 97e1ee34f47203a024e1461cc6d423ceb2c71fc7 Mon Sep 17 00:00:00 2001 From: amitkuma Date: Thu, 15 Feb 2018 18:21:10 +0530 Subject: [PATCH] sssctl: Showing help even when sssd not configured 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 --- src/tools/common/sss_tools.c | 36 ++-- src/tools/common/sss_tools.h | 5 +++-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index e491a1286..05179b378 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -53,16 +53,20 @@ static struct poptOption *sss_tool_common_opts_table(void) } static void sss_tool_common_opts(struct sss_tool_ctx *tool_ctx, - int *argc, const char **argv) + int *argc, const char **argv, + bool *_help) { 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 +78,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)); +*_help = help; DEBUG_CLI_INIT(debug); @@ -168,7 +173,8 @@ static errno_t sss_tool_domains_init(TALLOC_CTX *mem_ctx, errno_t sss_tool_init(TALLOC_CTX *mem_ctx, int *argc, const char **argv, - struct sss_tool_ctx **_tool_ctx) + struct sss_tool_ctx **_tool_ctx, + bool *_help) { struct sss_tool_ctx *tool_ctx; @@ -178,8 +184,7 @@ errno_t sss_tool_init(TALLOC_CTX *mem_ctx, return ENOMEM; } -sss_tool_common_opts(tool_ctx, argc, argv); - +sss_tool_common_opts(tool_ctx, argc, argv, _help); *_tool_ctx = tool_ctx; return EOK; @@ -296,7 +301,7 @@ static int tool_cmd_init(struct sss_tool_ctx *tool_ctx, errno_t sss_tool_route(int argc, const char **argv, struct sss_tool_ctx *tool_ctx, struct sss_route_cmd *commands, - void *pvt) + void *pvt, bool _help) { struct sss_cmdline cmdline; const char *cmd; @@ -333,13 +338,15 @@ 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 (!_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); } @@ -494,6 +501,7 @@ int sss_tool_main(int argc, const char **argv, struct sss_tool_ctx *tool_ctx; uid_t uid; errno_t ret; +bool _help=0; uid = getuid(); if (uid != 0) { @@ -502,7 +510,7 @@ int sss_tool_main(int argc, const char **argv, return EXIT_FAILURE; } -ret = sss_tool_init(NULL, &argc, argv, &tool_ctx); +ret = sss_tool_init(NULL, &argc, argv, &tool_ctx, &_help); if (ret == ERR_SYSDB_VERSION_TOO_OLD) { tool_ctx->init_err = ret; } else if (ret != EOK) { @@ -510,7 +518,7 @@ int sss_tool_main(int argc, const char **argv, return EXIT_FAILURE; } -ret = sss_tool_route(argc, argv, tool_ctx, commands, pvt); +ret = sss_tool_route(argc, argv, tool_ctx, c
[SSSD] [sssd PR#515][synchronized] sssctl: Showing help even when sssd not configured
URL: https://github.com/SSSD/sssd/pull/515 Author: amitkumar50 Title: #515: sssctl: Showing help even when sssd not configured Action: synchronized To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/515/head:pr515 git checkout pr515 From 2a05965449fb4f0c43cf1f9edcff72ee2f7b8a23 Mon Sep 17 00:00:00 2001 From: amitkuma Date: Thu, 15 Feb 2018 18:21:10 +0530 Subject: [PATCH] sssctl: Showing help even when sssd not configured 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 --- src/tools/common/sss_tools.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index e491a1286..e04f2204f 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -333,13 +333,15 @@ 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 (strcmp(argv[2],"--help") != 0) { +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); } ___ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org