1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

Merge pull request #22086 from keszybz/nss-no-proc-cmdline

Avoid looking at /prcc/cmdline from nss modules
This commit is contained in:
Luca Boccassi 2022-01-11 15:29:24 +00:00 committed by GitHub
commit 1d18a466c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 19 deletions

View File

@ -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;
}

View File

@ -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(

View File

@ -22,14 +22,9 @@
#include "signal-util.h"
#include "string-util.h"
static void setup_logging(void) {
/* We need a dummy function because log_parse_environment is a macro. */
log_parse_environment();
}
static void setup_logging_once(void) {
static pthread_once_t once = PTHREAD_ONCE_INIT;
assert_se(pthread_once(&once, setup_logging) == 0);
assert_se(pthread_once(&once, log_parse_environment_variables) == 0);
}
#define NSS_ENTRYPOINT_BEGIN \

View File

@ -22,7 +22,7 @@
static JsonDispatchFlags json_dispatch_flags = 0;
static void setup_logging(void) {
log_parse_environment();
log_parse_environment_variables();
if (DEBUG_LOGGING)
json_dispatch_flags = JSON_LOG;

View File

@ -116,14 +116,9 @@ static GetentData getsgent_data = {
.mutex = PTHREAD_MUTEX_INITIALIZER,
};
static void setup_logging(void) {
/* We need a dummy function because log_parse_environment is a macro. */
log_parse_environment();
}
static void setup_logging_once(void) {
static pthread_once_t once = PTHREAD_ONCE_INIT;
assert_se(pthread_once(&once, setup_logging) == 0);
assert_se(pthread_once(&once, log_parse_environment_variables) == 0);
}
#define NSS_ENTRYPOINT_BEGIN \