about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-04-19 10:36:43 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-04-19 10:36:43 +0000
commitc776811af67d99cdd22593c0eac8ff54876235b5 (patch)
tree131fa34114e1246218c6e5ebde7d3787b9fb9b13
parent793cf14db75f7802408130ef87598850f3186956 (diff)
downloadutmps-c776811af67d99cdd22593c0eac8ff54876235b5.tar.gz
utmps-c776811af67d99cdd22593c0eac8ff54876235b5.tar.xz
utmps-c776811af67d99cdd22593c0eac8ff54876235b5.zip
I *did* say it was a bad idea to remove sanitization, Xavier.
-rw-r--r--NEWS3
-rw-r--r--src/utmps/utmps-wtmpd.c13
2 files changed, 9 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 0329c7a..e5e27a9 100644
--- a/NEWS
+++ b/NEWS
@@ -3,11 +3,12 @@ Changelog for utmps.
 In 0.1.0.2
 ----------
 
+ - Bugfixes.
  - The wtmpd example now uses /var/log/wtmp instead of /run/utmps/wtmp
 since wtmp is supposed to survive across reboots.
  - WTMPX_FILE, which is unused by utmps, now points to /var/log/wtmp
 so that programs that want to read that file (e.g. lastlog) can
-access it without patching.
+access wtmp without patching. Or with less patching.
 
 
 In 0.1.0.1
diff --git a/src/utmps/utmps-wtmpd.c b/src/utmps/utmps-wtmpd.c
index 6a543af..b8639f8 100644
--- a/src/utmps/utmps-wtmpd.c
+++ b/src/utmps/utmps-wtmpd.c
@@ -50,6 +50,7 @@ int main (void)
   w = buffer_timed_get_g(buffer_0small, buf, sizeof(struct utmpx), &deadline) ; 
   if (w < sizeof(struct utmpx)) strerr_diefu1sys(111, "read from stdin") ;
   utmps_utmpx_unpack(buf, &b) ;
+  b.ut_user[UTMPS_UT_NAMESIZE - 1] = 0 ;
   if (uid)
   {
     struct passwd *pw ;
@@ -65,13 +66,13 @@ int main (void)
       else
       {
         answer(EPERM) ;
-        strerr_diefu2x(1, "verify ut_user identity", ": no such user") ;
+        strerr_diefu2x(1, "verify ut_user identity: ", "no such user") ;
       }
     }
     if (pw->pw_uid != uid)
     {
       answer(EPERM) ;
-      strerr_diefu2x(1, "verify ut_user identity", ": uid mismatch") ;
+      strerr_diefu2x(1, "verify ut_user identity: ", "uid mismatch") ;
     }
   }
   
@@ -79,17 +80,17 @@ int main (void)
   if (fd < 0)
   {
     answer(errno) ;
-    strerr_diefu1sys(111, "open wtmp") ;
+    strerr_diefu2sys(111, "open", " wtmp") ;
   }
   if (fd_lock(fd, 1, 0) < 1)
   {
     answer(errno) ;
-    strerr_diefu1sys(111, "open wtmp") ;
+    strerr_diefu2sys(111, "lock", " wtmp") ;
   }
   if (lseek(fd, 0, SEEK_END) < 0)
   {
     answer(errno) ;
-    strerr_diefu1sys(111, "lseek on wtmp") ;
+    strerr_diefu2sys(111, "lseek on", " wtmp") ;
   }
   w = allwrite(fd, buf, sizeof(struct utmpx)) ;
   if (w < sizeof(struct utmpx))
@@ -103,7 +104,7 @@ int main (void)
     fd_unlock(fd) ;
     answer(e) ;
     errno = e ;
-    strerr_diefu1sys(111, "append to wtmp") ;
+    strerr_diefu2sys(111, "append to", " wtmp") ;
   }
   fsync(fd) ;
   fd_unlock(fd) ;