Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHILD: Pass information about logger to children #441

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -1491,7 +1491,7 @@ EXTRA_DIST += \
src/responder/ifp/org.freedesktop.sssd.infopipe.service.in \
$(NULL)

ifp_edit_cmd = $(SED) \
ifp_edit_cmd = $(edit_cmd) \
-e 's|@ifp_exec_cmd[@]|$(ifp_exec_cmd)|g' \
-e 's|@ifp_systemdservice[@]|$(ifp_systemdservice)|g' \
-e 's|@ifp_restart[@]|$(ifp_restart)|g'
Expand Down
4 changes: 3 additions & 1 deletion src/p11_child/p11_child_nss.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion src/providers/ad/ad_gpo_child.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/providers/ipa/selinux_child.c
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/providers/krb5/krb5_child.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/providers/ldap/ldap_child.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/sysv/systemd/sssd.service.in
Expand Up @@ -10,6 +10,7 @@ EnvironmentFile=-@environment_file@
ExecStart=@sbindir@/sssd -i ${DEBUG_LOGGER}
Type=notify
NotifyAccess=main
PIDFile=@localstatedir@/run/sssd.pid

[Install]
WantedBy=multi-user.target
20 changes: 8 additions & 12 deletions src/util/child_common.c
Expand Up @@ -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) {
Expand Down Expand Up @@ -675,17 +672,16 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
goto fail;
}

if (child_debug_stderr) {
argv[--argc] = talloc_strdup(argv, "--logger=stderr");
if (sss_logger == FILES_LOGGER) {
argv[--argc] = talloc_asprintf(argv, "--debug-fd=%d",
child_debug_fd);
if (argv[argc] == NULL) {
ret = ENOMEM;
goto fail;
}
}

if (child_debug_to_file) {
argv[--argc] = talloc_asprintf(argv, "--debug-fd=%d",
child_debug_fd);
} else {
argv[--argc] = talloc_asprintf(argv, "--logger=%s",
sss_logger_str[sss_logger]);
if (argv[argc] == NULL) {
ret = ENOMEM;
goto fail;
Expand Down Expand Up @@ -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",
Expand Down