dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0034-CHILD-Pass-information-about-logger-to-children.patch

9f2ebf
From 3ada67750d3d0dc6188c03cc996b98e7578971a4 Mon Sep 17 00:00:00 2001
9f2ebf
From: Lukas Slebodnik <lslebodn@redhat.com>
9f2ebf
Date: Wed, 8 Nov 2017 08:13:02 +0100
9f2ebf
Subject: [PATCH 34/35] CHILD: Pass information about logger to children
9f2ebf
MIME-Version: 1.0
9f2ebf
Content-Type: text/plain; charset=UTF-8
9f2ebf
Content-Transfer-Encoding: 8bit
9f2ebf
9f2ebf
Variables debug_to_file or debug_to_stderr were not set
9f2ebf
because back-end already user parameter --logger=%s.
9f2ebf
And therefore logs were not sent to files.
9f2ebf
9f2ebf
It could only work in case of direct usage of --debug-to-files in back-end via
9f2ebf
command configuration option.
9f2ebf
9f2ebf
Resolves:
9f2ebf
https://pagure.io/SSSD/sssd/issue/3433
9f2ebf
9f2ebf
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
9f2ebf
(cherry picked from commit a24954cc19285b197fb287bfa7aa01949c92b17d)
9f2ebf
---
9f2ebf
 src/p11_child/p11_child_nss.c     |  4 +++-
9f2ebf
 src/providers/ad/ad_gpo_child.c   |  3 ++-
9f2ebf
 src/providers/ipa/selinux_child.c |  3 ++-
9f2ebf
 src/providers/krb5/krb5_child.c   |  3 ++-
9f2ebf
 src/providers/ldap/ldap_child.c   |  3 ++-
9f2ebf
 src/util/child_common.c           | 24 ++++++++++--------------
9f2ebf
 6 files changed, 21 insertions(+), 19 deletions(-)
9f2ebf
9f2ebf
diff --git a/src/p11_child/p11_child_nss.c b/src/p11_child/p11_child_nss.c
9f2ebf
index e7dbcb689220d1cd2585fbde5f26e84f8fa15cc2..b0ec69be321c4b4186ce851c07bfcc3e1afe9694 100644
9f2ebf
--- a/src/p11_child/p11_child_nss.c
9f2ebf
+++ b/src/p11_child/p11_child_nss.c
9f2ebf
@@ -537,7 +537,7 @@ int main(int argc, const char *argv[])
9f2ebf
     int opt;
9f2ebf
     poptContext pc;
9f2ebf
     int debug_fd = -1;
9f2ebf
-    char *opt_logger = NULL;
9f2ebf
+    const char *opt_logger = NULL;
9f2ebf
     errno_t ret;
9f2ebf
     TALLOC_CTX *main_ctx = NULL;
9f2ebf
     char *cert;
9f2ebf
@@ -673,7 +673,9 @@ int main(int argc, const char *argv[])
9f2ebf
         if (ret != EOK) {
9f2ebf
             DEBUG(SSSDBG_CRIT_FAILURE, "set_debug_file_from_fd failed.\n");
9f2ebf
         }
9f2ebf
+        opt_logger = sss_logger_str[FILES_LOGGER];
9f2ebf
     }
9f2ebf
+
9f2ebf
     sss_set_logger(opt_logger);
9f2ebf
 
9f2ebf
     DEBUG(SSSDBG_TRACE_FUNC, "p11_child started.\n");
9f2ebf
diff --git a/src/providers/ad/ad_gpo_child.c b/src/providers/ad/ad_gpo_child.c
9f2ebf
index 5375cc691e8649c289672b74c4bfe5266c8222c9..a0bd6e13a31fe0f92924d49302d1b8b17bac4d67 100644
9f2ebf
--- a/src/providers/ad/ad_gpo_child.c
9f2ebf
+++ b/src/providers/ad/ad_gpo_child.c
9f2ebf
@@ -687,7 +687,7 @@ main(int argc, const char *argv[])
9f2ebf
     int opt;
9f2ebf
     poptContext pc;
