changeset 17076:c2bb4d88ad0d

readutmp: fix non-portable UT_PID use The module readutmp is broken for the standard use read_utmp(..., READ_UTMP_USER_PROCESS | READ_UTMP_CHECK_PIDS) for all releases of FreeBSD until 8.3, and all OpenBSD ever released. The reason is that those systems do not provide `utmp.ut_pid', thus making the macro UT_PID(u) identical to naught, and then turning the predicate UT_PID (u) <= 0 found in desirable_utmp_entry(), into a permanent true clause. This makes desirable_utmp_entry() discard every legitimate user's UTMP entry for said BSD releases. NetBSD and DragonflyBSD are not touched by this malfunction. Copyright-paperwork-exempt: yes * lib/readutmp.c (desirable_utmp_entry) <READ_UTMP_CHECK_PIDS>: Use `UT_PID (u) > 0' as absolute condition.
author Mats Erik Andersson <mats.andersson@gisladisker.se>
date Wed, 05 Sep 2012 22:08:37 +0200
parents 034fed908e7d
children 995cc2e74f96
files ChangeLog lib/readutmp.c
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-09-05  Mats Erik Andersson  <gnu@gisladisker.se>  (tiny change)
+
+	readutmp: fix non-portable UT_PID use
+	* lib/readutmp.c (desirable_utmp_entry) <READ_UTMP_CHECK_PIDS>:
+	Use `UT_PID (u) > 0' as absolute condition.
+
 2012-09-04  Jim Meyering  <meyering@redhat.com>
 
 	fts: reduce two or more trailing spaces to just one, usually
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -69,8 +69,8 @@
     return false;
   if ((options & READ_UTMP_CHECK_PIDS)
       && user_proc
-      && (UT_PID (u) <= 0
-          || (kill (UT_PID (u), 0) < 0 && errno == ESRCH)))
+      && 0 < UT_PID (u)
+      && (kill (UT_PID (u), 0) < 0 && errno == ESRCH))
     return false;
   return true;
 }