]> git.marmaro.de Git - mmh/commitdiff
Rest of the MMDF-style mail drop support removal.
authormarkus schnalke <meillo@marmaro.de>
Mon, 30 Jan 2012 10:03:29 +0000 (11:03 +0100)
committermarkus schnalke <meillo@marmaro.de>
Mon, 30 Jan 2012 10:03:29 +0000 (11:03 +0100)
Only Unix-style (mbox) mail drops are supported now. Their location
is in `mailspool', which is reported in the  configure summary now.
If users like to have different locations, they can use the environment
variable MAILDROP or the profile entry MailDrop to overrule the default.
From mts.conf, mmdfldir and mmdflfil were removed.
msgchk(1) received several cleanups.
I touched sbr/m_getfld.c ... Wooohh ...

15 files changed:
config/Makefile.in
config/config.c
configure.ac
etc/mts.conf.in
h/mh.h
h/mts.h
man/conflict.man8
man/mh-tailor.man5
man/msgchk.man1
sbr/m_getfld.c
sbr/mts.c
uip/conflict.c
uip/inc.c
uip/msgchk.c
uip/slocal.c

index c1b16bd63332d80946feef687ebf05201511d7ce..da7d12ab8a1cc156cfcc7fa9393789777bc61639 100644 (file)
@@ -18,13 +18,15 @@ libdir      = @libdir@
 etcdir      = @sysconfdir@
 
 sendmailpath   = @sendmailpath@
+mailspool      = @mailspool@
 
 CC         = @CC@
 CFLAGS     = @CFLAGS@
 DEFS       = @DEFS@
 INCLUDES   = -I.. -I$(top_srcdir) @CPPFLAGS@
-CONFIGDEFS = -DNMHBINDIR='"$(bindir)"' -DNMHETCDIR='"$(etcdir)"' -DNMHLIBDIR='"$(libdir)"' \
-             -DSENDMAILPATH='"$(sendmailpath)"'
+CONFIGDEFS = -DNMHBINDIR='"$(bindir)"' -DNMHETCDIR='"$(etcdir)"' \
+               -DNMHLIBDIR='"$(libdir)"' -DSENDMAILPATH='"$(sendmailpath)"' \
+               -DMAILSPOOL='"$(mailspool)"'
 
 COMPILE  = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS)
 COMPILE2 = $(CC) -c $(DEFS) $(CONFIGDEFS) $(INCLUDES) $(CFLAGS)
index 30c95749558191d3eea3941f5c196c34915a433e..cdf8f5a737c88ac511f57110fec8597176f5c3c6 100644 (file)
@@ -217,6 +217,11 @@ char *whatnowproc = NMHBINDIR"/whatnow";
 */
 char *sendmail = SENDMAILPATH;
 
+/*
+** This is the path to the system mail spool directory (e.g. `/var/mail').
+*/
+char *mailspool = MAILSPOOL;
+
 
 /*
 ** file stuff
index 0d3dc69e86711404d66f817d330a02d7b8d8eaf5..3de6bf62ed58e5d3ec32034f45a6e1dddb85e931 100644 (file)
@@ -834,6 +834,7 @@ config install path    : ${nmhsysconf}
 man page install path  : ${nmhman}
 
 sendmail path          : ${sendmailpath}
+mail spool             : ${mailspool}
 
 file locking type      : ${LOCKTYPE}
 address masquerading   : ${masquerade}
index c5fd01c08cf9d73474218b30a8ea32407bd67cc1..65b9d1d54476ce1d7e24494f0254e6f68b240c5d 100644 (file)
@@ -8,11 +8,3 @@
 # The following directive allows email address masquerading.  The string
 # "draft_from mmailid username_extension" will allow all three types.
 masquerade: %masquerade%
-
-# Default location of mail drops.  If this option is
-# set, but empty, the user's home directory is used.
-mmdfldir: %mailspool%
-
-# The name of the maildrop file in the directory where maildrops
-# are kept.  If this is empty, the user's login name is used.
-mmdflfil:
diff --git a/h/mh.h b/h/mh.h
index 116abdb1af9c40925f1a43f3f2b4abc1bddff9bc..ef7aa034cdd25b49b30295c2fe62210bac7b1f6e 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -236,7 +236,6 @@ struct msgs {
 #define MS_DEFAULT  0    /* default (one msg per file) */
 #define MS_UNKNOWN  1    /* type not known yet         */
 #define MS_MBOX     2    /* Unix-style "from" lines    */
