From b6182322a5b14bb9441f901c211ef8a6dd08caf1 Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Sat, 6 Aug 1994 04:08:05 +0000 Subject: [PATCH] hack up utmp stuff git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4054 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/kpasswd/configure.in | 11 +++++++++++ src/kadmin/kpasswd/networked.c | 30 ++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/kadmin/kpasswd/configure.in b/src/kadmin/kpasswd/configure.in index dbd80c44b..b22149507 100644 --- a/src/kadmin/kpasswd/configure.in +++ b/src/kadmin/kpasswd/configure.in @@ -5,6 +5,17 @@ AC_SET_BUILDTOP AC_PROG_INSTALL AC_HAVE_LIBRARY(socket) AC_HAVE_LIBRARY(nsl) +AC_COMPILE_CHECK([ut_pid in struct utmp], +[#include ], +[struct utmp ut; ut.ut_pid;], +, +AC_DEFINE(NO_UT_PID)) +AC_COMPILE_CHECK([ut_type in struct utmp], +[#include ], +[struct utmp ut; ut.ut_type;], +, +AC_DEFINE(NO_UT_TYPE)) +AC_FUNC_CHECK(getutent,AC_DEFINE(HAVE_GETUTENT)) ET_RULES KRB_INCLUDE ISODE_INCLUDE diff --git a/src/kadmin/kpasswd/networked.c b/src/kadmin/kpasswd/networked.c index 3ddd0ffa5..18a3269a6 100644 --- a/src/kadmin/kpasswd/networked.c +++ b/src/kadmin/kpasswd/networked.c @@ -46,20 +46,18 @@ #define MAXHOSTNAME 64 #endif -int utfile; /* Global utfile file descriptor for BSD version - of setutent, getutline, and endutent */ +#if defined(HAVE_GETUTENT) && !defined(NO_UT_PID) + +static int utfile; -#if !defined(SYSV) && !defined(UMIPS) /* Setutent, Endutent, and getutline - routines for non System V Unix - systems */ #include -void setutent() +static void kadmin_setutent() { utfile = open("/etc/utmp",O_RDONLY); } -struct utmp * getutline(utmpent) +static struct utmp * kadmin_getutline(utmpent) struct utmp *utmpent; { static struct utmp tmputmpent; @@ -81,11 +79,15 @@ struct utmp *utmpent; return((struct utmp *) 0); } -void endutent() +static void kadmin_endutent() { close(utfile); } -#endif /* not SYSV */ +#else +#define kadmin_setutent setutent +#define kadmin_getutline getutline +#define kadmin_endutent endutent +#endif /* defined(HAVE_GETUTENT) && !defined(NO_UT_PID) */ int network_connected() @@ -117,12 +119,12 @@ char *username,*tmpname; /* See if this device is currently listed in /etc/utmp under calling user */ -#ifdef SYSV +#ifndef NO_UT_TYPE utmpent.ut_type = USER_PROCESS; #define ut_name ut_user #endif - setutent(); - while ( (tmpptr = (struct utmp *) getutline(&utmpent)) + kadmin_setutent(); + while ( (tmpptr = (struct utmp *) kadmin_getutline(&utmpent)) != ( struct utmp *) 0) { /* If logged out name and host will be empty */ @@ -135,11 +137,11 @@ char *username,*tmpname; else break; } if ( tmpptr == (struct utmp *) 0) { - endutent(); + kadmin_endutent(); return(1); } byte_copy((char *)tmpptr,(char *)&retutent,sizeof(struct utmp)); - endutent(); + kadmin_endutent(); #ifdef DEBUG #ifdef NO_UT_HOST printf("User %s on line %s :\n", -- 2.26.2