X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fslocal.c;h=275eedd48d8bb7bbb1830a4b60906e15288bfdf6;hp=e5f35c0ab8ae87f473ef34bb31b11eeb01f66b1f;hb=fb49dd82ec42997b9df97f221c920f6596102c0a;hpb=ed7b16e77ac3662db77d362d15e84b69e5cd3fe6 diff --git a/uip/slocal.c b/uip/slocal.c index e5f35c0..275eedd 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. */ /* @@ -12,45 +16,55 @@ * * to their $HOME/.forward file. * - * Under MMDF-I, users should (symbolically) link - * /usr/local/nmh/lib/slocal to $HOME/bin/rcvmail. - * + */ + +/* 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 -#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 -#else -#include +/* This define is needed for Berkeley db v2 and above to + * make the header file expose the 'historical' ndbm APIs. + * We define it unconditionally because this is simple and + * harmless. + */ +#define DB_DBM_HSEARCH 1 +#ifdef NDBM_HEADER +#include NDBM_HEADER #endif #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 @@ -84,7 +98,7 @@ static struct swit switches[] = { #define VERSIONSW 13 { "version", 0 }, #define HELPSW 14 - { "help", 4 }, + { "help", 0 }, { NULL, 0 } }; @@ -443,7 +457,7 @@ localmail (int fd, char *mdlvr) static int usr_delivery (int fd, char *delivery, int su) { - int i, accept, status, won, vecp, next; + int i, accept, status=1, won, vecp, next; char *field, *pattern, *action, *result, *string; char buffer[BUFSIZ], tmpbuf[BUFSIZ]; char *cp, *vec[NVEC]; @@ -647,6 +661,8 @@ usr_delivery (int fd, char *delivery, int su) break; } + if (status) next = 0; /* action failed, mark for 'N' result */ + if (accept && status == 0) won++; } @@ -929,6 +945,36 @@ 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 ( +#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(); + return (utmped = DONE); + } + } + + endutent(); + return (utmped = NOTOK); +} +#else static int logged_in (void) { @@ -954,7 +1000,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 @@ -1142,10 +1188,6 @@ usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress) status = pidwait (child_id, 0); alarm (0); -#ifdef MMDFI - if (status == RP_MOK || status == RP_OK) - status = 0; -#endif if (verbose) { if (status == 0) verbose_printf (", success.\n");