-#define MS_MMDF     3    /* string mmdlm2              */
 
 extern int msg_count;        /* m_getfld() indicators */
 extern int msg_style;        /*  .. */
@@ -307,6 +306,7 @@ extern char *incproc;
 extern char *lproc;
 extern char *mhetcdir;
 extern char *mailproc;
+extern char *mailspool;
 extern char *mh_seq;
 extern char *mhlformat;
 extern char *mhlforward;
diff --git a/h/mts.h b/h/mts.h
index 5ddd837ec78fca9f1bc58fd7cee407493817c97c..5092667454572c71e2db2e59ed5bb995b862a9d8 100644 (file)
--- a/h/mts.h
+++ b/h/mts.h
@@ -8,30 +8,10 @@
 char *LocalName(void);
 char *SystemName(void);
 
-/*
-** Mailboxes
-*/
-extern char *mmdfldir;
-extern char *mmdflfil;
-extern char *uucpldir;
-extern char *uucplfil;
-
-#define MAILDIR (mmdfldir && *mmdfldir ? mmdfldir : getenv("HOME"))
-#define MAILFIL (mmdflfil && *mmdflfil ? mmdflfil : getusername())
-#define UUCPDIR (uucpldir && *uucpldir ? uucpldir : getenv("HOME"))
-#define UUCPFIL (uucplfil && *uucplfil ? uucplfil : getusername())
 
 char *getusername(void);
 char *getfullname(void);
 
-/*
-** Separators
-*/
-extern char *mmdlm1;
-extern char *mmdlm2;
-
-#define isdlm1(s) (strcmp(s, mmdlm1) == 0)
-#define isdlm2(s) (strcmp(s, mmdlm2) == 0)
 
 /*
 ** Read mts.conf file
index fc2f8d7912329ba9e3e1e04f105b7dfedfc2e4fa..4df70944ad541c750e835108f22010f5d5c57eab 100644 (file)
@@ -66,7 +66,7 @@ or whenever system accounting takes place.
 ^/etc/passwd~^List of users
 ^/etc/group~^List of groups
 ^%bindir%/mhmail~^Program to send mail
-^%mailspool%/~^Directory of mail drop
+^%mailspool%/~^Directory of mail drops
 .fi
 
 .SH "PROFILE COMPONENTS"
index 8213cb74282bb460c3f11ee1eeea41c467a89900..265c3cfddf489b09f55056397efca29b68f60ef3 100644 (file)
@@ -31,21 +31,6 @@ will send messages by forking a
 local copy of
 .BR sendmail .
 .PP
-.BR mmdfldir :
-%mailspool%
-.RS 5
-The directory where maildrops are kept.  If this option is set, but empty,
-the user's home directory is used.  This overrides the default value
-chosen at the time of compilation.
-.RE
-.PP
-.BR mmdflfil :
-.RS 5
-The name of the maildrop file in the directory where maildrops are kept.
-If this is empty, the user's login name is used.  This overrides the default
-value (which is empty).
-.RE
-.PP
 .BR masquerade:
 .RS 5
 This directive controls three different types of email address masquerading.
index 1b9843b6c0ba16e6573f79f4cc1a68827492e8f8..1b58ee5c311a0eaf82c612563e29bf10bf34fb10 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH MSGCHK %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-msgchk \- check for messages
+msgchk \- check system mail drop for messages
 .SH SYNOPSIS
 .HP 5
 .na
@@ -21,11 +21,12 @@ all/mail/nomail ]
 .SH DESCRIPTION
 The
 .B msgchk
-program checks all known mail drops for mail waiting
-for you.  For those drops which have mail for you,
+program checks your system mail drop for mail waiting
+for you, or the given users.
+If the requested users have mail,
 .B msgchk
 will
-indicate if it believes that you have seen the mail in question before.
+indicate if it believes that they have seen the mail in question before.
 .PP
 The
 .B \-notify
@@ -67,13 +68,26 @@ switch directs
 .B msgchk
 to print out the last date mail was read, if this can
 be determined.
+.PP
+If
+.I users
+are given, then
+.B msgchk
+will only check the default system mail drops.
+Otherwise,
+.B msgchk
+will evaluate the environment variable
+.I MAILDROP
+and profile component
+.I MailDrop
+(in this order) first and, if they are set and non-empty,
+checks that mail drop instead of the system default mail drop.
 
 .SH FILES
 .fc ^ ~
 .nf
 .ta \w'%etcdir%/ExtraBigFileName  'u
 ^$HOME/.mmh/profile~^The user profile
-^%etcdir%/mts.conf~^nmh mts configuration file
 ^%mailspool%/$USER~^Location of mail drop
 .fi
 
@@ -81,10 +95,18 @@ be determined.
 .fc ^ ~
 .nf
 .ta 2.4i
-.ta \w'ExtraBigProfileName  'u
-None
+.ta \w'ExtraBigName  'u
+^MailDrop~^Supersedes the default mail drop location
 .fi
 
+.SH ENVIRONMENT
+.fc ^ ~
+.nf
+.ta \w'ExtraBigName  'u
+^MAILDROP~^Highest priority alternative mail drop location
+.fi
+
+
 .SH "SEE ALSO"
 inc(1)
 
index 8fd836430b4d6ef07ae9914236e95acf285e2aaa..a2dba260966f2e7f7c14a76be509b61d922739be 100644 (file)
@@ -639,15 +639,14 @@ m_unknown(FILE *iob)
 **
 ** If the first line of the maildrop is a Unix "From " line, we
 ** say the style is MBOX and eat the rest of the line.  Otherwise
-** we say the style is MMDF and look for the delimiter string
-** specified when nmh was built (or from the mts.conf file).
+** abort.
 */
 
        msg_style = MS_UNKNOWN;
 
        pos = ftell(iob);
        if (fread(text, sizeof(*text), 5, iob) == 5
-               && strncmp(text, "From ", 5) == 0) {
+                       && strncmp(text, "From ", 5) == 0) {
                msg_style = MS_MBOX;
                delimstr = "\nFrom ";
 #ifndef RPATHS
@@ -661,11 +660,7 @@ m_unknown(FILE *iob)
 #endif /* RPATHS */
        } else {
                /* not a Unix style maildrop */
-               fseek(iob, pos, SEEK_SET);
-               if (mmdlm2 == NULL || *mmdlm2 == 0)
-                       mmdlm2 = "\001\001\001\001\n";
-               delimstr = mmdlm2;
-               msg_style = MS_MMDF;
+               adios(NULL, "No Unix style (mbox) maildrop.");
        }
        c = strlen(delimstr);
        fdelim = (unsigned char *) mh_xmalloc((size_t) (c + 3));
