is not world- or user-writeable, and thus a lock file cannot
be created.
---with-ndbm=LIB (DEFAULT is to autodetect)
---with-ndbmheader=HEADER (DEFAULT is to autodetect)
- Specify the header file (eg ndbm.h) and library (eg ndbm) to use
- to compile against the ndbm database library. By default, configure
- will try various possibilities until it finds one that works; this
- option only needs to be specified if the autodetection fails or
- makes the wrong choice.
-
- If either of these options is given then the other must also be
- specified.
--
markus schnalke <meillo@marmaro.de>
AC_SEARCH_LIBS([connect], [socket], , [AC_MSG_ERROR([connect not found])])
])dnl
-dnl --------------
-dnl CHECK FOR NDBM
-dnl --------------
-dnl
-dnl NMH_CHECK_DBM(include,library,action-if-found,action-if-not)
-
-dnl Check for presence of dbm_open() in the specified library
-dnl and with the specified include file (if libname is the empty
-dnl string then don't try to link against any particular library).
-
-dnl We set nmh_ndbm_found to 'yes' or 'no'; if found we set
-dnl nmh_ndbmheader to the first arg and nmh_ndbm to the second.
-
-dnl If this macro accepted a list of include,library tuples
-dnl to test in order that would be cleaner than the current
-dnl nest of calls in configure.ac.
-
-dnl We try to link our own code fragment (which includes the
-dnl headers in the same way slocal.c does) rather than
-dnl using AC_CHECK_LIB because on later versions of libdb
-dnl the dbm_open() function is provided via a #define and
-dnl we don't want to hardcode searching for the internal
-dnl function that lies behind it. (AC_CHECK_LIB works by
-dnl defining its own bogus prototype rather than pulling in
-dnl the right header files.)
-
-dnl An oddity (bug) of this macro is that if you haven't
-dnl done AC_PROG_CC or something that implies it before
-dnl using this macro autoconf complains about a recursive
-dnl expansion.
-
-AC_DEFUN(NMH_CHECK_NDBM,
-[
-if test "x$2" = "x"; then
- nmh_libs=
- AC_MSG_CHECKING([for dbm in $1])
-else
- nmh_libs="-l$2 "
- AC_MSG_CHECKING([for dbm in $1 and $2])
-fi
-
-dnl We don't try to cache the result, because that exceeds
-dnl my autoconf skills -- feel free to put it in :-> -- PMM
-
-nmh_saved_libs="$LIBS"
-LIBS="$nmh_libs $5 $LIBS"
-AC_LINK_IFELSE(AC_LANG_PROGRAM([[
-#define DB_DBM_HSEARCH 1
-#include <$1>
-]],
-[[dbm_open("",0,0);]]),[nmh_ndbm_found=yes],[nmh_ndbm_found=no])
-LIBS="$nmh_saved_libs"
-
-if test "$nmh_ndbm_found" = "yes"; then
- AC_MSG_RESULT(yes)
- nmh_ndbmheader="$1"
- nmh_ndbm="$2"
- $3
-else
- AC_MSG_RESULT(no)
- $4
- :
-fi
-])dnl
-
dnl ----------------
dnl CHECK FOR d_type
dnl ----------------
[Define as const if the declaration of iconv() needs const.])
fi
-dnl --------------
-dnl CHECK FOR NDBM
-dnl --------------
-
-AC_ARG_WITH([ndbm],AS_HELP_STRING([--with-ndbm=ARG],[use -lARG to link with ndbm]),
- [nmh_ndbm=$withval],[nmh_ndbm=autodetect])
-AC_ARG_WITH([ndbmheader],AS_HELP_STRING([--with-ndbmheader=ARG],[#include <ARG> to use ndbm]),
- [nmh_ndbmheader=$withval],[nmh_ndbmheader=autodetect])
-
-if test "$nmh_ndbm" = "autodetect"; then
- if test "$nmh_ndbmheader" != "autodetect"; then
- AC_MSG_ERROR([must specify both --with-ndbm and --with-ndbmheader or neither])
- else
-
- dnl There are at least four implementations of ndbm, and
- dnl several of those can be in different places at the whim
- dnl of the system integrator. A good summary of this mess
- dnl can be found at http://www.unixpapa.com/incnote/dbm.html
-
- dnl Classic ndbm with no library required (eg NetBSD): try this
- dnl first so we don't accidentally link in a pointless but harmless
- dnl library in one of the later ndbm.h+libfoo tests:
- NMH_CHECK_NDBM(ndbm.h,,,
- dnl Berkeley DBv2 emulating ndbm: header in db.h:
- NMH_CHECK_NDBM(db.h,db,,
- dnl Berkeley DBv1 emulating ndbm:
- NMH_CHECK_NDBM(ndbm.h,db,,
- NMH_CHECK_NDBM(ndbm.h,db1,,
- dnl Classic ndbm:
- NMH_CHECK_NDBM(ndbm.h,ndbm,,
- dnl glibc2.1 systems put db1 in a subdir:
- NMH_CHECK_NDBM(db1/ndbm.h,db1,,
- dnl GNU gdbm emulating ndbm, with header possibly in gdbm/
- dnl and possibly needing gbdm_compat library:
- NMH_CHECK_NDBM(gdbm/ndbm.h,gdbm,,
- NMH_CHECK_NDBM(gdbm/ndbm.h,gdbm_compat -lgdbm,,
- NMH_CHECK_NDBM(ndbm.h,gdbm,,
- NMH_CHECK_NDBM(ndbm.h,gdbm_compat -lgdbm))))))))))
-
- fi
-else
- dnl We don't really need to check that the user-specified values work,
- dnl but it is a convenience to the user to bomb out early rather than
- dnl after configure and half the compile process.
- NMH_CHECK_NDBM([$nmh_ndbmheader],[$nmh_ndbm])
-fi
-
-if test "$nmh_ndbm_found" = "no"; then
- AC_MSG_ERROR([could not find a working ndbm library/header combination])
-else
- dnl Now export the lib/header to our makefile/config.h:
- if test x"$nmh_ndbmheader" != x; then
- AC_DEFINE_UNQUOTED(NDBM_HEADER, <$nmh_ndbmheader>,
- [Define to the header containing the ndbm API prototypes.])
- fi
- if test x"$nmh_ndbm" != x; then
- NDBM_LIBS="-l$nmh_ndbm"
- else
- NDBM_LIBS=
- fi
- AC_SUBST(NDBM_LIBS)
-fi
-
dnl ---------------------
dnl CHECK TERMCAP LIBRARY
.RB [ \-maildelivery
.IR deliveryfile ]
.RB [ \-verbose " | " \-noverbose ]
-.RB [ \-suppressdup " | " \-nosuppressdup ]
.RB [ \-debug ]
.RB [ \-version ]
.RB [ \-help ]
.RB [ \-maildelivery
.IR deliveryfile ]
.RB [ \-verbose " | " \-noverbose ]
-.RB [ \-suppressdup " | " \-nosuppressdup ]
.RB [ \-debug ]
.RB [ \-version ]
.RB [ \-help ]
.B slocal
the name of the user's maildrop file.
.PP
-.B slocal
-is able to detect and suppress duplicate messages.
-To enable this, use the option
-.BR \-suppressdup .
-.B slocal
-will
-keep a database containing the Message-ID's of incoming messages,
-in order to detect duplicates. Depending on your configuration,
-this database will be in either ndbm or Berkeley db format.
-.PP
The
.B \-info
switch may be used to pass an arbitrary argument to
.SH DEFAULTS
.nf
.RB ` \-noverbose '
-.RB ` \-nosuppressdup '
.RB ` \-maildelivery "' defaults to $HOME/\&.maildelivery"
.RB ` \-mailbox "' deaults to %mailspool%/$USER"
.RB ` \-file "' defaults to stdin"
.B RP_MECH
(200), which means
\*(lquse an alternate route\*(rq (deliver the message to the maildrop).
+.PP
+The `suppress duplicates' function had been removed from slocal for
+simplicity reasons.
.SH BUGS
Only two return codes are meaningful, others should be.
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
-NDBM_LIBS = @NDBM_LIBS@
LOCALLIBS = ../config/version.o ../config/config.o ../sbr/libmh.a
LINKLIBS = $(LOCALLIBS) $(LIBS)
$(COMPILE2) $(srcdir)/slocal.c
slocal: slocal.o aliasbr.o dropsbr.o $(LOCALLIBS)
- $(LINK) slocal.o aliasbr.o dropsbr.o $(NDBM_LIBS) $(LINKLIBS)
+ $(LINK) slocal.o aliasbr.o dropsbr.o $(LINKLIBS)
sortm: sortm.o $(LOCALLIBS)
$(LINK) sortm.o $(LINKLIBS)
extern int initgroups(char*, int);
#endif
-/*
-** 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 <utmp.h>
#ifndef HAVE_GETUTENT
{ "verbose", 0 },
#define NVERBSW 9
{ "noverbose", 0 },
-#define SUPPRESSDUP 10
- { "suppressdup", 0 },
-#define NSUPPRESSDUP 11
- { "nosuppressdup", 0 },
-#define DEBUGSW 12
+#define DEBUGSW 10
{ "debug", 0 },
-#define VERSIONSW 13
+#define VERSIONSW 11
{ "version", 0 },
-#define HELPSW 14
+#define HELPSW 12
{ "help", 0 },
{ NULL, 0 }
};
static int globbed = 0; /* have we built "vars" table yet? */
static int parsed = 0; /* have we built header field table yet */
static int utmped = 0; /* have we scanned umtp(x) file yet */
-static int suppressdup = 0; /* are we suppressing duplicate messages? */
static int verbose = 0;
static int debug = 0;
static void verbose_printf(char *fmt, ...);
static void adorn(char *, char *, ...);
static void debug_printf(char *fmt, ...);
-static int suppress_duplicates(int, char *);
static char *trim(char *);
verbose = 0;
continue;
- case SUPPRESSDUP:
- suppressdup++;
- continue;
- case NSUPPRESSDUP:
- suppressdup = 0;
- continue;
case DEBUGSW:
debug++;
continue;
static int
localmail(int fd, char *mdlvr)
{
- /* check if this message is a duplicate */
- if (suppressdup && suppress_duplicates(fd, mdlvr ?
- mdlvr : ".maildelivery") == DONE)
- return 0;
-
/* delivery according to personal Maildelivery file */
if (usr_delivery(fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1)
return 0;
vfprintf(stderr, fmt, ap);
va_end(ap);
}
-
-
-/*
-** Check ndbm/db file(s) to see if the Message-Id of this
-** message matches the Message-Id of a previous message,
-** so we can discard it. If it doesn't match, we add the
-** Message-Id of this message to the ndbm/db file.
-*/
-static int
-suppress_duplicates(int fd, char *file)
-{
- int fd1, lockfd, state, result;
- char *cp, buf[BUFSIZ], name[NAMESZ];
- datum key, value;
- DBM *db;
- FILE *in;
-
- if ((fd1 = dup(fd)) == -1)
- return -1;
- if (!(in = fdopen(fd1, "r"))) {
- close(fd1);
- return -1;
- }
- rewind(in);
-
- for (state = FLD;;) {
- state = m_getfld(state, name, buf, sizeof(buf), in);
- switch (state) {
- case FLD:
- case FLDPLUS:
- case FLDEOF:
- /* Search for the message ID */
- if (mh_strcasecmp(name, "Message-ID")) {
- while (state == FLDPLUS)
- state = m_getfld(state, name, buf,
- sizeof(buf), in);
- continue;
- }
-
- cp = getcpy(buf);
- while (state == FLDPLUS) {
- state = m_getfld(state, name, buf,
- sizeof(buf), in);
- cp = add(buf, cp);
- }
- key.dptr = trimcpy(cp);
- key.dsize = strlen(key.dptr) + 1;
- free(cp);
- cp = key.dptr;
-
- if (!(db = dbm_open(file, O_RDWR | O_CREAT, 0600))) {
- advise(file, "unable to perform dbm_open on");
- free(cp);
- fclose(in);
- return -1;
- }
- /*
- ** Since it is difficult to portable lock a ndbm
- ** file, we will open and lock the Maildelivery
- ** file instead. This will fail if your Maildelivery
- ** file doesn't exist.
- */
- if ((lockfd = lkopen(file, O_RDWR, 0)) == -1) {
- advise(file, "unable to perform file locking on");
- free(cp);
- fclose(in);
- return -1;
- }
- value = dbm_fetch(db, key);
- if (value.dptr) {
- if (verbose)
- verbose_printf("Message-ID: %s\n already received on %s", cp, value.dptr);
- result = DONE;
- } else {
- value.dptr = ddate + sizeof("Delivery-Date:");
- value.dsize = strlen(value.dptr) + 1;
- if (dbm_store(db, key, value, DBM_INSERT))
- advise(file, "possibly corrupt file");
- result = 0;
- }
-
- dbm_close(db);
- lkclose(lockfd, file);
- free(cp);
- fclose(in);
- return result;
- break;
-
- case BODY:
- case BODYEOF:
- case FILEEOF:
- break;
-
- case LENERR:
- case FMTERR:
- default:
- break;
- }
-
- break;
- }
-
- fclose(in);
- return 0;
-}