9f2ebf
     int debug_fd = -1;
9f2ebf
-    char *opt_logger = NULL;
9f2ebf
+    const char *opt_logger = NULL;
9f2ebf
     errno_t ret;
9f2ebf
     int sysvol_gpt_version;
9f2ebf
     int result;
9f2ebf
@@ -744,6 +744,7 @@ main(int argc, const char *argv[])
9f2ebf
         if (ret != EOK) {
9f2ebf
             DEBUG(SSSDBG_CRIT_FAILURE, "set_debug_file_from_fd failed.\n");
9f2ebf
         }
9f2ebf
+        opt_logger = sss_logger_str[FILES_LOGGER];
9f2ebf
     }
9f2ebf
 
9f2ebf
     sss_set_logger(opt_logger);
9f2ebf
diff --git a/src/providers/ipa/selinux_child.c b/src/providers/ipa/selinux_child.c
9f2ebf
index 120492686963241b7e419413f489cc38953e32f2..a7e20f715626d0f3ecef7cc06f3de5d44b6a15c1 100644
9f2ebf
--- a/src/providers/ipa/selinux_child.c
9f2ebf
+++ b/src/providers/ipa/selinux_child.c
9f2ebf
@@ -206,7 +206,7 @@ int main(int argc, const char *argv[])
9f2ebf
     struct response *resp = NULL;
9f2ebf
     ssize_t written;
9f2ebf
     bool needs_update;
9f2ebf
-    char *opt_logger = NULL;
9f2ebf
+    const char *opt_logger = NULL;
9f2ebf
 
9f2ebf
     struct poptOption long_options[] = {
9f2ebf
         POPT_AUTOHELP
9f2ebf
@@ -254,6 +254,7 @@ int main(int argc, const char *argv[])
9f2ebf
         if (ret != EOK) {
9f2ebf
             DEBUG(SSSDBG_CRIT_FAILURE, "set_debug_file_from_fd failed.\n");
9f2ebf
         }
9f2ebf
+        opt_logger = sss_logger_str[FILES_LOGGER];
9f2ebf
     }
9f2ebf
 
9f2ebf
     sss_set_logger(opt_logger);
9f2ebf
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
9f2ebf
index 700338e47a3f9ac6fcf11b4c92364dbdb4f9bcf7..7b56002377ac22472c3eea1aef687109757c22db 100644
9f2ebf
--- a/src/providers/krb5/krb5_child.c
9f2ebf
+++ b/src/providers/krb5/krb5_child.c
9f2ebf
@@ -3020,7 +3020,7 @@ int main(int argc, const char *argv[])
9f2ebf
     int opt;
9f2ebf
     poptContext pc;
9f2ebf
     int debug_fd = -1;
9f2ebf
-    char *opt_logger = NULL;
9f2ebf
+    const char *opt_logger = NULL;
9f2ebf
     errno_t ret;
9f2ebf
     krb5_error_code kerr;
9f2ebf
     uid_t fast_uid;
9f2ebf
@@ -3097,6 +3097,7 @@ int main(int argc, const char *argv[])
9f2ebf
         if (ret != EOK) {
9f2ebf
             DEBUG(SSSDBG_CRIT_FAILURE, "set_debug_file_from_fd failed.\n");
9f2ebf
         }
9f2ebf
+        opt_logger = sss_logger_str[FILES_LOGGER];
9f2ebf
     }
9f2ebf
 
9f2ebf
     sss_set_logger(opt_logger);
9f2ebf
diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c
9f2ebf
index baeed239db5dc7ffa482edcbc155f25f718c8249..c0618d6d8828f102c32cf56731995e2b370590e7 100644
9f2ebf
--- a/src/providers/ldap/ldap_child.c
9f2ebf
+++ b/src/providers/ldap/ldap_child.c
9f2ebf
@@ -599,7 +599,7 @@ int main(int argc, const char *argv[])
9f2ebf
     int kerr;
9f2ebf
     int opt;
9f2ebf
     int debug_fd = -1;
9f2ebf
-    char *opt_logger = NULL;
9f2ebf
+    const char *opt_logger = NULL;
9f2ebf
     poptContext pc;