@@ -689,14 +684,6 @@ m_unknown(FILE *iob)
 
        for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++ )
                pat_map[(unsigned char)*cp] = (unsigned char *) cp;
-
-       if (msg_style == MS_MMDF) {
-               /* flush extra msg hdrs */
-               while ((c = getc(iob)) >= 0 && eom(c, iob))
-                       ;
-               if (c >= 0)
-                       ungetc(c, iob);
-       }
 }
 
 
index a3ea0f812fddd66f98fbda1b75dd4bd551319d95..2830bb70eef997025e70f76de7b7368189ce873c 100644 (file)
--- a/sbr/mts.c
+++ b/sbr/mts.c
@@ -31,26 +31,11 @@ static const char *get_mtsconf_pathname(void);
 static const char *get_mtsuserconf_pathname(void);
 static void mts_read_conf_file(FILE *fp);
 
-/*
-** *mmdfldir and *uucpldir are the maildrop directories.  If maildrops
-** are kept in the user's home directory, then these should be empty
-** strings.  In this case, the appropriate ...lfil array should contain
-** the name of the file in the user's home directory.  Usually, this is
-** something like ".mail".
-*/
-
 /*
 ** nmh mail transport interface customization file
 */
 static char *mtsconf = NMHETCDIR"/mts.conf";
 
-char *mmdfldir = MAILSPOOL;
-char *mmdflfil = "";
-char *uucpldir = "/usr/spool/mail";
-char *uucplfil = "";
-
-char *mmdlm1 = "\001\001\001\001\n";
-char *mmdlm2 = "\001\001\001\001\n";
 
 /* Cache the username and fullname of the user */
 static char username[BUFSIZ];
