From: Karel Zak Date: Tue, 24 May 2016 12:08:57 +0000 (+0200) Subject: last: fix logout time X-Git-Tag: v2.29-rc1~226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4482f7b3b298b2a66c959a08f07a19aa580fba5;p=thirdparty%2Futil-linux.git last: fix logout time Signed-off-by: Karel Zak --- diff --git a/login-utils/last.c b/login-utils/last.c index 78b82ca8fe..1ffd226a04 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();