sssd/0038-CHILD-Pass-information-about-logger-to-children.patch

198 lines
6.9 KiB
Diff
Raw Normal View History

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