From 39342962511c923e1cc4bf9aea1040dacca5d6a5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sat, 16 Jun 2018 05:42:33 +0000 Subject: Only have pututxline() overwrite records with the same ut_line --- src/utmps/utmps-utmpd.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/utmps/utmps-utmpd.c b/src/utmps/utmps-utmpd.c index 32d174b..42fb4ed 100644 --- a/src/utmps/utmps-utmpd.c +++ b/src/utmps/utmps-utmpd.c @@ -156,16 +156,18 @@ static void do_putline (uid_t uid) { struct utmpx b ; char tmp[sizeof(struct utmpx)] ; - if (!read_utmp_entry(tmp)) goto writeit ; + if (!read_utmp_entry(tmp)) break ; utmps_utmpx_unpack(tmp, &b) ; - if (idmatch(u.ut_type, u.ut_id, &b)) break ; - } - if (lseek(fd, -(off_t)sizeof(struct utmpx), SEEK_CUR) < 0) - { - answer(errno) ; - return ; + if (idmatch(u.ut_type, u.ut_id, &b) && !strncmp(u.ut_line, b.ut_line, UTMPS_UT_LINESIZE - 1)) + { + if (lseek(fd, -(off_t)sizeof(struct utmpx), SEEK_CUR) < 0) + { + answer(errno) ; + return ; + } + break ; + } } - writeit: utmps_utmpx_pack(buf, &u) ; if (lock_ex(fd) < 0) { answer(errno) ; return ; } if (allwrite(fd, buf, sizeof(struct utmpx)) < sizeof(struct utmpx)) -- cgit 1.4.1