chiark / gitweb /
utmp: fix reboot string
[elogind.git] / utmp-wtmp.c
index 1650d10..cb3f201 100644 (file)
@@ -179,7 +179,7 @@ int utmp_put_reboot(usec_t timestamp) {
         init_entry(&store, timestamp);
 
         store.ut_type = BOOT_TIME;
-        strncpy(store.ut_user, "reboot", sizeof(store.ut_type));
+        strncpy(store.ut_user, "reboot", sizeof(store.ut_user));
 
         return write_entry_both(&store);
 }
@@ -193,8 +193,12 @@ int utmp_put_runlevel(usec_t timestamp, int runlevel, int previous) {
         if (previous <= 0) {
                 /* Find the old runlevel automatically */
 
-                if ((r = utmp_get_runlevel(&previous, NULL)) < 0)
-                        return r;
+                if ((r = utmp_get_runlevel(&previous, NULL)) < 0) {
+                        if (r != -ESRCH)
+                                return r;
+
+                        previous = 0;
+                }
 
                 if (previous == runlevel)
                         return 0;