summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-06-16 05:42:33 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-06-16 05:42:33 +0000
commit39342962511c923e1cc4bf9aea1040dacca5d6a5 (patch)
tree4cc8d19a8377eea17b37d011359fe5eb88b85319 /src
parent82578d77f2a00d4794f4e55ae04f431340bbcada (diff)
downloadutmps-39342962511c923e1cc4bf9aea1040dacca5d6a5.tar.xz
Only have pututxline() overwrite records with the same ut_line
Diffstat (limited to 'src')
-rw-r--r--src/utmps/utmps-utmpd.c18
1 files changed, 10 insertions, 8 deletions
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))