diff --git a/Makefile.am b/Makefile.am index 933f334ffce..f6bc9414d00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1915,6 +1915,7 @@ sssctl_LDADD = \ $(NULL) sssctl_CFLAGS = \ $(AM_CFLAGS) \ + -DPYTHONDIR_PATH=\"$(python3dir)/sssd\" \ $(NULL) if BUILD_SUDO diff --git a/src/tools/sssctl/sssctl.c b/src/tools/sssctl/sssctl.c index 8adaf30910e..3816125ad3a 100644 --- a/src/tools/sssctl/sssctl.c +++ b/src/tools/sssctl/sssctl.c @@ -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), diff --git a/src/tools/sssctl/sssctl.h b/src/tools/sssctl/sssctl.h index 599ef65196f..c827bb87893 100644 --- a/src/tools/sssctl/sssctl.h +++ b/src/tools/sssctl/sssctl.h @@ -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); diff --git a/src/tools/sssctl/sssctl_logs.c b/src/tools/sssctl/sssctl_logs.c index ebb2c4571ca..b98cd68fec0 100644 --- a/src/tools/sssctl/sssctl_logs.c +++ b/src/tools/sssctl/sssctl_logs.c @@ -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) { \ @@ -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; +}