chiark / gitweb /
ask-password: don't show wall message on ttys we are already running a tty agent on
[elogind.git] / src / shutdownd.c
index 5ff9b4ae127b0ee1b0888ff774fdfc8b6afb3831..143fa8d825feca845e2e998476f9ae1c2910e76b 100644 (file)
@@ -108,7 +108,7 @@ static void warn_wall(usec_t n, struct shutdownd_command *c) {
                 return;
 
         if (c->wall_message[0])
-                utmp_wall(c->wall_message);
+                utmp_wall(c->wall_message, NULL);
         else {
                 char date[FORMAT_TIMESTAMP_MAX];
                 const char* prefix;
@@ -126,7 +126,7 @@ static void warn_wall(usec_t n, struct shutdownd_command *c) {
                 if (asprintf(&l, "%s%s!", prefix, format_timestamp(date, sizeof(date), c->elapse)) < 0)
                         log_error("Failed to allocate wall message");
                 else {
-                        utmp_wall(l);
+                        utmp_wall(l, NULL);
                         free(l);
                 }
         }
@@ -176,7 +176,7 @@ int main(int argc, char *argv[]) {
                 _FD_MAX
         };
 
-        int r = 4, n_fds;
+        int r = EXIT_FAILURE, n_fds;
         int one = 1;
         struct shutdownd_command c;
         struct pollfd pollfd[_FD_MAX];
@@ -185,12 +185,12 @@ int main(int argc, char *argv[]) {
 
         if (getppid() != 1) {
                 log_error("This program should be invoked by init only.");
-                return 1;
+                return EXIT_FAILURE;
         }
 
         if (argc > 1) {
                 log_error("This program does not take arguments.");
-                return 1;
+                return EXIT_FAILURE;
         }
 
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
@@ -199,17 +199,17 @@ int main(int argc, char *argv[]) {
 
         if ((n_fds = sd_listen_fds(true)) < 0) {
                 log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
-                return 1;
+                return EXIT_FAILURE;
         }
 
         if (n_fds != 1) {
                 log_error("Need exactly one file descriptor.");
-                return 2;
+                return EXIT_FAILURE;
         }
 
         if (setsockopt(SD_LISTEN_FDS_START, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0) {
                 log_error("SO_PASSCRED failed: %m");
-                return 3;
+                return EXIT_FAILURE;
         }
 
         zero(c);
@@ -318,10 +318,10 @@ int main(int argc, char *argv[]) {
                 if (pollfd[FD_NOLOGIN_TIMER].revents) {
                         int e;
 
-                        log_info("Creating /etc/nologin, blocking further logins...");
+                        log_info("Creating /var/run/nologin, blocking further logins...");
 
-                        if ((e = touch("/etc/nologin")) < 0)
-                                log_error("Failed to create /etc/nologin: %s", strerror(-e));
+                        if ((e = write_one_line_file("/var/run/nologin", "System is going down.")) < 0)
+                                log_error("Failed to create /var/run/nologin: %s", strerror(-e));
                         else
                                 unlink_nologin = true;
 
@@ -335,7 +335,7 @@ int main(int argc, char *argv[]) {
 
         } while (c.elapse > 0);
 
-        r = 0;
+        r = EXIT_SUCCESS;
 
         log_debug("systemd-shutdownd stopped as pid %lu", (unsigned long) getpid());
 
@@ -346,7 +346,7 @@ finish:
                         close_nointr_nofail(pollfd[i].fd);
 
         if (unlink_nologin)
-                unlink("/etc/nologin");
+                unlink("/var/run/nologin");
 
         if (exec_shutdown) {
                 char sw[3];