On Wed, Mar 30, 2005 at 12:31:06AM -0500, Paul Eggert wrote:
> You're welcome. I installed the following slightly-modified patch:
> it updates m4/readutmp.m4 as well, and it adds another check for
> size_t overflow.
>
> 2005-03-30 Paul Eggert <[EMAIL PROTECTED]>
>
> * lib/readutmp.h (read_utmp): New arg OPTIONS. All uses changed.
> * lib/readutmp.c: Likewise. Include signal.h, stdbool.h.
> (desirable_utmp_entry): New function.
> (read_utmp) [defined UTMP_NAME_FUNCTION]: Redo memory allocation
> using x2nrealloc, to simplify logic.
> (read_utmp) [!defined UTMP_NAME_FUNCTION]: Check for overflow in
> size calculation.
> * lib/readutmp.h (UT_PID): Moved here from ../src/who.c.
> (READ_UTMP_CHECK_PIDS): New constant.
I had a bug report that 'who -b' and 'who -r' fail to give output with
this patch. This fixes it:
--- coreutils-5.2.1/lib/readutmp.c 2005-04-08 17:44:56.000000000 +0100
+++ coreutils-5.2.1/lib/readutmp.c 2005-06-22 13:56:54.000000000 +0100
@@ -60,7 +60,22 @@
static inline bool
desirable_utmp_entry (STRUCT_UTMP const *u, int options)
{
+#define UT_TYPE_UNDEF 255
+
+#if HAVE_STRUCT_XTMP_UT_TYPE
+# define UT_TYPE(U) ((U)->ut_type)
+#else
+# define UT_TYPE(U) UT_TYPE_UNDEF
+#endif
+
+#define IS_USER_PROCESS(U) \
+ (UT_USER (U)[0] \
+ && (UT_TYPE (U) == USER_PROCESS \
+ || (UT_TYPE (U) == UT_TYPE_UNDEF \
+ && UT_TIME_MEMBER (U) != 0)))
+
return ! (options & READ_UTMP_CHECK_PIDS
+ && IS_USER_PROCESS (u)
&& (UT_PID (u) <= 0
|| (kill (UT_PID (u), 0) < 0 && errno == ESRCH)));
}
Tim.
*/
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils