URL: https://github.com/SSSD/sssd/pull/403 Author: lslebodn Title: #403: Fix few sssctl debug-level related issues Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/403/head:pr403 git checkout pr403
From 2b1f62507ea44216293d61570244da177b2cb95b Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 11 Oct 2017 14:21:45 +0200 Subject: [PATCH 1/3] TOOLS: Log redirection info for sss_debuglevel to stderr --- src/tools/wrappers/sss_debuglevel.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/wrappers/sss_debuglevel.in b/src/tools/wrappers/sss_debuglevel.in index 8df4918d6..4deeafff6 100644 --- a/src/tools/wrappers/sss_debuglevel.in +++ b/src/tools/wrappers/sss_debuglevel.in @@ -1,4 +1,4 @@ #!/bin/sh sbindir=@sbindir@ -echo "Redirecting to $sbindir/sssctl debug-level" +echo "Redirecting to $sbindir/sssctl debug-level" >&2 $sbindir/sssctl debug-level $@ From 210427b37cc18e5305feb30d460e8d4a7cb4a240 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 11 Oct 2017 17:10:49 +0200 Subject: [PATCH 2/3] TOOLS: Print Better usage for sssctl debug-level There is missing command name in help sh# sssctl debug-level --help Usage: DEBUG_LEVEL_TO_SET -c, --config=STRING Specify a non-default config file Help options: -?, --help Show this help message --usage Display brief usage message --- src/tools/sssctl/sssctl_logs.c | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/src/tools/sssctl/sssctl_logs.c b/src/tools/sssctl/sssctl_logs.c index 32e0a7ac5..aca988c05 100644 --- a/src/tools/sssctl/sssctl_logs.c +++ b/src/tools/sssctl/sssctl_logs.c @@ -301,51 +301,24 @@ errno_t sssctl_debug_level(struct sss_cmdline *cmdline, void *pvt) { int ret; - int pc_debug = SSSDBG_DEFAULT; int debug_to_set = SSSDBG_INVALID; const char *debug_as_string = NULL; const char *config_file = NULL; const char *pc_config_file = NULL; struct debuglevel_tool_ctx *ctx = NULL; struct poptOption long_options[] = { - POPT_AUTOHELP - {"debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug, - 0, _("The debug level to run with"), NULL }, {"config", 'c', POPT_ARG_STRING, &pc_config_file, 0, _("Specify a non-default config file"), NULL}, POPT_TABLEEND }; - poptContext pc = NULL; - - debug_prg_name = cmdline->argv[0]; - - /* parse parameters */ - pc = poptGetContext(cmdline->argv[0], cmdline->argc, cmdline->argv, - long_options, POPT_CONTEXT_KEEP_FIRST); - poptSetOtherOptionHelp(pc, "DEBUG_LEVEL_TO_SET"); - while ((ret = poptGetNextOpt(pc)) != -1) { - switch (ret) { - default: - fprintf(stderr, "\nInvalid option %s: %s\n\n", - poptBadOption(pc, 0), poptStrerror(ret)); - poptPrintUsage(pc, stderr, 0); - ret = EXIT_FAILURE; - goto fini; - } - } - DEBUG_CLI_INIT(pc_debug); - - /* get debug level */ - debug_as_string = poptGetArg(pc); - if (debug_as_string == NULL) { - BAD_POPT_PARAMS(pc, _("Specify debug level you want to set\n"), - ret, fini); - } - /* No more arguments expected. If something follows it is an error. */ - if (poptGetArg(pc)) { - BAD_POPT_PARAMS(pc, _("Only one argument expected\n"), - ret, fini); + ret = sss_tool_popt_ex(cmdline, long_options, SSS_TOOL_OPT_OPTIONAL, NULL, + NULL, "DEBUG_LEVEL_TO_SET", + _("Specify debug level you want to set"), + &debug_as_string, NULL); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to parse command arguments\n"); + return ret; } /* get config file */ @@ -393,7 +366,6 @@ errno_t sssctl_debug_level(struct sss_cmdline *cmdline, "Is sssd running?"); fini: - poptFreeContext(pc); talloc_free(ctx); return ret; } From 6e21945d16dc5ffcea0580411ef0d12f56f0f7b6 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 11 Oct 2017 17:20:05 +0200 Subject: [PATCH 3/3] TOOLS: Hide option --debug in sssctl Related to old bug https://pagure.io/SSSD/sssd/issue/1224 --- src/tools/common/sss_tools.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index 0b676341f..e491a1286 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -32,10 +32,6 @@ static void sss_tool_print_common_opts(int min_len) { - fprintf(stderr, _("Common options:\n")); - fprintf(stderr, " %-*s\t %s\n", min_len, "--debug=INT", - _("The debug level to run with")); - fprintf(stderr, "\n"); fprintf(stderr, _("Help options:\n")); fprintf(stderr, " %-*s\t %s\n", min_len, "-?, --help", _("Show this for a command")); @@ -46,7 +42,7 @@ static void sss_tool_print_common_opts(int min_len) static struct poptOption *sss_tool_common_opts_table(void) { static struct poptOption common_opts[] = { - {"debug", '\0', POPT_ARG_INT, NULL, + {"debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, NULL, 0, NULL, NULL }, POPT_TABLEEND }; @@ -380,7 +376,7 @@ errno_t sss_tool_popt_ex(struct sss_cmdline *cmdline, {NULL, '\0', POPT_ARG_INCLUDE_TABLE, nonnull_popt_table(options), \ 0, _("Command options:"), NULL }, {NULL, '\0', POPT_ARG_INCLUDE_TABLE, sss_tool_common_opts_table(), \ - 0, _("Common options:"), NULL }, + 0, NULL, NULL }, POPT_AUTOHELP POPT_TABLEEND };
_______________________________________________ sssd-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
