|
|
0034f4 |
From 66c318d212d56e26f303fc52d5fecbde4a6b9589 Mon Sep 17 00:00:00 2001
|
|
|
0034f4 |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
0034f4 |
Date: Thu, 10 Nov 2022 22:18:06 +0100
|
|
|
0034f4 |
Subject: [PATCH 16/16] SSSCTL: don't require 'root' for "analyze" cmd
|
|
|
0034f4 |
MIME-Version: 1.0
|
|
|
0034f4 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0034f4 |
Content-Transfer-Encoding: 8bit
|
|
|
0034f4 |
|
|
|
0034f4 |
:relnote: `sssctl analyze` tool doesn't require anymore to be run under root.
|
|
|
0034f4 |
|
|
|
0034f4 |
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
0034f4 |
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
|
|
|
0034f4 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
0034f4 |
(cherry picked from commit 99791400bec1054cf0081884e013a3cbed75fe8a)
|
|
|
0034f4 |
|
|
|
0034f4 |
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
0034f4 |
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
|
|
|
0034f4 |
---
|
|
|
0034f4 |
src/tools/common/sss_tools.c | 16 +++++++++-------
|
|
|
0034f4 |
src/tools/common/sss_tools.h | 3 ++-
|
|
|
0034f4 |
src/tools/sssctl/sssctl.c | 2 +-
|
|
|
0034f4 |
3 files changed, 12 insertions(+), 9 deletions(-)
|
|
|
0034f4 |
|
|
|
0034f4 |
diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c
|
|
|
0034f4 |
index 38ae88306..d16de7c4d 100644
|
|
|
0034f4 |
--- a/src/tools/common/sss_tools.c
|
|
|
0034f4 |
+++ b/src/tools/common/sss_tools.c
|
|
|
0034f4 |
@@ -267,6 +267,15 @@ static int tool_cmd_init(struct sss_tool_ctx *tool_ctx,
|
|
|
0034f4 |
struct sss_route_cmd *command)
|
|
|
0034f4 |
{
|
|
|
0034f4 |
int ret;
|
|
|
0034f4 |
+ uid_t uid;
|
|
|
0034f4 |
+
|
|
|
0034f4 |
+ if (!(command->flags & SSS_TOOL_FLAG_SKIP_ROOT_CHECK)) {
|
|
|
0034f4 |
+ uid = getuid();
|
|
|
0034f4 |
+ if (uid != 0) {
|
|
|
0034f4 |
+ ERROR("'%s' must be run as root\n", command->command);
|
|
|
0034f4 |
+ return EXIT_FAILURE;
|
|
|
0034f4 |
+ }
|
|
|
0034f4 |
+ }
|
|
|
0034f4 |
|
|
|
0034f4 |
if (command->flags & SSS_TOOL_FLAG_SKIP_CMD_INIT) {
|
|
|
0034f4 |
return EOK;
|
|
|
0034f4 |
@@ -515,15 +524,8 @@ int sss_tool_main(int argc, const char **argv,
|
|
|
0034f4 |
void *pvt)
|
|
|
0034f4 |
{
|
|
|
0034f4 |
struct sss_tool_ctx *tool_ctx;
|
|
|
0034f4 |
- uid_t uid;
|
|
|
0034f4 |
errno_t ret;
|
|
|
0034f4 |
|
|
|
0034f4 |
- uid = getuid();
|
|
|
0034f4 |
- if (uid != 0) {
|
|
|
0034f4 |
- ERROR("%1$s must be run as root\n", argv[0]);
|
|
|
0034f4 |
- return EXIT_FAILURE;
|
|
|
0034f4 |
- }
|
|
|
0034f4 |
-
|
|
|
0034f4 |
ret = sss_tool_init(NULL, &argc, argv, &tool_ctx);
|
|
|
0034f4 |
if (ret != EOK) {
|
|
|
0034f4 |
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create tool context\n");
|
|
|
0034f4 |
diff --git a/src/tools/common/sss_tools.h b/src/tools/common/sss_tools.h
|
|
|
0034f4 |
index 75dc15391..24dd4b559 100644
|
|
|
0034f4 |
--- a/src/tools/common/sss_tools.h
|
|
|
0034f4 |
+++ b/src/tools/common/sss_tools.h
|
|
|
0034f4 |
@@ -54,7 +54,8 @@ typedef errno_t
|
|
|
0034f4 |
#define SSS_TOOL_DELIMITER(message) {"", _(message), 0, NULL, 0}
|
|
|
0034f4 |
#define SSS_TOOL_LAST {NULL, NULL, 0, NULL, 0}
|
|
|
0034f4 |
|
|
|
0034f4 |
-#define SSS_TOOL_FLAG_SKIP_CMD_INIT 0x01
|
|
|
0034f4 |
+#define SSS_TOOL_FLAG_SKIP_CMD_INIT 0x01
|
|
|
0034f4 |
+#define SSS_TOOL_FLAG_SKIP_ROOT_CHECK 0x02
|
|
|
0034f4 |
|
|
|
0034f4 |
struct sss_route_cmd {
|
|
|
0034f4 |
const char *command;
|
|
|
0034f4 |
diff --git a/src/tools/sssctl/sssctl.c b/src/tools/sssctl/sssctl.c
|
|
|
0034f4 |
index f18689f9f..b73d19ffe 100644
|
|
|
0034f4 |
--- a/src/tools/sssctl/sssctl.c
|
|
|
0034f4 |
+++ b/src/tools/sssctl/sssctl.c
|
|
|
0034f4 |
@@ -296,7 +296,7 @@ int main(int argc, const char **argv)
|
|
|
0034f4 |
SSS_TOOL_COMMAND("logs-remove", "Remove existing SSSD log files", 0, sssctl_logs_remove),
|
|
|
0034f4 |
SSS_TOOL_COMMAND("logs-fetch", "Archive SSSD log files in tarball", 0, sssctl_logs_fetch),
|
|
|
0034f4 |
SSS_TOOL_COMMAND("debug-level", "Change SSSD debug level", 0, sssctl_debug_level),
|
|
|
0034f4 |
- SSS_TOOL_COMMAND_FLAGS("analyze", "Analyze logged data", 0, sssctl_analyze, SSS_TOOL_FLAG_SKIP_CMD_INIT),
|
|
|
0034f4 |
+ SSS_TOOL_COMMAND_FLAGS("analyze", "Analyze logged data", 0, sssctl_analyze, SSS_TOOL_FLAG_SKIP_CMD_INIT|SSS_TOOL_FLAG_SKIP_ROOT_CHECK),
|
|
|
0034f4 |
#ifdef HAVE_LIBINI_CONFIG_V1_3
|
|
|
0034f4 |
SSS_TOOL_DELIMITER("Configuration files tools:"),
|
|
|
0034f4 |
SSS_TOOL_COMMAND_FLAGS("config-check", "Perform static analysis of SSSD configuration", 0, sssctl_config_check, SSS_TOOL_FLAG_SKIP_CMD_INIT),
|
|
|
0034f4 |
--
|
|
|
0034f4 |
2.37.3
|
|
|
0034f4 |
|