summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-09-06 11:16:35 +0200
committerLeah Neukirchen <chneukirchen@gmail.com>2019-09-06 14:40:42 +0200
commit59f9de7fc1c8b8eba55564c5c1ec83499bc0a66a (patch)
tree4b5e6921c4ef21e9821d73b529e47132985a9f81
parent6e355b9c6567363eff97940ba94c3e086028435c (diff)
downloadrunit-void-59f9de7fc1c8b8eba55564c5c1ec83499bc0a66a.tar.gz
runit-void-59f9de7fc1c8b8eba55564c5c1ec83499bc0a66a.tar.xz
runit-void-59f9de7fc1c8b8eba55564c5c1ec83499bc0a66a.zip
halt: also update utmp
-rw-r--r--halt.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/halt.c b/halt.c
index 7241d42..67a11a1 100644
--- a/halt.c
+++ b/halt.c
@@ -18,6 +18,10 @@ typedef enum {NOOP, HALT, REBOOT, POWEROFF} action_type;
 #define OUR_WTMP "/var/log/wtmp"
 #endif
 
+#ifndef OUR_UTMP
+#define OUR_UTMP "/run/utmp"
+#endif
+
 void write_wtmp(int boot) {
   int fd;
 
@@ -42,6 +46,13 @@ void write_wtmp(int boot) {
 
   write(fd, (char *)&utmp, sizeof(utmp));
   close(fd);
+
+  if (boot) {
+    if ((fd = open(OUR_UTMP, O_WRONLY|O_APPEND)) < 0)
+      return;
+    write(fd, (char *)&utmp, sizeof utmp);
+    close(fd);
+  }
 }
 
 int main(int argc, char *argv[]) {