summaryrefslogtreecommitdiffstats
path: root/login-utils/last.c
diff options
context:
space:
mode:
authorKarel Zak2016-05-24 14:08:57 +0200
committerKarel Zak2016-05-24 14:08:57 +0200
commitc4482f7b3b298b2a66c959a08f07a19aa580fba5 (patch)
treee446f995e0b9336a90150b8bc906228951d62451 /login-utils/last.c
parentlsipc: use strtime_short() (diff)
downloadkernel-qcow2-util-linux-c4482f7b3b298b2a66c959a08f07a19aa580fba5.tar.gz
kernel-qcow2-util-linux-c4482f7b3b298b2a66c959a08f07a19aa580fba5.tar.xz
kernel-qcow2-util-linux-c4482f7b3b298b2a66c959a08f07a19aa580fba5.zip
last: fix logout time
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r--login-utils/last.c9
1 files 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();