chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shared: in code that might get called from suid programs use __secure_getenv() rather...
[elogind.git]
/
src
/
shared
/
log.c
diff --git
a/src/shared/log.c
b/src/shared/log.c
index 21512006449d774c0b3d9e833ddaadbbd9d49504..4fc430eed11a1f783e9defeb89cf7317483def06 100644
(file)
--- a/
src/shared/log.c
+++ b/
src/shared/log.c
@@
-240,7
+240,7
@@
int log_open(void) {
return 0;
}
return 0;
}
- if (
log_target != LOG_TARGET_AUTO
||
+ if (
(log_target != LOG_TARGET_AUTO && log_target != LOG_TARGET_SAFE)
||
getpid() == 1 ||
isatty(STDERR_FILENO) <= 0) {
getpid() == 1 ||
isatty(STDERR_FILENO) <= 0) {
@@
-266,6
+266,7
@@
int log_open(void) {
}
if (log_target == LOG_TARGET_AUTO ||
}
if (log_target == LOG_TARGET_AUTO ||
+ log_target == LOG_TARGET_SAFE ||
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_KMSG) {
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_KMSG) {
@@
-466,12
+467,14
@@
static int write_to_journal(
"CODE_FILE=%s\n"
"CODE_LINE=%i\n"
"CODE_FUNCTION=%s\n"
"CODE_FILE=%s\n"
"CODE_LINE=%i\n"
"CODE_FUNCTION=%s\n"
+ "SYSLOG_IDENTIFIER=%s\n"
"MESSAGE=",
LOG_PRI(level),
LOG_FAC(level),
file,
line,
"MESSAGE=",
LOG_PRI(level),
LOG_FAC(level),
file,
line,
- func);
+ func,
+ program_invocation_short_name);
char_array_0(header);
char_array_0(header);
@@
-545,7
+548,9
@@
static int log_dispatch(
if (k <= 0 &&
(log_target == LOG_TARGET_AUTO ||
if (k <= 0 &&
(log_target == LOG_TARGET_AUTO ||
+ log_target == LOG_TARGET_SAFE ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
+ log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_KMSG)) {
k = write_to_kmsg(level, file, line, func, buffer);
log_target == LOG_TARGET_KMSG)) {
k = write_to_kmsg(level, file, line, func, buffer);
@@
-653,6
+658,11
@@
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file
log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
}
log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
}
+int __log_oom(const char *file, int line, const char *func) {
+ log_meta(LOG_ERR, file, line, func, "Out of memory.");
+ return -ENOMEM;
+}
+
int log_set_target_from_string(const char *e) {
LogTarget t;
int log_set_target_from_string(const char *e) {
LogTarget t;
@@
-678,21
+688,21
@@
int log_set_max_level_from_string(const char *e) {
void log_parse_environment(void) {
const char *e;
void log_parse_environment(void) {
const char *e;
- if ((e = getenv("SYSTEMD_LOG_TARGET")))
-
if (
log_set_target_from_string(e) < 0)
-
log_warning("Failed to parse log target %s. Ignoring.", e);
+ e = __secure_getenv("SYSTEMD_LOG_TARGET");
+
if (e &&
log_set_target_from_string(e) < 0)
+ log_warning("Failed to parse log target %s. Ignoring.", e);
- if ((e = getenv("SYSTEMD_LOG_LEVEL")))
-
if (
log_set_max_level_from_string(e) < 0)
-
log_warning("Failed to parse log level %s. Ignoring.", e);
+ e = __secure_getenv("SYSTEMD_LOG_LEVEL");
+
if (e &&
log_set_max_level_from_string(e) < 0)
+ log_warning("Failed to parse log level %s. Ignoring.", e);
- if ((e = getenv("SYSTEMD_LOG_COLOR")))
-
if (
log_show_color_from_string(e) < 0)
-
log_warning("Failed to parse bool %s. Ignoring.", e);
+ e = __secure_getenv("SYSTEMD_LOG_COLOR");
+
if (e &&
log_show_color_from_string(e) < 0)
+ log_warning("Failed to parse bool %s. Ignoring.", e);
- if ((e = getenv("SYSTEMD_LOG_LOCATION")))
-
if (
log_show_location_from_string(e) < 0)
-
log_warning("Failed to parse bool %s. Ignoring.", e);
+ e = __secure_getenv("SYSTEMD_LOG_LOCATION");
+
if (e &&
log_show_location_from_string(e) < 0)
+ log_warning("Failed to parse bool %s. Ignoring.", e);
}
LogTarget log_get_target(void) {
}
LogTarget log_get_target(void) {
@@
-741,6
+751,7
@@
static const char *const log_target_table[] = {
[LOG_TARGET_SYSLOG] = "syslog",
[LOG_TARGET_SYSLOG_OR_KMSG] = "syslog-or-kmsg",
[LOG_TARGET_AUTO] = "auto",
[LOG_TARGET_SYSLOG] = "syslog",
[LOG_TARGET_SYSLOG_OR_KMSG] = "syslog-or-kmsg",
[LOG_TARGET_AUTO] = "auto",
+ [LOG_TARGET_SAFE] = "safe",
[LOG_TARGET_NULL] = "null"
};
[LOG_TARGET_NULL] = "null"
};