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)
*/
char *sendmail = SENDMAILPATH;
+/*
+** This is the path to the system mail spool directory (e.g. `/var/mail').
+*/
+char *mailspool = MAILSPOOL;
+
/*
** file stuff
man page install path : ${nmhman}
sendmail path : ${sendmailpath}
+mail spool : ${mailspool}
file locking type : ${LOCKTYPE}
address masquerading : ${masquerade}
# 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:
#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; /* .. */
extern char *lproc;
extern char *mhetcdir;
extern char *mailproc;
+extern char *mailspool;
extern char *mh_seq;
extern char *mhlformat;
extern char *mhlforward;
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
^/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"
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.
.\"
.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
.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
.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
.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)
**
** 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
#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));
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);
- }
}
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];
};
static struct bind binds[] = {
- { "mmdfldir", &mmdfldir },
- { "mmdflfil", &mmdflfil },
- { "uucpldir", &uucpldir },
- { "uucplfil", &uucplfil },
{ "masquerade", &masquerade },
{ "maildelivery", &maildelivery },
{ "everyone", &everyone },
{
register int i;
- if (mmdfldir && *mmdfldir)
- mdrop(mmdfldir);
- if (uucpldir && *uucpldir)
- mdrop(uucpldir);
+ mdrop(mailspool);
for (i = 0; dirs[i]; i++)
mdrop(dirs[i]);
}
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");
#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
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];
context_read();
mts_init(invo_name);
- uid = getuid();
user = getusername();
arguments = getarguments(invo_name, argc, argv, 1);
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;
}
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;
}
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)