9f2ebf
     TALLOC_CTX *main_ctx = NULL;
9f2ebf
     uint8_t *buf = NULL;
9f2ebf
@@ -657,6 +657,7 @@ int main(int argc, const char *argv[])
9f2ebf
         if (ret != EOK) {
9f2ebf
             DEBUG(SSSDBG_CRIT_FAILURE, "set_debug_file_from_fd failed.\n");
9f2ebf
         }
9f2ebf
+        opt_logger = sss_logger_str[FILES_LOGGER];
9f2ebf
     }
9f2ebf
 
9f2ebf
     sss_set_logger(opt_logger);
9f2ebf
diff --git a/src/util/child_common.c b/src/util/child_common.c
9f2ebf
index dc070f26446305e07cbb34edd1e4d72db72aedc5..203c115f9e7c4ecc2178b5660473d4f960fbbb6d 100644
9f2ebf
--- a/src/util/child_common.c
9f2ebf
+++ b/src/util/child_common.c
9f2ebf
@@ -630,14 +630,11 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
9f2ebf
     }
9f2ebf
 
9f2ebf
     /* Save the current state in case an interrupt changes it */
9f2ebf
-    bool child_debug_to_file = debug_to_file;
9f2ebf
     bool child_debug_timestamps = debug_timestamps;
9f2ebf
     bool child_debug_microseconds = debug_microseconds;
9f2ebf
-    bool child_debug_stderr = debug_to_stderr;
9f2ebf
 
9f2ebf
     if (!extra_args_only) {
9f2ebf
-        if (child_debug_to_file) argc++;
9f2ebf
-        if (child_debug_stderr) argc++;
9f2ebf
+        argc++;
9f2ebf
     }
9f2ebf
 
9f2ebf
     if (extra_argv) {
9f2ebf
@@ -675,21 +672,20 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
9f2ebf
             goto fail;
9f2ebf
         }
9f2ebf
 
9f2ebf
-        if (child_debug_stderr) {
9f2ebf
-            argv[--argc] = talloc_strdup(argv, "--logger=stderr");
9f2ebf
-            if (argv[argc] == NULL) {
9f2ebf
-                ret = ENOMEM;
9f2ebf
-                goto fail;
9f2ebf
-            }
9f2ebf
-        }
9f2ebf
-
9f2ebf
-        if (child_debug_to_file) {
9f2ebf
+        if (sss_logger == FILES_LOGGER) {
9f2ebf
             argv[--argc] = talloc_asprintf(argv, "--debug-fd=%d",
9f2ebf
                                            child_debug_fd);
9f2ebf
             if (argv[argc] == NULL) {
9f2ebf
                 ret = ENOMEM;
9f2ebf
                 goto fail;
9f2ebf
             }
9f2ebf
+        } else {
9f2ebf
+            argv[--argc] = talloc_asprintf(argv, "--logger=%s",
9f2ebf
+                                           sss_logger_str[sss_logger]);
9f2ebf
+            if (argv[argc] == NULL) {
9f2ebf
+                ret = ENOMEM;
9f2ebf
+                goto fail;
9f2ebf
+            }
9f2ebf
         }
9f2ebf
 
9f2ebf
         argv[--argc] = talloc_asprintf(argv, "--debug-timestamps=%d",
9f2ebf
@@ -816,7 +812,7 @@ errno_t child_debug_init(const char *logfile, int *debug_fd)
9f2ebf
         return EOK;
9f2ebf
     }
9f2ebf
 
9f2ebf
-    if (debug_to_file != 0 && *debug_fd == -1) {
9f2ebf
+    if (sss_logger == FILES_LOGGER && *debug_fd == -1) {
9f2ebf
         ret = open_debug_file_ex(logfile, &debug_filep, false);
9f2ebf
         if (ret != EOK) {
9f2ebf
             DEBUG(SSSDBG_FATAL_FAILURE, "Error setting up logging (%d) [%s]\n",
9f2ebf
-- 
9f2ebf
2.13.6
9f2ebf