From 56539e8eafef3e955be9d08254d61b139faf34f1 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Tue, 8 Nov 2005 20:22:33 +0000 Subject: [PATCH] Simon Burge: fix to handle getutent() on NetBSD --- ChangeLog | 3 +++ acconfig.h | 3 +++ configure.in | 9 +++++++++ uip/rcvtty.c | 10 +++++++--- uip/slocal.c | 10 +++++++--- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c50664a..e4a660e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-11-08 Oliver Kiddle + * Simon Burge: acconfig.h, configure.in, uip/rcvtty.c, uip/slocal.c: + fix to handle getutent() on NetBSD + * INSTALL, README, docs/README.about, man/nmh.man: update most references to the web page and mailing list locations diff --git a/acconfig.h b/acconfig.h index 10866bf..cedaa55 100644 --- a/acconfig.h +++ b/acconfig.h @@ -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 diff --git a/configure.in b/configure.in index 9b8c568..287875b 100644 --- a/configure.in +++ b/configure.in @@ -793,6 +793,15 @@ if test $nmh_cv_struct_tm_gmtoff = yes; then 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 ], +[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 ------------- diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 12b73e7..9b272d2 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -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); } diff --git a/uip/slocal.c b/uip/slocal.c index bbf1850..ca23fd8 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -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(); -- 1.7.10.4