X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Flog.c;h=3924ed71f10680261e680f5ba9a39f47a7051444;hb=d93247127eb2e073a6d3b5bcc67bcc4048d674fe;hp=df1a775f11652969c1439d149ae941e6248071f5;hpb=7a65c7a2257c398113531ee614cda06ea007146c;p=elogind.git diff --git a/src/basic/log.c b/src/basic/log.c index df1a775f1..3924ed71f 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -238,6 +238,8 @@ fail: int log_open(void) { int r; + /* Do not call from library code. */ + /* If we don't use the console we close it here, to not get * killed by SAK. If we don't use syslog we close it here so * that we are not confused by somebody deleting the socket in @@ -316,6 +318,8 @@ void log_set_target(LogTarget target) { } void log_close(void) { + /* Do not call from library code. */ + log_close_journal(); log_close_syslog(); log_close_kmsg(); @@ -324,6 +328,8 @@ void log_close(void) { #if 0 /// UNNEEDED by elogind void log_forget_fds(void) { + /* Do not call from library code. */ + console_fd = kmsg_fd = syslog_fd = journal_fd = -1; } #endif // 0 @@ -736,7 +742,6 @@ int log_object_internalv( PROTECT_ERRNO; char *buffer, *b; - size_t l; if (error < 0) error = -error; @@ -753,16 +758,12 @@ int log_object_internalv( size_t n; n = strlen(object); - l = n + 2 + LINE_MAX; - - buffer = newa(char, l); + buffer = newa(char, n + 2 + LINE_MAX); b = stpcpy(stpcpy(buffer, object), ": "); - } else { - l = LINE_MAX; - b = buffer = newa(char, l); - } + } else + b = buffer = newa(char, LINE_MAX); - vsnprintf(b, l, format, ap); + vsnprintf(b, LINE_MAX, format, ap); return log_dispatch_internal(level, error, file, line, func, object_field, object, extra_field, extra, buffer); @@ -1057,6 +1058,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat } void log_parse_environment_realm(LogRealm realm) { + /* Do not call from library code. */ + const char *e; if (get_ctty_devnr(0, NULL) < 0) @@ -1064,19 +1067,19 @@ void log_parse_environment_realm(LogRealm realm) { user stuff. */ (void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX); - e = secure_getenv("SYSTEMD_LOG_TARGET"); + e = getenv("SYSTEMD_LOG_TARGET"); if (e && log_set_target_from_string(e) < 0) log_warning("Failed to parse log target '%s'. Ignoring.", e); - e = secure_getenv("SYSTEMD_LOG_LEVEL"); + e = getenv("SYSTEMD_LOG_LEVEL"); if (e && log_set_max_level_from_string_realm(realm, e) < 0) log_warning("Failed to parse log level '%s'. Ignoring.", e); - e = secure_getenv("SYSTEMD_LOG_COLOR"); + e = getenv("SYSTEMD_LOG_COLOR"); if (e && log_show_color_from_string(e) < 0) log_warning("Failed to parse bool '%s'. Ignoring.", e); - e = secure_getenv("SYSTEMD_LOG_LOCATION"); + e = getenv("SYSTEMD_LOG_LOCATION"); if (e && log_show_location_from_string(e) < 0) log_warning("Failed to parse bool '%s'. Ignoring.", e); }