Here's a patch that gets getutent() support working on NetBSD (and
possibly some other operating systems). Changes to the existing code
are:
- Not all struct utmp includes a ut_type member. Test for that in
autoconf.
- Use "ut_name" instead of "ut_user". It seems that ut_name is the
older structure name for the username, but Linux provides a #define
for backwards compatibility. Instead of checking for ut_user and/or
ut_name in autoconf, just use ut_name everywhere.
Cheers,
Simon.
--
Simon Burge <[EMAIL PROTECTED]>
NetBSD Development, Support and Service: http://www.wasabisystems.com/
Index: acconfig.h
===================================================================
RCS file: /cvsroot/nmh/nmh/acconfig.h,v
retrieving revision 1.22
diff -d -p -u -r1.22 acconfig.h
--- acconfig.h 22 Dec 2000 23:42:16 -0000 1.22
+++ acconfig.h 14 Oct 2004 11:19:26 -0000
@@ -260,6 +260,9 @@
/* Define to 1 if struct tm has gmtoff */
#undef HAVE_TM_GMTOFF
+/* Define to 1 if struct utmp has ut_type */
+#undef HAVE_UTMP_UT_TYPE
+
/* Define if your system has sigsetjmp */
#undef HAVE_SIGSETJMP
Index: configure.in
===================================================================
RCS file: /cvsroot/nmh/nmh/configure.in,v
retrieving revision 1.65
diff -d -p -u -r1.65 configure.in
--- configure.in 6 Oct 2003 20:11:54 -0000 1.65
+++ configure.in 14 Oct 2004 11:19:26 -0000
@@ -746,6 +746,15 @@ if test $nmh_cv_struct_tm_gmtoff = yes;
AC_DEFINE(HAVE_TM_GMTOFF)
fi
+AC_CACHE_CHECK(for ut_type in struct utmp, nmh_cv_struct_utmp_ut_type,
+[AC_TRY_COMPILE(
+[#include <utmp.h>],
+[struct utmp temputmp; temputmp.ut_type = 0;],
+ nmh_cv_struct_utmp_ut_type=yes, nmh_cv_struct_utmp_ut_type=no)])
+if test $nmh_cv_struct_utmp_ut_type = yes; then
+ AC_DEFINE(HAVE_UTMP_UT_TYPE)
+fi
+
dnl -------------
dnl CHECK SIGNALS
dnl -------------
Index: uip/rcvtty.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/rcvtty.c,v
retrieving revision 1.12
diff -d -p -u -r1.12 rcvtty.c
--- uip/rcvtty.c 2 Jul 2002 22:09:15 -0000 1.12
+++ uip/rcvtty.c 14 Oct 2004 11:19:26 -0000
@@ -176,10 +176,14 @@ main (int argc, char **argv)
#ifdef HAVE_GETUTENT
setutent();
while ((utp = getutent()) != NULL) {
- if (utp->ut_type == USER_PROCESS
- && utp->ut_user[0] != 0
+ if (
+#ifdef HAVE_UTMP_UT_TYPE
+ utp->ut_type == USER_PROCESS
+ &&
+#endif
+ utp->ut_name[0] != 0
&& utp->ut_line[0] != 0
- && strncmp (user, utp->ut_user, sizeof(utp->ut_user)) == 0) {
+ && strncmp (user, utp->ut_name, sizeof(utp->ut_name)) == 0) {
strncpy (tty, utp->ut_line, sizeof(utp->ut_line));
alert (tty, md);
}
Index: uip/slocal.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/slocal.c,v
retrieving revision 1.17
diff -d -p -u -r1.17 slocal.c
--- uip/slocal.c 6 Oct 2003 20:11:39 -0000 1.17
+++ uip/slocal.c 14 Oct 2004 11:19:27 -0000
@@ -965,9 +965,13 @@ logged_in (void)
setutent();
while ((utp = getutent()) != NULL) {
- if (utp->ut_type == USER_PROCESS
- && utp->ut_user[0] != 0
- && strncmp (user, utp->ut_user, sizeof(utp->ut_user)) == 0) {
+ if (
+#ifdef HAVE_UTMP_UT_TYPE
+ utp->ut_type == USER_PROCESS
+ &&
+#endif
+ utp->ut_name[0] != 0
+ && strncmp (user, utp->ut_name, sizeof(utp->ut_name)) == 0) {
if (debug)
continue;
endutent();
_______________________________________________
Nmh-workers mailing list
[EMAIL PROTECTED]
http://lists.nongnu.org/mailman/listinfo/nmh-workers