X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fslocal.c;h=74f1b57e8c87fd343913b7d8b3b574b76e926a15;hp=b665280bbb32717bea0aced2629e262e0085706a;hb=6c42153ad9362cc676ea66563bf400d7511b3b68;hpb=017a82124bf2ea39ced5aa4c8f969c18b3c2fb90 diff --git a/uip/slocal.c b/uip/slocal.c index b665280..74f1b57 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -3,6 +3,10 @@ * slocal.c -- asynchronously filter and deliver new mail * * $Id$ + * + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ /* @@ -17,26 +21,33 @@ * */ +/* 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 #include -#include -#include +#include +#include #include #include #include #include -#include /* initgroups() is here on Solaris 2.6 */ -#include /* initgroups() is here on HP-UX 10.20 */ - +#ifdef INITGROUPS_HEADER +#include INITGROUPS_HEADER +#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. On other OSes, this should be a duplicate prototype - that won't cause any errors or warnings. */ -extern int initgroups(const char*, gid_t); + types as char* and int), but doesn't have a prototype in any of the system + header files. AIX 4.3, SunOS 4.1.3, and ULTRIX 4.2A have the same + problem. */ +extern int initgroups(char*, int); +#endif + #ifdef HAVE_DB1_NDBM_H #include @@ -46,11 +57,13 @@ extern int initgroups(const char*, gid_t); #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 @@ -929,6 +942,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) { @@ -954,7 +993,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