b1b450
From 3fc3a07a03ef74fde99db40ce9ef43ccab336205 Mon Sep 17 00:00:00 2001
b1b450
From: MertsA <andrewmerts@gmail.com>
b1b450
Date: Fri, 23 Jul 2021 03:36:05 -0700
b1b450
Subject: [PATCH] Rewind utmp file pointer after searching for entry
b1b450
b1b450
getutline() advances the file pointer until it matches or reaches EOF. pututline() starts from the current position in utmp. This rewinds the file pointer to the beginning to avoid allocating additional spurious utmp entries.
b1b450
---
b1b450
 src/utmp.c | 1 +
b1b450
 1 file changed, 1 insertion(+)
b1b450
b1b450
diff --git a/src/utmp.c b/src/utmp.c
b1b450
index 544a37519..952bf3043 100644
b1b450
--- a/src/utmp.c
b1b450
+++ b/src/utmp.c
b1b450
@@ -210,6 +210,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd,
b1b450
 	memset(&utbuf, 0, sizeof(utbuf));
b1b450
 	strncpy(utbuf.ut_line, from_line, sizeof(utbuf.ut_line));
b1b450
 	ut_old = sudo_getutline(&utbuf);
b1b450
+	sudo_setutent();
b1b450
     }
b1b450
     utmp_fill(to_line, user, ut_old, &utbuf);
b1b450
     if (sudo_pututline(&utbuf) != NULL)