dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0038-sssctl-sssctl-config-check-alternative-snippet-dir.patch

1bb595
From 72b8e02c77f0b0b7e36663fa3bd3fd6987ea1b80 Mon Sep 17 00:00:00 2001
1bb595
From: Tomas Halman <thalman@redhat.com>
1bb595
Date: Mon, 13 Jul 2020 18:11:40 +0200
1bb595
Subject: [PATCH] sssctl: sssctl config-check alternative snippet dir
1bb595
1bb595
The sssctl config-check now allows to specify not only alternative
1bb595
config file but also snippet dir.
1bb595
1bb595
    sssctl config-check -c ./sssd.conf -s /etc/sssd/conf.d
1bb595
1bb595
Configuration snippets are still looked up in the same place under
1bb595
conf.d directory by default. It would be in ./conf.d/ for the example
1bb595
above.
1bb595
1bb595
Resolves:
1bb595
https://github.com/SSSD/sssd/issues/5142
1bb595
1bb595
Reviewed-by: Pawel Polawski <ppolawsk@redhat.com>
1bb595
---
1bb595
 src/tools/sssctl/sssctl_config.c | 14 ++++++++++----
1bb595
 1 file changed, 10 insertions(+), 4 deletions(-)
1bb595
1bb595
diff --git a/src/tools/sssctl/sssctl_config.c b/src/tools/sssctl/sssctl_config.c
1bb595
index de9f3de6e..db4aeeae4 100644
1bb595
--- a/src/tools/sssctl/sssctl_config.c
1bb595
+++ b/src/tools/sssctl/sssctl_config.c
1bb595
@@ -75,6 +75,11 @@ errno_t sssctl_config_check(struct sss_cmdline *cmdline,
1bb595
     struct poptOption long_options[] = {
1bb595
         {"config", 'c', POPT_ARG_STRING, &config_path,
1bb595
             0, _("Specify a non-default config file"), NULL},
1bb595
+        {"snippet", 's', POPT_ARG_STRING, &config_snippet_path,
1bb595
+            0, _("Specify a non-default snippet dir (The default is to look in "
1bb595
+                 "the same place where the main config file is located. For "
1bb595
+                 "example if the config is set to \"/my/path/sssd.conf\", "
1bb595
+                 "the snippet dir \"/my/path/conf.d\" is used)"), NULL},
1bb595
         POPT_TABLEEND
1bb595
     };
1bb595
 
1bb595
@@ -92,16 +97,17 @@ errno_t sssctl_config_check(struct sss_cmdline *cmdline,
1bb595
         goto done;
1bb595
     }
1bb595
 
1bb595
-    if (config_path != NULL) {
1bb595
+    if (config_path == NULL) {
1bb595
+        config_path = SSSD_CONFIG_FILE;
1bb595
+    }
1bb595
+
1bb595
+    if (config_snippet_path == NULL) {
1bb595
         config_snippet_path = sssctl_config_snippet_path(tmp_ctx, config_path);
1bb595
         if (config_snippet_path == NULL) {
1bb595
             DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create snippet path\n");
1bb595
             ret = ENOMEM;
1bb595
             goto done;
1bb595
         }
1bb595
-    } else {
1bb595
-        config_path = SSSD_CONFIG_FILE;
1bb595
-        config_snippet_path = CONFDB_DEFAULT_CONFIG_DIR;
1bb595
     }
1bb595
 
1bb595
     ret = sss_ini_read_sssd_conf(init_data,
1bb595
-- 
1bb595
2.21.3
1bb595