]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: fix logout time
authorKarel Zak <kzak@redhat.com>
Tue, 24 May 2016 12:08:57 +0000 (14:08 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 24 May 2016 12:08:57 +0000 (14:08 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/last.c

index 78b82ca8fe0bf8f6d20a3047cf582707d2db6248..1ffd226a04242a356d530e5b74552b99af01820a 100644 (file)
@@ -444,6 +444,11 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti
        hours = (secs / 3600) % 24;
        days  = secs / 86400;
 
+       strcpy(logouttime, "- ");
+       if (time_formatter(fmt->out_fmt, logouttime + 2,
+                          sizeof(logouttime) - 2, &logout_time) < 0)
+               errx(EXIT_FAILURE, _("preallocation size exceeded"));
+
        if (logout_time == currentdate) {
                if (ctl->time_fmt > LAST_TIMEFTM_SHORT) {
                        sprintf(logouttime, "  still running");
@@ -492,10 +497,6 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti
                        break;
                case R_NORMAL:
                case R_REBOOT:
-                       strcpy(logouttime, "- ");
-                       if (time_formatter(fmt->out_fmt, logouttime + 2,
-                                          sizeof(logouttime) - 2, &logout_time) < 0)
-                               errx(EXIT_FAILURE, _("preallocation size exceeded"));
                        break;
                default:
                        abort();