Skip to content

Commit

Permalink
SSSCTL: Add analyze command
Browse files Browse the repository at this point in the history
Wrapper for sss_analyze

Print a message about limited functionality when tevent chain ID
support is not built.

Reviewed-by: Jakub Vávra <[email protected]>
Reviewed-by: Pavel Březina <[email protected]>
Reviewed-by: Sumit Bose <[email protected]>
  • Loading branch information
justin-stephenson authored and pbrezina committed Oct 14, 2021
1 parent 82e051e commit 097feb3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ sssctl_LDADD = \
$(NULL)
sssctl_CFLAGS = \
$(AM_CFLAGS) \
-DPYTHONDIR_PATH=\"$(python3dir)/sssd\" \
$(NULL)

if BUILD_SUDO
Expand Down
1 change: 1 addition & 0 deletions src/tools/sssctl/sssctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ int main(int argc, const char **argv)
SSS_TOOL_COMMAND("logs-remove", "Remove existing SSSD log files", 0, sssctl_logs_remove),
SSS_TOOL_COMMAND("logs-fetch", "Archive SSSD log files in tarball", 0, sssctl_logs_fetch),
SSS_TOOL_COMMAND("debug-level", "Change SSSD debug level", 0, sssctl_debug_level),
SSS_TOOL_COMMAND("analyze", "Analyze logged data", 0, sssctl_analyze),
#ifdef HAVE_LIBINI_CONFIG_V1_3
SSS_TOOL_DELIMITER("Configuration files tools:"),
SSS_TOOL_COMMAND_FLAGS("config-check", "Perform static analysis of SSSD configuration", 0, sssctl_config_check, SSS_TOOL_FLAG_SKIP_CMD_INIT),
Expand Down
4 changes: 4 additions & 0 deletions src/tools/sssctl/sssctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ errno_t sssctl_debug_level(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);

errno_t sssctl_analyze(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);

errno_t sssctl_user_show(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);
Expand Down
29 changes: 29 additions & 0 deletions src/tools/sssctl/sssctl_logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#define LOG_FILE(file) " " LOG_PATH "/" file
#define LOG_FILES LOG_FILE("*.log")
#define SSS_ANALYZE PYTHONDIR_PATH"/sss_analyze.py"

#define CHECK(expr, done, msg) do { \
if (expr) { \
Expand Down Expand Up @@ -388,3 +389,31 @@ errno_t sssctl_debug_level(struct sss_cmdline *cmdline,
talloc_free(ctx);
return ret;
}

errno_t sssctl_analyze(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt)
{
errno_t ret;

#ifndef BUILD_CHAIN_ID
PRINT("NOTE: Tevent chain ID support missing, request analysis will be limited.\n");
PRINT("It is recommended to use the --logdir option against tevent chain ID "
"supported SSSD logs.\n");
#endif
const char **args = talloc_array_size(tool_ctx,
sizeof(char *),
cmdline->argc + 2);
if (!args) {
return ENOMEM;
}
memcpy(&args[1], cmdline->argv, sizeof(char *) * cmdline->argc);
args[0] = SSS_ANALYZE;
args[cmdline->argc + 1] = NULL;

ret = sssctl_run_command(args);

talloc_free(args);

return ret;
}

0 comments on commit 097feb3

Please sign in to comment.