nss: only read logging config from environment variables
log_parse_environment() uses should_parse_proc_cmdline() to determine whether it should parse settings from the kernel command line. But the checks that should_parse_proc_cmdline() apply to the whole process, and we could get a positive answer also when log_parse_environment() was called from one of the nss modules. In case of nss-modules, we don't want to look at the kernel command line. log_parse_environment_variables() that only looks at the environment variables is split out and used in the nss modules. Fixes #22020.
This commit is contained in:
+10
-6
@@ -1189,14 +1189,9 @@ static bool should_parse_proc_cmdline(void) {
|
||||
return getpid_cached() == p;
|
||||
}
|
||||
|
||||
void log_parse_environment(void) {
|
||||
void log_parse_environment_variables(void) {
|
||||
const char *e;
|
||||
|
||||
/* Do not call from library code. */
|
||||
|
||||
if (should_parse_proc_cmdline())
|
||||
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
|
||||
|
||||
e = getenv("SYSTEMD_LOG_TARGET");
|
||||
if (e && log_set_target_from_string(e) < 0)
|
||||
log_warning("Failed to parse log target '%s'. Ignoring.", e);
|
||||
@@ -1222,6 +1217,15 @@ void log_parse_environment(void) {
|
||||
log_warning("Failed to parse log tid '%s'. Ignoring.", e);
|
||||
}
|
||||
|
||||
void log_parse_environment(void) {
|
||||
/* Do not call from library code. */
|
||||
|
||||
if (should_parse_proc_cmdline())
|
||||
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
|
||||
|
||||
log_parse_environment_variables();
|
||||
}
|
||||
|
||||
LogTarget log_get_target(void) {
|
||||
return log_target;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ int log_open(void);
|
||||
void log_close(void);
|
||||
void log_forget_fds(void);
|
||||
|
||||
void log_parse_environment_variables(void);
|
||||
void log_parse_environment(void);
|
||||
|
||||
int log_dispatch_internal(
|
||||
|
||||
Reference in New Issue
Block a user