X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=utmp-wtmp.c;h=cb3f201322edbef648ca68b7bf5cb8933d231711;hb=afb757b1a8a416b3c692728330a266b3915eef41;hp=1650d10eba753cd7a8c065ff32ed1e07489e7ded;hpb=e537352b9bfffe6f6286483bff2c7601c78407e3;p=elogind.git diff --git a/utmp-wtmp.c b/utmp-wtmp.c index 1650d10eb..cb3f20132 100644 --- a/utmp-wtmp.c +++ b/utmp-wtmp.c @@ -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;