[systemd-devel] [PATCH 2/7] shutdownd: honour !HAVE_UTMP

Emil Renner Berthing systemd at esmil.dk
Wed Sep 24 08:25:01 PDT 2014


---
 src/shutdownd/shutdownd.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c
index 99aa4b3..4132d9a 100644
--- a/src/shutdownd/shutdownd.c
+++ b/src/shutdownd/shutdownd.c
@@ -36,10 +36,13 @@
 #include "log.h"
 #include "macro.h"
 #include "util.h"
-#include "utmp-wtmp.h"
 #include "mkdir.h"
 #include "fileio.h"
 
+#ifdef HAVE_UTMP
+#include "utmp-wtmp.h"
+#endif
+
 union shutdown_buffer {
         struct sd_shutdown_command command;
         char space[offsetof(struct sd_shutdown_command, wall_message) + LINE_MAX];
@@ -118,6 +121,7 @@ static int read_packet(int fd, union shutdown_buffer *_b) {
 }
 
 static void warn_wall(usec_t n, struct sd_shutdown_command *c) {
+#ifdef HAVE_UTMP
         char date[FORMAT_TIMESTAMP_MAX];
         const char *prefix;
         _cleanup_free_ char *l = NULL;
@@ -146,6 +150,7 @@ static void warn_wall(usec_t n, struct sd_shutdown_command *c) {
                 utmp_wall(l, NULL, NULL);
         else
                 log_error("Failed to allocate wall message");
+#endif
 }
 
 _const_ static usec_t when_wall(usec_t n, usec_t elapse) {
@@ -348,6 +353,7 @@ int main(int argc, char *argv[]) {
                                 }
 
                                 zero(its);
+#ifdef HAVE_UTMP
                                 if (b.command.warn_wall) {
                                         /* Send wall messages every so often */
                                         timespec_store(&its.it_value, when_wall(n, b.command.usec));
@@ -357,6 +363,7 @@ int main(int argc, char *argv[]) {
                                             n + 15*USEC_PER_MINUTE >= b.command.usec)
                                                 warn_wall(n, &b.command);
                                 }
+#endif
                                 if (timerfd_settime(pollfd[FD_WALL_TIMER].fd, TFD_TIMER_ABSTIME, &its, NULL) < 0) {
                                         log_error("timerfd_settime(): %m");
                                         goto finish;
-- 
2.1.0



More information about the systemd-devel mailing list