X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fslocal.c;h=acbdf2e47ab15c44dc258d5385bdc2c5cb31686f;hb=522138c8d86c20435f045eaee0944a9b008b1c5a;hp=e12b940e26e1c7c677625e4abbbe2103664623c2;hpb=b1450ec537bd31be606633aa363201cc2ed95b9a;p=mmh diff --git a/uip/slocal.c b/uip/slocal.c index e12b940..acbdf2e 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -17,6 +17,11 @@ * */ +/* Changed to use getutent() and friends. Assumes that when getutent() exists, + * a number of other things also exist. Please check. + * Ruud de Rooij Sun, 28 May 2000 17:28:55 +0200 + */ + #include #include #include @@ -34,7 +39,8 @@ #else /* On AIX 4.1, initgroups() is defined and even documented (giving the parameter types as char* and int), but doesn't have a prototype in any of the system - header files. AIX 4.3 and SunOS 4.1.3 have the same problem. */ + header files. AIX 4.3, SunOS 4.1.3, and ULTRIX 4.2A have the same + problem. */ extern int initgroups(char*, int); #endif @@ -47,11 +53,13 @@ extern int initgroups(char*, int); #include -#ifndef UTMP_FILE -# ifdef _PATH_UTMP -# define UTMP_FILE _PATH_UTMP -# else -# define UTMP_FILE "/etc/utmp" +#ifndef HAVE_GETUTENT +# ifndef UTMP_FILE +# ifdef _PATH_UTMP +# define UTMP_FILE _PATH_UTMP +# else +# define UTMP_FILE "/etc/utmp" +# endif # endif #endif @@ -930,6 +938,32 @@ lookup (struct pair *pairs, char *key) * logged in. */ +#ifdef HAVE_GETUTENT +static int +logged_in (void) +{ + struct utmp * utp; + + if (utmped) + return utmped; + + 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 (debug) + continue; + endutent(); + return (utmped = DONE); + } + } + + endutent(); + return (utmped = NOTOK); +} +#else static int logged_in (void) { @@ -955,7 +989,7 @@ logged_in (void) fclose (uf); return (utmped = NOTOK); } - +#endif #define check(t,a,b) if (t < a || t > b) return -1 #define cmpar(h1,m1,h2,m2) if (h1 < h2 || (h1 == h2 && m1 < m2)) return 0