@@ -86,10 +71,6 @@ struct bind {
 };
 
 static struct bind binds[] = {
-       { "mmdfldir", &mmdfldir },
-       { "mmdflfil", &mmdflfil },
-       { "uucpldir", &uucpldir },
-       { "uucplfil", &uucplfil },
        { "masquerade", &masquerade },
        { "maildelivery", &maildelivery },
        { "everyone", &everyone },
index 4251ab2d689a5900eb6c49c6bdcefbe060d50e25..527dd11332a1d0f4b2f42fd425a23d6db1d3f87d 100644 (file)
@@ -283,10 +283,7 @@ maildrops(void)
 {
        register int i;
 
-       if (mmdfldir && *mmdfldir)
-               mdrop(mmdfldir);
-       if (uucpldir && *uucpldir)
-               mdrop(uucpldir);
+       mdrop(mailspool);
        for (i = 0; dirs[i]; i++)
                mdrop(dirs[i]);
 }
index e3199c048e4355c6028d89a1134ef1c7c5c27517..f000d4767187fa655a7e15c03ee0778565a6fdd2 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -288,7 +288,7 @@ main(int argc, char **argv)
        else if ((newmail = context_find("maildrop")) && *newmail)
                newmail = toabsdir(newmail);
        else {
-               newmail = concat(MAILDIR, "/", MAILFIL, NULL);
+               newmail = concat(mailspool, "/", getusername(), NULL);
        }
        if (stat(newmail, &s1) == NOTOK || s1.st_size == 0)
                adios(NULL, "no mail to incorporate");
index 36edccb4e0499457907b766f6273bad6a35db456..5b75814c2b28a0799b5f8ca1ade8b51c9451a113 100644 (file)
@@ -38,19 +38,16 @@ static struct swit switches[] = {
 #define NT_ALL   (NT_MAIL | NT_NMAI)
 
 #define NONEOK   0x0
-#define UUCPOLD  0x1
-#define UUCPNEW  0x2
-#define UUCPOK   (UUCPOLD | UUCPNEW)
-#define MMDFOLD  0x4
-#define MMDFNEW  0x8
-#define MMDFOK   (MMDFOLD | MMDFNEW)
+#define MAILOLD  0x4
+#define MAILNEW  0x8
+#define MAILOK   (MAILOLD | MAILNEW)
 
 
 /*
 ** static prototypes
 */
 static int donote(char *, int);
-static int checkmail(char *, char *, int, int, int);
+static int checkmail(char *, int, int, int);
 
 
 int
@@ -59,7 +56,6 @@ main(int argc, char **argv)
        int datesw = 1, notifysw = NT_ALL;
        int status = 0;
        int vecp = 0;
-       uid_t uid;
        char buf[BUFSIZ];
        char *user, *cp;
        char **argp, **arguments, *vec[MAXVEC];
@@ -74,7 +70,6 @@ main(int argc, char **argv)
        context_read();
 
        mts_init(invo_name);
-       uid = getuid();
        user = getusername();
 
        arguments = getarguments(invo_name, argc, argv, 1);
@@ -125,30 +120,18 @@ main(int argc, char **argv)
                        vec[vecp++] = cp;
        }
 
-       if (vecp != 0)
-               vec[vecp] = NULL;
-
-       if (vecp == 0) {
-               char *home;
-
-               /* Not sure this check makes sense... */
-               if (!geteuid() || NULL == (home = getenv("HOME"))) {
-                       pw = getpwnam(user);
-                       if (pw == NULL)
-                               adios(NULL, "unable to get information about user");
-                       home = pw->pw_dir;
-               }
-               status = checkmail(user, home, datesw, notifysw, 1);
-       } else {
-               for (vecp = 0; vec[vecp]; vecp++) {
-                       if ((pw = getpwnam(vec[vecp])))
-                               status += checkmail(pw->pw_name, pw->pw_dir,
-                                               datesw, notifysw, 0);
-                       else
-                               advise(NULL, "no such user as %s", vec[vecp]);
-               }
+       if (!vecp) {
+               done(checkmail(user, datesw, notifysw, 1));
+               return 1;
        }
 
+       vec[vecp] = NULL;
+       for (vecp = 0; vec[vecp]; vecp++) {
+               if ((pw = getpwnam(vec[vecp])))
+                       status += checkmail(pw->pw_name, datesw, notifysw, 0);
+               else
+                       advise(NULL, "no such user as %s", vec[vecp]);
+       }
        done(status);
        return 1;
 }
@@ -189,55 +172,72 @@ donote(char *cp, int ntflag)
 
 
 static int
-checkmail(char *user, char *home, int datesw, int notifysw, int personal)
+checkmail(char *user, int datesw, int notifysw, int personal)
 {
        int mf, status;
        char buffer[BUFSIZ];
        struct stat st;
-
-       snprintf(buffer, sizeof(buffer), "%s/%s",
-                       mmdfldir[0] ? mmdfldir : home,
-                       mmdflfil[0] ? mmdflfil : user);
+       char *maildrop;
+
+       if (personal) {
+               /*
+               ** Evaluate the env var and profile only if the check is
+               ** for the calling user.
+               */
+               if ((maildrop = getenv("MAILDROP")) && *maildrop) {
+                       snprintf(buffer, sizeof buffer, "%s",
+                                       toabsdir(maildrop));
+               } else if ((maildrop=context_find("maildrop")) && *maildrop) {
+                       snprintf(buffer, sizeof buffer, "%s",
+                                       toabsdir(maildrop));
+               } else {
+                       snprintf(buffer, sizeof buffer, "%s/%s",
+                                       mailspool, user);
+               }
+       } else {
+               snprintf(buffer, sizeof(buffer), "%s/%s", mailspool, user);
+       }
        if (datesw) {
                st.st_size = 0;
                st.st_atime = st.st_mtime = 0;
        }
        mf = (stat(buffer, &st) == NOTOK || st.st_size == 0) ? NONEOK
-               : st.st_atime <= st.st_mtime ? MMDFNEW : MMDFOLD;
+               : st.st_atime <= st.st_mtime ? MAILNEW : MAILOLD;
 
-       if ((mf & UUCPOK) || (mf & MMDFOK)) {
+       if (mf & MAILOK) {
                if (notifysw & NT_MAIL) {
-                       printf(personal ? "You have " : "%s has ", user);
-                       if (mf & UUCPOK)
-                               printf("%s old-style bell",
-                                               mf & UUCPOLD ? "old" : "new");
-                       if ((mf & UUCPOK) && (mf & MMDFOK))
-                               printf(" and ");
-                       if (mf & MMDFOK)
-                               printf("%s%s", mf & MMDFOLD ? "old" : "new",
-                                               mf & UUCPOK ? " Internet" : "");
+                       if (personal) {
+                               printf("You have ");
+                       } else {
+                               printf("%s has ", user);
+                       }
+                       if (mf & MAILOK)
+                               printf(mf & MAILOLD ? "old" : "new");
                        printf(" mail waiting");
                } else {
                        notifysw = 0;
                }
                status = 0;
-       }
-       else {
-               if (notifysw & NT_NMAI)
-                       printf(personal ? "You don't %s%s" : "%s doesn't %s",
-                                       personal ? "" : user,
-                                       "have any mail waiting");
-               else
+       } else {
+               if (notifysw & NT_NMAI) {
+                       if (personal) {
+                               printf("You don't have any mail waiting");
+                       } else {
+                               printf("%s doesn't have any mail waiting",
+                                               user);
+                       }
+               } else {
                        notifysw = 0;
-
+               }
                status = 1;
        }
 
-       if (notifysw)
-               if (datesw && st.st_atime)
+       if (notifysw) {
+               if (datesw && st.st_atime) {
                        printf("; last read on %s", dtime(&st.st_atime, 1));
-       if (notifysw)
+               }
                printf("\n");
+       }
 
        return status;
 }
index a81afa90eda8fabd305ac535a446c7bc4b2fdc68..7b148e8c48fb116486f72d9b4dd4ec411ca49c16 100644 (file)
@@ -405,8 +405,7 @@ main(int argc, char **argv)
 
        if (mbox == NULL) {
                snprintf(mailbox, sizeof(mailbox), "%s/%s",
-                               mmdfldir[0] ? mmdfldir : pw->pw_dir,
-                               mmdflfil[0] ? mmdflfil : pw->pw_name);
+                               mailspool, pw->pw_name);
                mbox = mailbox;
        }
        if (home == NULL)