dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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