From c4482f7b3b298b2a66c959a08f07a19aa580fba5 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 24 May 2016 14:08:57 +0200 Subject: last: fix logout time Signed-off-by: Karel Zak --- login-utils/last.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/login-utils/last.c b/login-utils/last.c index 78b82ca8f..1ffd226a0 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -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(); -- cgit v1.2.3-55-g7522