[systemd-commits] 12 commits - TODO src/core src/journal src/libsystemd src/login src/machine src/network src/shared src/sleep src/timedate
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Nov 27 18:30:04 PST 2014
TODO | 9 +-
src/core/execute.c | 54 +++++++-------
src/core/job.c | 54 +++++++-------
src/core/manager.c | 35 ++++-----
src/core/mount.c | 20 ++---
src/core/service.c | 20 ++---
src/core/unit.c | 8 +-
src/core/unit.h | 2
src/journal/journald-server.c | 2
src/libsystemd/sd-bus/bus-kernel.c | 21 +++--
src/login/logind-button.c | 28 +++----
src/login/logind-dbus.c | 6 +
src/login/logind-seat.c | 8 +-
src/login/logind-session.c | 8 +-
src/machine/machine.c | 8 +-
src/network/networkd-dhcp4.c | 4 -
src/network/networkd-link.c | 60 +++------------
src/network/networkd-link.h | 24 ++++--
src/network/networkd.h | 17 ----
src/shared/conf-parser.c | 8 +-
src/shared/log.c | 140 ++++++++++++++++++++-----------------
src/shared/log.h | 17 ++--
src/sleep/sleep.c | 26 +++---
src/timedate/timedated.c | 8 +-
24 files changed, 288 insertions(+), 299 deletions(-)
New commits:
commit e8bbb7c7e9163420cb1ba92f82dbc09aab577d1a
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 03:29:52 2014 +0100
update TODO
diff --git a/TODO b/TODO
index 5588baf..8f5e3a5 100644
--- a/TODO
+++ b/TODO
@@ -259,7 +259,10 @@ Features:
* sd-bus:
- bus-proxy: fix how we detect whether we are connected to a system bus
- kdbus: the kernel should not allow messages to be delivered that have a reply serial != 0, reply-expect unset, but no appropriate window
- - kdbus: busnames.target should get pulled in by basic.target
+ - kdbus: when we fake creds euid being (uint32_t) -1 is weirdly translated
+ - kdbus: timestamps on kernel's NameOwnerChanged messages?
+ - kdbus: busctl monitor message ordering is wildly out-of-order?
+ - kdbus' busnames.target should get pulled in by basic.target
- Ignore .busname units on classic D-Bus boots, systemd-resolved cannot be started on kdbus
without the active policy and should get a Wants=org.freedesktop.resolve1.busname to
pull-in the policy.
@@ -286,8 +289,6 @@ Features:
253 messages)
- kdbus: introduce a concept of "send-only" connections
- kdbus: add counter for refused unicast messages that is passed out via the RECV ioctl. SImilar to the counter for dropped multicast messages we already have.
- - kdbus: when we fake creds euid being (uint32_t) -1 is weirdly translated
- - kdbus: attach mask kmod parameter should be 64bit not 32bit
* sd-event
- allow multiple signal handlers per signal?
commit 1214b53c8e463ec328021e90163279ac94dd9af8
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 02:30:43 2014 +0100
kdbus: when running in a container, don't complain that we cannot write to /sys
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index a7d18e3..84fb4bd 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1810,10 +1810,8 @@ int bus_kernel_fix_attach_mask(void) {
* line option, however. */
r = get_proc_cmdline_key("systemd.kdbus_attach_flags_mask=", &mask);
- if (r < 0) {
- log_warning_errno(-r, "Failed to read kernel command line: %m");
- return r;
- }
+ if (r < 0)
+ return log_warning_errno(r, "Failed to read kernel command line: %m");
if (mask) {
const char *p = mask;
@@ -1827,10 +1825,10 @@ int bus_kernel_fix_attach_mask(void) {
sprintf(buf, "0x%" PRIx64 "\n", m);
r = write_string_file("/sys/module/kdbus/parameters/attach_flags_mask", buf);
- if (r < 0) {
- log_warning_errno(-r, "Failed to write kdbus attach mask: %m");
- return r;
- }
+ if (r < 0)
+ return log_full_errno(
+ r == -EROFS ? LOG_DEBUG : LOG_WARNING, r,
+ "Failed to write kdbus attach mask: %m");
return 0;
}
commit bf371116f69261c17e47dc3dbb51cfaa3c9369ff
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 03:10:55 2014 +0100
log: change log_xyz_errno() calls to always return the negative error
This enables us to write things like this:
int open_some_file(void) {
fd = open("/dev/foobar", O_RDWR|O_CLOEXEC);
if (fd < 0)
return log_error_errno(errno, "Failed to reboot: %m");
return fd;
}
Which is function that returns -errno on failure, as well as printing an
error message, all in one line.
diff --git a/src/shared/log.c b/src/shared/log.c
index e0dc026..af1a932 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -540,10 +540,10 @@ static int log_dispatch(
const char *object,
char *buffer) {
- int r = 0;
+ assert(buffer);
if (log_target == LOG_TARGET_NULL)
- return 0;
+ return -error;
/* Patch in LOG_DAEMON facility if necessary */
if ((level & LOG_FACMASK) == 0)
@@ -573,8 +573,7 @@ static int log_dispatch(
if (k != -EAGAIN)
log_close_journal();
log_open_kmsg();
- } else if (k > 0)
- r++;
+ }
}
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
@@ -585,8 +584,7 @@ static int log_dispatch(
if (k != -EAGAIN)
log_close_syslog();
log_open_kmsg();
- } else if (k > 0)
- r++;
+ }
}
if (k <= 0 &&
@@ -600,26 +598,22 @@ static int log_dispatch(
if (k < 0) {
log_close_kmsg();
log_open_console();
- } else if (k > 0)
- r++;
+ }
}
- if (k <= 0) {
- k = write_to_console(level, error, file, line, func, object_field, object, buffer);
- if (k < 0)
- return k;
- }
+ if (k <= 0)
+ (void) write_to_console(level, error, file, line, func, object_field, object, buffer);
buffer = e;
} while (buffer);
- return r;
+ return -error;
}
int log_dump_internal(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
char *buffer) {
@@ -628,8 +622,11 @@ int log_dump_internal(
/* This modifies the buffer... */
+ if (error < 0)
+ error = -error;
+
if (_likely_(LOG_PRI(level) > log_max_level))
- return 0;
+ return -error;
return log_dispatch(level, error, file, line, func, NULL, NULL, buffer);
}
@@ -646,12 +643,15 @@ int log_internalv(
PROTECT_ERRNO;
char buffer[LINE_MAX];
+ if (error < 0)
+ error = -error;
+
if (_likely_(LOG_PRI(level) > log_max_level))
- return 0;
+ return -error;
/* Make sure that %m maps to the specified error */
if (error != 0)
- errno = abs(error);
+ errno = error;
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
@@ -667,8 +667,8 @@ int log_internal(
const char *func,
const char *format, ...) {
- int r;
va_list ap;
+ int r;
va_start(ap, format);
r = log_internalv(level, error, file, line, func, format, ap);
@@ -691,12 +691,15 @@ int log_object_internalv(
PROTECT_ERRNO;
char buffer[LINE_MAX];
+ if (error < 0)
+ error = -error;
+
if (_likely_(LOG_PRI(level) > log_max_level))
- return 0;
+ return -error;
/* Make sure that %m maps to the specified error */
if (error != 0)
- errno = abs(error);
+ errno = error;
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
@@ -714,8 +717,8 @@ int log_object_internal(
const char *object,
const char *format, ...) {
- int r;
va_list ap;
+ int r;
va_start(ap, format);
r = log_object_internalv(level, error, file, line, func, object_field, object, format, ap);
@@ -775,27 +778,27 @@ int log_struct_internal(
const char *func,
const char *format, ...) {
+ char buf[LINE_MAX];
+ bool found = false;
PROTECT_ERRNO;
va_list ap;
- int r;
+
+ if (error < 0)
+ error = -error;
if (_likely_(LOG_PRI(level) > log_max_level))
- return 0;
+ return -error;
if (log_target == LOG_TARGET_NULL)
- return 0;
+ return -error;
if ((level & LOG_FACMASK) == 0)
level = log_facility | LOG_PRI(level);
- if (error < 0)
- error = -error;
-
if ((log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_JOURNAL) &&
journal_fd >= 0) {
-
char header[LINE_MAX];
struct iovec iovec[17] = {};
unsigned n = 0, i;
@@ -803,6 +806,7 @@ int log_struct_internal(
.msg_iov = iovec,
};
static const char nl = '\n';
+ bool fallback = false;
/* If the journal is available do structured logging */
log_do_header(header, sizeof(header), level, error, file, line, func, NULL, NULL);
@@ -810,8 +814,8 @@ int log_struct_internal(
va_start(ap, format);
while (format && n + 1 < ELEMENTSOF(iovec)) {
- char *buf;
va_list aq;
+ char *m;
/* We need to copy the va_list structure,
* since vasprintf() leaves it afterwards at
@@ -821,9 +825,9 @@ int log_struct_internal(
errno = error;
va_copy(aq, ap);
- if (vasprintf(&buf, format, aq) < 0) {
+ if (vasprintf(&m, format, aq) < 0) {
va_end(aq);
- r = -ENOMEM;
+ fallback = true;
goto finish;
}
va_end(aq);
@@ -832,7 +836,7 @@ int log_struct_internal(
* the next format string */
VA_FORMAT_ADVANCE(format, ap);
- IOVEC_SET_STRING(iovec[n++], buf);
+ IOVEC_SET_STRING(iovec[n++], m);
iovec[n].iov_base = (char*) &nl;
iovec[n].iov_len = 1;
@@ -843,52 +847,46 @@ int log_struct_internal(
mh.msg_iovlen = n;
- if (sendmsg(journal_fd, &mh, MSG_NOSIGNAL) < 0)
- r = -errno;
- else
- r = 1;
+ (void) sendmsg(journal_fd, &mh, MSG_NOSIGNAL);
finish:
va_end(ap);
for (i = 1; i < n; i += 2)
free(iovec[i].iov_base);
- } else {
- char buf[LINE_MAX];
- bool found = false;
-
- /* Fallback if journal logging is not available */
-
- va_start(ap, format);
- while (format) {
- va_list aq;
+ if (!fallback)
+ return -error;
+ }
- if (error != 0)
- errno = error;
+ /* Fallback if journal logging is not available or didn't work. */
- va_copy(aq, ap);
- vsnprintf(buf, sizeof(buf), format, aq);
- va_end(aq);
- char_array_0(buf);
+ va_start(ap, format);
+ while (format) {
+ va_list aq;
- if (startswith(buf, "MESSAGE=")) {
- found = true;
- break;
- }
+ if (error != 0)
+ errno = error;
- VA_FORMAT_ADVANCE(format, ap);
+ va_copy(aq, ap);
+ vsnprintf(buf, sizeof(buf), format, aq);
+ va_end(aq);
+ char_array_0(buf);
- format = va_arg(ap, char *);
+ if (startswith(buf, "MESSAGE=")) {
+ found = true;
+ break;
}
- va_end(ap);
- if (found)
- r = log_dispatch(level, error, file, line, func, NULL, NULL, buf + 8);
- else
- r = -EINVAL;
+ VA_FORMAT_ADVANCE(format, ap);
+
+ format = va_arg(ap, char *);
}
+ va_end(ap);
- return r;
+ if (!found)
+ return -error;
+
+ return log_dispatch(level, error, file, line, func, NULL, NULL, buf + 8);
}
int log_set_target_from_string(const char *e) {
diff --git a/src/shared/log.h b/src/shared/log.h
index 3180dfd..a6b9336 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -155,11 +155,13 @@ void log_assert_failed_return(
const char *func);
/* Logging with level */
-#define log_full_errno(level, error, ...) \
- do { \
- if (log_get_max_level() >= (level)) \
- log_internal((level), error, __FILE__, __LINE__, __func__, __VA_ARGS__); \
- } while (false)
+#define log_full_errno(level, error, ...) \
+ ({ \
+ int _l = (level), _e = (error); \
+ (log_get_max_level() >= _l) \
+ ? log_internal(_l, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \
+ : -abs(_e); \
+ })
#define log_full(level, ...) log_full_errno(level, 0, __VA_ARGS__)
commit 95066a906119998011d49d2602f063e74d97f680
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 02:56:39 2014 +0100
log: make socket address structs static const
diff --git a/src/shared/log.c b/src/shared/log.c
index eba5853..e0dc026 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -106,8 +106,8 @@ void log_close_syslog(void) {
}
static int create_log_socket(int type) {
- int fd;
struct timeval tv;
+ int fd;
fd = socket(AF_UNIX, type|SOCK_CLOEXEC, 0);
if (fd < 0)
@@ -128,12 +128,14 @@ static int create_log_socket(int type) {
}
static int log_open_syslog(void) {
- int r;
- union sockaddr_union sa = {
+
+ static const union sockaddr_union sa = {
.un.sun_family = AF_UNIX,
.un.sun_path = "/dev/log",
};
+ int r;
+
if (syslog_fd >= 0)
return 0;
@@ -176,10 +178,12 @@ void log_close_journal(void) {
}
static int log_open_journal(void) {
- union sockaddr_union sa = {
+
+ static const union sockaddr_union sa = {
.un.sun_family = AF_UNIX,
.un.sun_path = "/run/systemd/journal/socket",
};
+
int r;
if (journal_fd >= 0)
@@ -303,7 +307,7 @@ void log_set_facility(int facility) {
static int write_to_console(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
const char *object_field,
@@ -359,7 +363,7 @@ static int write_to_console(
static int write_to_syslog(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
const char *object_field,
@@ -529,7 +533,7 @@ static int write_to_journal(
static int log_dispatch(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
const char *object_field,
commit 6357ac664c9ce8ae5b83bdb98011da24185e4efa
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 02:30:49 2014 +0100
log: also set errno to the passed error code before processing format string in log_struct()
That way the caller may use %m to print the specified error.
diff --git a/src/shared/log.c b/src/shared/log.c
index 56469b3..eba5853 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -813,6 +813,9 @@ int log_struct_internal(
* since vasprintf() leaves it afterwards at
* an undefined location */
+ if (error != 0)
+ errno = error;
+
va_copy(aq, ap);
if (vasprintf(&buf, format, aq) < 0) {
va_end(aq);
@@ -856,6 +859,9 @@ int log_struct_internal(
while (format) {
va_list aq;
+ if (error != 0)
+ errno = error;
+
va_copy(aq, ap);
vsnprintf(buf, sizeof(buf), format, aq);
va_end(aq);
commit 387eba008426fbd8d7400eef8e41fda09f7f3cb3
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 02:26:05 2014 +0100
core: only override kdbus attach mask when running as PID 1
diff --git a/src/core/manager.c b/src/core/manager.c
index 63102d1..1646761 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -722,7 +722,8 @@ static int manager_setup_kdbus(Manager *m) {
if (m->test_run || m->kdbus_fd >= 0)
return 0;
- bus_kernel_fix_attach_mask();
+ if (getpid() == 1)
+ bus_kernel_fix_attach_mask();
m->kdbus_fd = bus_kernel_create_bus(
m->running_as == SYSTEMD_SYSTEM ? "system" : "user",
commit 412c18f10c9df3f0a02358d8c0e707ed2e5fa186
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 02:23:29 2014 +0100
sd-bus: the attach_mask kernel module parameter is 64bit now, hence initialize it as such
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 759d566..a7d18e3 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1800,10 +1800,15 @@ int bus_kernel_realize_attach_flags(sd_bus *bus) {
int bus_kernel_fix_attach_mask(void) {
_cleanup_free_ char *mask = NULL;
- uint64_t m = (uint32_t) -1;
+ uint64_t m = (uint64_t) -1;
char buf[2+16+2];
int r;
+ /* By default we don't want any kdbus metadata fields to be
+ * suppressed, hence we reset the kernel mask for it to
+ * (uint64_t) -1. This is overridable via a kernel command
+ * line option, however. */
+
r = get_proc_cmdline_key("systemd.kdbus_attach_flags_mask=", &mask);
if (r < 0) {
log_warning_errno(-r, "Failed to read kernel command line: %m");
commit 8f16f51d9323e87cc78d28e9656984c028071f94
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 02:12:30 2014 +0100
log: allow negative errno values
sd_bus_error_set_errno() allows negative errors too, hence, be equally
nice.
diff --git a/src/shared/log.c b/src/shared/log.c
index dcbcd9d..56469b3 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -545,6 +545,9 @@ static int log_dispatch(
if ((level & LOG_FACMASK) == 0)
level = log_facility | LOG_PRI(level);
+ if (error < 0)
+ error = -error;
+
do {
char *e;
int k = 0;
@@ -644,7 +647,7 @@ int log_internalv(
/* Make sure that %m maps to the specified error */
if (error != 0)
- errno = error;
+ errno = abs(error);
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
@@ -689,7 +692,7 @@ int log_object_internalv(
/* Make sure that %m maps to the specified error */
if (error != 0)
- errno = error;
+ errno = abs(error);
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
@@ -781,6 +784,9 @@ int log_struct_internal(
if ((level & LOG_FACMASK) == 0)
level = log_facility | LOG_PRI(level);
+ if (error < 0)
+ error = -error;
+
if ((log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_JOURNAL) &&
diff --git a/src/shared/log.h b/src/shared/log.h
index 3a4d113..3180dfd 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -202,7 +202,7 @@ LogTarget log_target_from_string(const char *s) _pure_;
/* Helpers to prepare various fields for structured logging */
#define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__
#define LOG_MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
-#define LOG_ERRNO(error) "ERRNO=%i", error
+#define LOG_ERRNO(error) "ERRNO=%i", abs(error)
void log_received_signal(int level, const struct signalfd_siginfo *si);
commit e2cc6eca73cd1df8be552d7c23f9ff3d69c06f1e
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 02:05:14 2014 +0100
log: fix order of log_unit_struct() to match other logging calls
Also, while we are at it, introduce some syntactic sugar for creating
ERRNO= and MESSAGE= structured logging fields.
diff --git a/src/core/execute.c b/src/core/execute.c
index dd182f5..a48c15d 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -426,12 +426,13 @@ static int setup_output(const ExecContext *context, int fileno, int socket_fd, c
case EXEC_OUTPUT_JOURNAL_AND_CONSOLE:
r = connect_logger_as(context, o, ident, unit_id, fileno);
if (r < 0) {
- log_unit_struct(LOG_CRIT, unit_id,
- "MESSAGE=Failed to connect std%s of %s to the journal socket: %s",
- fileno == STDOUT_FILENO ? "out" : "err",
- unit_id, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_unit_struct(unit_id,
+ LOG_CRIT,
+ LOG_MESSAGE("Failed to connect %s of %s to the journal socket: %s",
+ fileno == STDOUT_FILENO ? "stdout" : "stderr",
+ unit_id, strerror(-r)),
+ LOG_ERRNO(-r),
+ NULL);
r = open_null_as(O_WRONLY, fileno);
}
return r;
@@ -1751,10 +1752,10 @@ static int exec_child(ExecCommand *command,
line = exec_command_line(final_argv);
if (line) {
log_open();
- log_unit_struct(LOG_DEBUG,
- params->unit_id,
+ log_unit_struct(params->unit_id,
+ LOG_DEBUG,
"EXECUTABLE=%s", command->path,
- "MESSAGE=Executing: %s", line,
+ LOG_MESSAGE("Executing: %s", line),
NULL);
log_close();
}
@@ -1799,11 +1800,11 @@ int exec_spawn(ExecCommand *command,
err = exec_context_load_environment(context, params->unit_id, &files_env);
if (err < 0) {
- log_unit_struct(LOG_ERR,
- params->unit_id,
- "MESSAGE=Failed to load environment files: %s", strerror(-err),
- "ERRNO=%d", -err,
- NULL);
+ log_unit_struct(params->unit_id,
+ LOG_ERR,
+ LOG_MESSAGE("Failed to load environment files: %s", strerror(-err)),
+ LOG_ERRNO(-err),
+ NULL);
return err;
}
@@ -1813,10 +1814,10 @@ int exec_spawn(ExecCommand *command,
if (!line)
return log_oom();
- log_unit_struct(LOG_DEBUG,
- params->unit_id,
+ log_unit_struct(params->unit_id,
+ LOG_DEBUG,
"EXECUTABLE=%s", command->path,
- "MESSAGE=About to execute: %s", line,
+ LOG_MESSAGE("About to execute: %s", line),
NULL);
free(line);
@@ -1838,12 +1839,13 @@ int exec_spawn(ExecCommand *command,
&r);
if (r != 0) {
log_open();
- log_struct(LOG_ERR, MESSAGE_ID(SD_MESSAGE_SPAWN_FAILED),
+ log_struct(LOG_ERR,
+ LOG_MESSAGE_ID(SD_MESSAGE_SPAWN_FAILED),
"EXECUTABLE=%s", command->path,
- "MESSAGE=Failed at step %s spawning %s: %s",
- exit_status_to_string(r, EXIT_STATUS_SYSTEMD),
- command->path, strerror(-err),
- "ERRNO=%d", -err,
+ LOG_MESSAGE("Failed at step %s spawning %s: %s",
+ exit_status_to_string(r, EXIT_STATUS_SYSTEMD),
+ command->path, strerror(-err)),
+ LOG_ERRNO(-err),
NULL);
log_close();
}
@@ -1851,10 +1853,10 @@ int exec_spawn(ExecCommand *command,
_exit(r);
}
- log_unit_struct(LOG_DEBUG,
- params->unit_id,
- "MESSAGE=Forked %s as "PID_FMT,
- command->path, pid,
+ log_unit_struct(params->unit_id,
+ LOG_DEBUG,
+ LOG_MESSAGE("Forked %s as "PID_FMT,
+ command->path, pid),
NULL);
/* We add the new process to the cgroup both in the child (so
diff --git a/src/core/job.c b/src/core/job.c
index 80fdbde..8968091 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -730,28 +730,28 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
sd_id128_t mid;
mid = result == JOB_DONE ? SD_MESSAGE_UNIT_STARTED : SD_MESSAGE_UNIT_FAILED;
- log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- u->id,
- MESSAGE_ID(mid),
- "RESULT=%s", job_result_to_string(result),
- "MESSAGE=%s", buf,
- NULL);
+ log_unit_struct(u->id,
+ result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ LOG_MESSAGE_ID(mid),
+ LOG_MESSAGE("%s", buf),
+ "RESULT=%s", job_result_to_string(result),
+ NULL);
} else if (t == JOB_STOP)
- log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- u->id,
- MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED),
- "RESULT=%s", job_result_to_string(result),
- "MESSAGE=%s", buf,
- NULL);
+ log_unit_struct(u->id,
+ result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ LOG_MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED),
+ LOG_MESSAGE("%s", buf),
+ "RESULT=%s", job_result_to_string(result),
+ NULL);
else if (t == JOB_RELOAD)
- log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- u->id,
- MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED),
- "RESULT=%s", job_result_to_string(result),
- "MESSAGE=%s", buf,
- NULL);
+ log_unit_struct(u->id,
+ result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ LOG_MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED),
+ LOG_MESSAGE("%s", buf),
+ "RESULT=%s", job_result_to_string(result),
+ NULL);
}
int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) {
@@ -837,15 +837,15 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) {
* this context. And JOB_FAILURE is already handled by the
* unit itself. */
if (result == JOB_TIMEOUT || result == JOB_DEPENDENCY) {
- log_unit_struct(LOG_NOTICE,
- u->id,
- "JOB_TYPE=%s", job_type_to_string(t),
- "JOB_RESULT=%s", job_result_to_string(result),
- "Job %s/%s failed with result '%s'.",
- u->id,
- job_type_to_string(t),
- job_result_to_string(result),
- NULL);
+ log_unit_struct(u->id,
+ LOG_NOTICE,
+ "JOB_TYPE=%s", job_type_to_string(t),
+ "JOB_RESULT=%s", job_result_to_string(result),
+ LOG_MESSAGE("Job %s/%s failed with result '%s'.",
+ u->id,
+ job_type_to_string(t),
+ job_result_to_string(result)),
+ NULL);
unit_start_on_failure(u);
}
diff --git a/src/core/manager.c b/src/core/manager.c
index 0d1f5bb..63102d1 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1881,8 +1881,8 @@ static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint
assert(m->time_change_fd == fd);
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),
- "MESSAGE=Time has been changed",
+ LOG_MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),
+ LOG_MESSAGE("Time has been changed"),
NULL);
/* Restart the watch */
@@ -2590,28 +2590,28 @@ static void manager_notify_finished(Manager *m) {
initrd_usec = m->userspace_timestamp.monotonic - m->initrd_timestamp.monotonic;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
+ LOG_MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"KERNEL_USEC="USEC_FMT, kernel_usec,
"INITRD_USEC="USEC_FMT, initrd_usec,
"USERSPACE_USEC="USEC_FMT, userspace_usec,
- "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
- format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
- format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
- format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
- format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
+ LOG_MESSAGE("Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
+ format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
+ format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
+ format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
+ format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)),
NULL);
} else {
kernel_usec = m->userspace_timestamp.monotonic - m->kernel_timestamp.monotonic;
initrd_usec = 0;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
+ LOG_MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"KERNEL_USEC="USEC_FMT, kernel_usec,
"USERSPACE_USEC="USEC_FMT, userspace_usec,
- "MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
- format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
- format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
- format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
+ LOG_MESSAGE("Startup finished in %s (kernel) + %s (userspace) = %s.",
+ format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
+ format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
+ format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)),
NULL);
}
} else {
@@ -2619,10 +2619,10 @@ static void manager_notify_finished(Manager *m) {
total_usec = userspace_usec = m->finish_timestamp.monotonic - m->userspace_timestamp.monotonic;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
+ LOG_MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"USERSPACE_USEC="USEC_FMT, userspace_usec,
- "MESSAGE=Startup finished in %s.",
- format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
+ LOG_MESSAGE("Startup finished in %s.",
+ format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)),
NULL);
}
diff --git a/src/core/mount.c b/src/core/mount.c
index 36375f6..d34699b 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -823,12 +823,12 @@ void warn_if_dir_nonempty(const char *unit, const char* where) {
if (r > 0)
return;
else if (r == 0)
- log_unit_struct(LOG_NOTICE,
- unit,
- "MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.",
- unit, where,
+ log_unit_struct(unit,
+ LOG_NOTICE,
+ LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
+ LOG_MESSAGE("%s: Directory %s to mount over is not empty, mounting anyway.",
+ unit, where),
"WHERE=%s", where,
- MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
NULL);
else
log_unit_warning(unit,
@@ -840,12 +840,12 @@ static int fail_if_symlink(const char *unit, const char* where) {
assert(where);
if (is_symlink(where) > 0) {
- log_unit_struct(LOG_WARNING,
- unit,
- "MESSAGE=%s: Mount on symlink %s not allowed.",
- unit, where,
+ log_unit_struct(unit,
+ LOG_ERR,
+ LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
+ LOG_MESSAGE("%s: Mount on symlink %s not allowed.",
+ unit, where),
"WHERE=%s", where,
- MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
NULL);
return -ELOOP;
diff --git a/src/core/service.c b/src/core/service.c
index 72e8f71..a55be8f 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2205,16 +2205,16 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
f = SERVICE_SUCCESS;
}
- log_unit_struct(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
- u->id,
- "MESSAGE=%s: main process exited, code=%s, status=%i/%s",
- u->id, sigchld_code_to_string(code), status,
- strna(code == CLD_EXITED
- ? exit_status_to_string(status, EXIT_STATUS_FULL)
- : signal_to_string(status)),
- "EXIT_CODE=%s", sigchld_code_to_string(code),
- "EXIT_STATUS=%i", status,
- NULL);
+ log_unit_struct(u->id,
+ f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+ LOG_MESSAGE("%s: main process exited, code=%s, status=%i/%s",
+ u->id, sigchld_code_to_string(code), status,
+ strna(code == CLD_EXITED
+ ? exit_status_to_string(status, EXIT_STATUS_FULL)
+ : signal_to_string(status))),
+ "EXIT_CODE=%s", sigchld_code_to_string(code),
+ "EXIT_STATUS=%i", status,
+ NULL);
if (f != SERVICE_SUCCESS)
s->result = f;
diff --git a/src/core/unit.c b/src/core/unit.c
index 2e8df7d..88cddbd 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1394,10 +1394,10 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
t == JOB_STOP ? SD_MESSAGE_UNIT_STOPPING :
SD_MESSAGE_UNIT_RELOADING;
- log_unit_struct(LOG_INFO,
- u->id,
- MESSAGE_ID(mid),
- "MESSAGE=%s", buf,
+ log_unit_struct(u->id,
+ LOG_INFO,
+ LOG_MESSAGE_ID(mid),
+ LOG_MESSAGE("%s", buf),
NULL);
}
diff --git a/src/core/unit.h b/src/core/unit.h
index 5c0fba7..5983a51 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -605,4 +605,4 @@ UnitActiveState unit_active_state_from_string(const char *s) _pure_;
#define log_unit_warning(unit, ...) log_unit_full(unit, LOG_WARNING, __VA_ARGS__)
#define log_unit_error(unit, ...) log_unit_full(unit, LOG_ERR, __VA_ARGS__)
-#define log_unit_struct(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__)
+#define log_unit_struct(unit, level, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index cd4843c..4fd2069 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -841,7 +841,7 @@ void server_driver_message(Server *s, sd_id128_t message_id, const char *format,
IOVEC_SET_STRING(iovec[n++], buffer);
if (!sd_id128_equal(message_id, SD_ID128_NULL)) {
- snprintf(mid, sizeof(mid), MESSAGE_ID(message_id));
+ snprintf(mid, sizeof(mid), LOG_MESSAGE_ID(message_id));
char_array_0(mid);
IOVEC_SET_STRING(iovec[n++], mid);
}
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 57e619e..e380dc0 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -159,8 +159,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
case KEY_POWER:
case KEY_POWER2:
log_struct(LOG_INFO,
- "MESSAGE=Power key pressed.",
- MESSAGE_ID(SD_MESSAGE_POWER_KEY),
+ LOG_MESSAGE("Power key pressed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_POWER_KEY),
NULL);
manager_handle_action(b->manager, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manager->power_key_ignore_inhibited, true);
@@ -174,8 +174,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
case KEY_SLEEP:
log_struct(LOG_INFO,
- "MESSAGE=Suspend key pressed.",
- MESSAGE_ID(SD_MESSAGE_SUSPEND_KEY),
+ LOG_MESSAGE("Suspend key pressed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_SUSPEND_KEY),
NULL);
manager_handle_action(b->manager, INHIBIT_HANDLE_SUSPEND_KEY, b->manager->handle_suspend_key, b->manager->suspend_key_ignore_inhibited, true);
@@ -183,8 +183,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
case KEY_SUSPEND:
log_struct(LOG_INFO,
- "MESSAGE=Hibernate key pressed.",
- MESSAGE_ID(SD_MESSAGE_HIBERNATE_KEY),
+ LOG_MESSAGE("Hibernate key pressed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_HIBERNATE_KEY),
NULL);
manager_handle_action(b->manager, INHIBIT_HANDLE_HIBERNATE_KEY, b->manager->handle_hibernate_key, b->manager->hibernate_key_ignore_inhibited, true);
@@ -195,8 +195,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
if (ev.code == SW_LID) {
log_struct(LOG_INFO,
- "MESSAGE=Lid closed.",
- MESSAGE_ID(SD_MESSAGE_LID_CLOSED),
+ LOG_MESSAGE("Lid closed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_LID_CLOSED),
NULL);
b->lid_closed = true;
@@ -205,8 +205,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
} else if (ev.code == SW_DOCK) {
log_struct(LOG_INFO,
- "MESSAGE=System docked.",
- MESSAGE_ID(SD_MESSAGE_SYSTEM_DOCKED),
+ LOG_MESSAGE("System docked."),
+ LOG_MESSAGE_ID(SD_MESSAGE_SYSTEM_DOCKED),
NULL);
b->docked = true;
@@ -216,8 +216,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
if (ev.code == SW_LID) {
log_struct(LOG_INFO,
- "MESSAGE=Lid opened.",
- MESSAGE_ID(SD_MESSAGE_LID_OPENED),
+ LOG_MESSAGE("Lid opened."),
+ LOG_MESSAGE_ID(SD_MESSAGE_LID_OPENED),
NULL);
b->lid_closed = false;
@@ -225,8 +225,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
} else if (ev.code == SW_DOCK) {
log_struct(LOG_INFO,
- "MESSAGE=System undocked.",
- MESSAGE_ID(SD_MESSAGE_SYSTEM_UNDOCKED),
+ LOG_MESSAGE("System undocked."),
+ LOG_MESSAGE_ID(SD_MESSAGE_SYSTEM_UNDOCKED),
NULL);
b->docked = false;
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index f18d210..d225ba1 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1300,9 +1300,11 @@ static int bus_manager_log_shutdown(
q = NULL;
}
- return log_struct(LOG_NOTICE, MESSAGE_ID(SD_MESSAGE_SHUTDOWN),
+ return log_struct(LOG_NOTICE,
+ LOG_MESSAGE_ID(SD_MESSAGE_SHUTDOWN),
p,
- q, NULL);
+ q,
+ NULL);
}
static int lid_switch_ignore_handler(sd_event_source *e, uint64_t usec, void *userdata) {
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 9992195..709c638 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -400,9 +400,9 @@ int seat_start(Seat *s) {
return 0;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SEAT_START),
+ LOG_MESSAGE_ID(SD_MESSAGE_SEAT_START),
"SEAT_ID=%s", s->id,
- "MESSAGE=New seat %s.", s->id,
+ LOG_MESSAGE("New seat %s.", s->id),
NULL);
/* Initialize VT magic stuff */
@@ -428,9 +428,9 @@ int seat_stop(Seat *s, bool force) {
if (s->started)
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SEAT_STOP),
+ LOG_MESSAGE_ID(SD_MESSAGE_SEAT_STOP),
"SEAT_ID=%s", s->id,
- "MESSAGE=Removed seat %s.", s->id,
+ LOG_MESSAGE("Removed seat %s.", s->id),
NULL);
seat_stop_sessions(s, force);
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 65bbb77..c4fe53b 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -549,11 +549,11 @@ int session_start(Session *s) {
return r;
log_struct(s->class == SESSION_BACKGROUND ? LOG_DEBUG : LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SESSION_START),
+ LOG_MESSAGE_ID(SD_MESSAGE_SESSION_START),
"SESSION_ID=%s", s->id,
"USER_ID=%s", s->user->name,
"LEADER="PID_FMT, s->leader,
- "MESSAGE=New session %s of user %s.", s->id, s->user->name,
+ LOG_MESSAGE("New session %s of user %s.", s->id, s->user->name),
NULL);
if (!dual_timestamp_is_set(&s->timestamp))
@@ -652,11 +652,11 @@ int session_finalize(Session *s) {
if (s->started)
log_struct(s->class == SESSION_BACKGROUND ? LOG_DEBUG : LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SESSION_STOP),
+ LOG_MESSAGE_ID(SD_MESSAGE_SESSION_STOP),
"SESSION_ID=%s", s->id,
"USER_ID=%s", s->user->name,
"LEADER="PID_FMT, s->leader,
- "MESSAGE=Removed session %s.", s->id,
+ LOG_MESSAGE("Removed session %s.", s->id),
NULL);
s->timer_event_source = sd_event_source_unref(s->timer_event_source);
diff --git a/src/machine/machine.c b/src/machine/machine.c
index 13d3448..a6d636e 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -377,10 +377,10 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) {
return r;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_MACHINE_START),
+ LOG_MESSAGE_ID(SD_MESSAGE_MACHINE_START),
"NAME=%s", m->name,
"LEADER="PID_FMT, m->leader,
- "MESSAGE=New machine %s.", m->name,
+ LOG_MESSAGE("New machine %s.", m->name),
NULL);
if (!dual_timestamp_is_set(&m->timestamp))
@@ -426,10 +426,10 @@ int machine_stop(Machine *m) {
if (m->started)
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_MACHINE_STOP),
+ LOG_MESSAGE_ID(SD_MESSAGE_MACHINE_STOP),
"NAME=%s", m->name,
"LEADER="PID_FMT, m->leader,
- "MESSAGE=Machine %s terminated.", m->name,
+ LOG_MESSAGE("Machine %s terminated.", m->name),
NULL);
/* Kill cgroup */
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 6bd9d9e..f9a3459 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -64,19 +64,19 @@ int log_syntax_internal(
error > 0 ? error : EINVAL,
file, line, func,
getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit,
- MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
+ LOG_MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
"CONFIG_FILE=%s", config_file,
"CONFIG_LINE=%u", config_line,
- "MESSAGE=[%s:%u] %s", config_file, config_line, msg,
+ LOG_MESSAGE("[%s:%u] %s", config_file, config_line, msg),
NULL);
else
r = log_struct_internal(level,
error > 0 ? error : EINVAL,
file, line, func,
- MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
+ LOG_MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
"CONFIG_FILE=%s", config_file,
"CONFIG_LINE=%u", config_line,
- "MESSAGE=[%s:%u] %s", config_file, config_line, msg,
+ LOG_MESSAGE("[%s:%u] %s", config_file, config_line, msg),
NULL);
return r;
diff --git a/src/shared/log.h b/src/shared/log.h
index 2780104..3a4d113 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -199,7 +199,10 @@ bool log_on_console(void) _pure_;
const char *log_target_to_string(LogTarget target) _const_;
LogTarget log_target_from_string(const char *s) _pure_;
-#define MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
+/* Helpers to prepare various fields for structured logging */
+#define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__
+#define LOG_MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
+#define LOG_ERRNO(error) "ERRNO=%i", error
void log_received_signal(int level, const struct signalfd_siginfo *si);
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index ca00eea..0d7c1e3 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -88,10 +88,16 @@ static int write_state(FILE **f, char **states) {
}
static int execute(char **modes, char **states) {
- char* arguments[4];
+
+ char *arguments[] = {
+ NULL,
+ (char*) "pre",
+ arg_verb,
+ NULL
+ };
+
int r;
_cleanup_fclose_ FILE *f = NULL;
- const char* note = strappenda("SLEEP=", arg_verb);
/* This file is opened first, so that if we hit an error,
* we can abort before modifying any state. */
@@ -106,16 +112,12 @@ static int execute(char **modes, char **states) {
if (r < 0)
return r;
- arguments[0] = NULL;
- arguments[1] = (char*) "pre";
- arguments[2] = arg_verb;
- arguments[3] = NULL;
execute_directory(SYSTEM_SLEEP_PATH, NULL, DEFAULT_TIMEOUT_USEC, arguments);
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SLEEP_START),
- "MESSAGE=Suspending system...",
- note,
+ LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_START),
+ LOG_MESSAGE("Suspending system..."),
+ "SLEEP=%s", arg_verb,
NULL);
r = write_state(&f, states);
@@ -123,9 +125,9 @@ static int execute(char **modes, char **states) {
return r;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
- "MESSAGE=System resumed.",
- note,
+ LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
+ LOG_MESSAGE("MESSAGE=System resumed."),
+ "SLEEP=%s", arg_verb,
NULL);
arguments[1] = (char*) "post";
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index e720227..4af054e 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -429,9 +429,9 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, s
}
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_TIMEZONE_CHANGE),
+ LOG_MESSAGE_ID(SD_MESSAGE_TIMEZONE_CHANGE),
"TIMEZONE=%s", c->zone,
- "MESSAGE=Changed time zone to '%s'.", c->zone,
+ LOG_MESSAGE("Changed time zone to '%s'.", c->zone),
NULL);
sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL);
@@ -581,9 +581,9 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu
clock_set_hwclock(tm);
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),
+ LOG_MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),
"REALTIME="USEC_FMT, timespec_load(&ts),
- "MESSAGE=Changed local time to %s", ctime(&ts.tv_sec),
+ LOG_MESSAGE("Changed local time to %s", ctime(&ts.tv_sec)),
NULL);
return sd_bus_reply_method_return(m, NULL);
commit 6c861f0aeff9449ee1201bb56f89861921e41c45
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 00:42:35 2014 +0100
networkd: update logging macros for parameter order, and errno, to match rest of the code
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 0a8c8ba..ac59fd4 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -442,7 +442,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
}
if (r >= 0)
- log_link_struct(LOG_INFO, link,
+ log_link_struct(link, LOG_INFO,
"MESSAGE=%-*s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
IFNAMSIZ,
link->ifname,
@@ -457,7 +457,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
ADDRESS_FMT_VAL(gateway),
NULL);
else
- log_link_struct(LOG_INFO, link,
+ log_link_struct(link, LOG_INFO,
"MESSAGE=%-*s: DHCPv4 address %u.%u.%u.%u/%u",
IFNAMSIZ,
link->ifname,
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index b46ac5c..2eb0925 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -515,12 +515,7 @@ static int route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not set route: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not set route: %m", IFNAMSIZ, link->ifname);
if (link->link_messages == 0) {
log_link_debug(link, "routes set");
@@ -576,12 +571,7 @@ int link_route_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -ESRCH)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not drop route: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not drop route: %m", IFNAMSIZ, link->ifname);
return 1;
}
@@ -631,12 +621,7 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not set address: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not set address: %m", IFNAMSIZ, link->ifname);
else if (r >= 0) {
/* calling handler directly so take a ref */
link_ref(link);
@@ -695,12 +680,7 @@ int link_address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EADDRNOTAVAIL)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not drop address: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not drop address: %m", IFNAMSIZ, link->ifname);
return 1;
}
@@ -780,11 +760,7 @@ static int set_mtu_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not set MTU: %s",
- IFNAMSIZ, link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not set MTU: %m", IFNAMSIZ, link->ifname);
return 1;
}
@@ -1003,12 +979,7 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
if (r < 0) {
/* we warn but don't fail the link, as it may
be brought up later */
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not bring up interface: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not bring up interface: %m", IFNAMSIZ, link->ifname);
}
return 1;
@@ -1084,12 +1055,7 @@ static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
- log_link_struct(LOG_ERR, link,
- "MESSAGE=%-*s: could not join netdev: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_error_errno(link, -r, "%-*s: could not join netdev: %m", IFNAMSIZ, link->ifname);
link_enter_failed(link);
return 1;
} else
@@ -1120,7 +1086,7 @@ static int link_enter_join_netdev(Link *link) {
return link_joined(link);
if (link->network->bond) {
- log_link_struct(LOG_DEBUG, link,
+ log_link_struct(link, LOG_DEBUG,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bond->ifname,
@@ -1129,7 +1095,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(link->network->bond, link, &netdev_join_handler);
if (r < 0) {
- log_link_struct(LOG_WARNING, link,
+ log_link_struct(link, LOG_WARNING,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bond->ifname,
@@ -1144,7 +1110,7 @@ static int link_enter_join_netdev(Link *link) {
}
if (link->network->bridge) {
- log_link_struct(LOG_DEBUG, link,
+ log_link_struct(link, LOG_DEBUG,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
@@ -1154,7 +1120,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(link->network->bridge, link,
&netdev_join_handler);
if (r < 0) {
- log_link_struct(LOG_WARNING, link,
+ log_link_struct(link, LOG_WARNING,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
@@ -1169,7 +1135,7 @@ static int link_enter_join_netdev(Link *link) {
}
HASHMAP_FOREACH(netdev, link->network->stacked_netdevs, i) {
- log_link_struct(LOG_DEBUG, link,
+ log_link_struct(link, LOG_DEBUG,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, netdev->ifname, NETDEVIF(netdev),
@@ -1177,7 +1143,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(netdev, link, &netdev_join_handler);
if (r < 0) {
- log_link_struct(LOG_WARNING, link,
+ log_link_struct(link, LOG_WARNING,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, netdev->ifname,
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 61cdbf3..5663175 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -132,14 +132,22 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
/* Macros which append INTERFACE= to the message */
-#define log_link_full(level, link, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
-#define log_link_debug(link, ...) log_link_full(LOG_DEBUG, link, ##__VA_ARGS__)
-#define log_link_info(link, ...) log_link_full(LOG_INFO, link, ##__VA_ARGS__)
-#define log_link_notice(link, ...) log_link_full(LOG_NOTICE, link, ##__VA_ARGS__)
-#define log_link_warning(link, ...) log_link_full(LOG_WARNING, link, ##__VA_ARGS__)
-#define log_link_error(link, ...) log_link_full(LOG_ERR, link, ##__VA_ARGS__)
-
-#define log_link_struct(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
+#define log_link_full(link, level, error, fmt, ...) \
+ log_object_internal(level, error, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
+
+#define log_link_debug(link, ...) log_link_full(link, LOG_DEBUG, 0, ##__VA_ARGS__)
+#define log_link_info(link, ...) log_link_full(link, LOG_INFO, 0, ##__VA_ARGS__)
+#define log_link_notice(link, ...) log_link_full(link, LOG_NOTICE, 0, ##__VA_ARGS__)
+#define log_link_warning(link, ...) log_link_full(link, LOG_WARNING, 0, ##__VA_ARGS__)
+#define log_link_error(link, ...) log_link_full(link, LOG_ERR, 0, ##__VA_ARGS__)
+
+#define log_link_debug_errno(link, error, ...) log_link_full(link, LOG_DEBUG, error, ##__VA_ARGS__)
+#define log_link_info_errno(link, error, ...) log_link_full(link, LOG_INFO, error, ##__VA_ARGS__)
+#define log_link_notice_errno(link, error, ...) log_link_full(link, LOG_NOTICE, error, ##__VA_ARGS__)
+#define log_link_warning_errno(link, error, ...) log_link_full(link, LOG_WARNING, error, ##__VA_ARGS__)
+#define log_link_error_errno(link, error, ...) log_link_full(link, LOG_ERR, error, ##__VA_ARGS__)
+
+#define log_link_struct(link, level, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
#define ADDRESS_FMT_VAL(address) \
(address).s_addr & 0xFF, \
commit bca3e263cfc68f506bfbafb11680f35aa13c38a5
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 00:41:49 2014 +0100
update TODO
diff --git a/TODO b/TODO
index fd48171..5588baf 100644
--- a/TODO
+++ b/TODO
@@ -257,8 +257,8 @@ Features:
ReadOnlyDirectories=... for whitelisting files for a service.
* sd-bus:
- - kdbus: the kernel needs to tell us whether it accepted a message because of a method call window. THis can then be used by the proxy to blindly accept all method replies with that flag set as OK.
- - systemd-bus-proxyd needs to enforce good old XML policy
+ - bus-proxy: fix how we detect whether we are connected to a system bus
+ - kdbus: the kernel should not allow messages to be delivered that have a reply serial != 0, reply-expect unset, but no appropriate window
- kdbus: busnames.target should get pulled in by basic.target
- Ignore .busname units on classic D-Bus boots, systemd-resolved cannot be started on kdbus
without the active policy and should get a Wants=org.freedesktop.resolve1.busname to
@@ -286,6 +286,8 @@ Features:
253 messages)
- kdbus: introduce a concept of "send-only" connections
- kdbus: add counter for refused unicast messages that is passed out via the RECV ioctl. SImilar to the counter for dropped multicast messages we already have.
+ - kdbus: when we fake creds euid being (uint32_t) -1 is weirdly translated
+ - kdbus: attach mask kmod parameter should be 64bit not 32bit
* sd-event
- allow multiple signal handlers per signal?
commit ac3ab439f022766b264b0b8af0789df9cd12a18e
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 28 00:41:38 2014 +0100
networkd: remove duplicate macro definitions
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 263cc61..1f31023 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -333,20 +333,3 @@ int address_pool_new_from_string(Manager *m, AddressPool **ret, int family, cons
void address_pool_free(AddressPool *p);
int address_pool_acquire(AddressPool *p, unsigned prefixlen, union in_addr_union *found);
-
-/* Macros which append INTERFACE= to the message */
-
-#define log_link_full(level, link, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
-#define log_link_debug(link, ...) log_link_full(LOG_DEBUG, link, ##__VA_ARGS__)
-#define log_link_info(link, ...) log_link_full(LOG_INFO, link, ##__VA_ARGS__)
-#define log_link_notice(link, ...) log_link_full(LOG_NOTICE, link, ##__VA_ARGS__)
-#define log_link_warning(link, ...) log_link_full(LOG_WARNING, link, ##__VA_ARGS__)
-#define log_link_error(link, ...) log_link_full(LOG_ERR, link, ##__VA_ARGS__)
-
-#define log_link_struct(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
-
-#define ADDRESS_FMT_VAL(address) \
- (address).s_addr & 0xFF, \
- ((address).s_addr >> 8) & 0xFF, \
- ((address).s_addr >> 16) & 0xFF, \
- (address).s_addr >> 24
More information about the systemd-commits
mailing list