summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/vacation/vacation.c
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2002-06-11 21:12:04 +0000
committergshapiro <gshapiro@FreeBSD.org>2002-06-11 21:12:04 +0000
commitfaacdfb2c2946459651449cedf08a1bc29aee731 (patch)
tree546131e3b171104de8ab1498603b992a6971ec6a /contrib/sendmail/vacation/vacation.c
parente226f8e879ed5a8d2f5cc433067b698e07dce0b6 (diff)
downloadFreeBSD-src-faacdfb2c2946459651449cedf08a1bc29aee731.zip
FreeBSD-src-faacdfb2c2946459651449cedf08a1bc29aee731.tar.gz
Import sendmail 8.12.4
Diffstat (limited to 'contrib/sendmail/vacation/vacation.c')
-rw-r--r--contrib/sendmail/vacation/vacation.c73
1 files changed, 46 insertions, 27 deletions
diff --git a/contrib/sendmail/vacation/vacation.c b/contrib/sendmail/vacation/vacation.c
index 8fe9793..ab4f4e8 100644
--- a/contrib/sendmail/vacation/vacation.c
+++ b/contrib/sendmail/vacation/vacation.c
@@ -20,7 +20,7 @@ SM_IDSTR(copyright,
The Regents of the University of California. All rights reserved.\n\
Copyright (c) 1983 Eric P. Allman. All rights reserved.\n")
-SM_IDSTR(id, "@(#)$Id: vacation.c,v 1.1.1.7 2002/04/10 03:05:00 gshapiro Exp $")
+SM_IDSTR(id, "@(#)$Id: vacation.c,v 8.137 2002/04/22 18:48:12 gshapiro Exp $")
#include <ctype.h>
@@ -108,7 +108,7 @@ static void listdb __P((void));
#define EXITM(excode) \
{ \
- if (!iflag && !lflag) \
+ if (!initdb && !list) \
eatmsg(); \
exit(excode); \
}
@@ -118,9 +118,10 @@ main(argc, argv)
int argc;
char **argv;
{
- bool iflag, exclude;
+ bool alwaysrespond = false;
+ bool initdb, exclude;
bool runasuser = false;
- bool lflag = false;
+ bool list = false;
int mfail = 0, ufail = 0;
int ch;
int result;
@@ -139,7 +140,7 @@ main(argc, argv)
extern char *optarg;
extern void usage __P((void));
extern void setinterval __P((time_t));
- extern int readheaders __P((void));
+ extern int readheaders __P((bool));
extern bool recent __P((void));
extern void setreply __P((char *, time_t));
extern void sendmessage __P((char *, char *, char *));
@@ -168,17 +169,13 @@ main(argc, argv)
# endif /* LOG_MAIL */
opterr = 0;
- iflag = false;
+ initdb = false;
exclude = false;
interval = INTERVAL_UNDEF;
*From = '\0';
-#if _FFR_RETURN_ADDR
-# define OPTIONS "a:C:df:Iilm:R:r:s:t:Uxz"
-#else /* _FFR_RETURN_ADDR */
-# define OPTIONS "a:C:df:Iilm:r:s:t:Uxz"
-#endif /* _FFR_RETURN_ADDR */
+#define OPTIONS "a:C:df:Iijlm:R:r:s:t:Uxz"
while (mfail == 0 && ufail == 0 &&
(ch = getopt(argc, argv, OPTIONS)) != -1)
@@ -211,11 +208,17 @@ main(argc, argv)
case 'I': /* backward compatible */
case 'i': /* init the database */
- iflag = true;
+ initdb = true;
+ break;
+
+#if _FFR_RESPOND_ALL
+ case 'j':
+ alwaysrespond = true;
break;
+#endif /* _FFR_RESPOND_ALL */
case 'l':
- lflag = true; /* list the database */
+ list = true; /* list the database */
break;
case 'm': /* alternate message file */
@@ -278,7 +281,7 @@ main(argc, argv)
if (argc != 1)
{
- if (!iflag && !lflag && !exclude)
+ if (!initdb && !list && !exclude)
usage();
if ((pw = getpwuid(getuid())) == NULL)
{
@@ -381,7 +384,7 @@ main(argc, argv)
result = smdb_open_database(&Db, dbfilename,
- O_CREAT|O_RDWR | (iflag ? O_TRUNC : 0),
+ O_CREAT|O_RDWR | (initdb ? O_TRUNC : 0),
S_IRUSR|S_IWUSR, sff,
SMDB_TYPE_DEFAULT, &user_info, NULL);
if (result != SMDBE_OK)
@@ -391,7 +394,7 @@ main(argc, argv)
EXITM(EX_DATAERR);
}
- if (lflag)
+ if (list)
{
listdb();
(void) Db->smdb_close(Db);
@@ -401,7 +404,7 @@ main(argc, argv)
if (interval != INTERVAL_UNDEF)
setinterval(interval);
- if (iflag && !exclude)
+ if (initdb && !exclude)
{
(void) Db->smdb_close(Db);
exit(EX_OK);
@@ -425,7 +428,7 @@ main(argc, argv)
cur->next = Names;
Names = cur;
- result = readheaders();
+ result = readheaders(alwaysrespond);
if (result == EX_OK && !recent())
{
time_t now;
@@ -468,7 +471,7 @@ eatmsg()
** READHEADERS -- read mail headers
**
** Parameters:
-** none.
+** alwaysrespond -- respond regardless of whether msg is to me
**
** Returns:
** a exit code: NOUSER if no reply, OK if reply, * if error
@@ -479,7 +482,8 @@ eatmsg()
*/
int
-readheaders()
+readheaders(alwaysrespond)
+ bool alwaysrespond;
{
bool tome, cont;
register char *p;
@@ -488,7 +492,8 @@ readheaders()
extern bool junkmail __P((char *));
extern bool nsearch __P((char *, char *));
- cont = tome = false;
+ cont = false;
+ tome = alwaysrespond;
while (sm_io_fgets(smioin, SM_TIME_DEFAULT, buf, sizeof(buf)) &&
*buf != '\n')
{
@@ -1037,17 +1042,20 @@ sendmessage(myname, msgfn, sender)
void
usage()
{
- char *retusage;
+ char *retusage = "";
+ char *respusage = "";
#if _FFR_RETURN_ADDR
retusage = "[-R returnaddr] ";
-#else /* _FFR_RETURN_ADDR */
- retusage = "";
#endif /* _FFR_RETURN_ADDR */
+#if _FFR_RESPOND_ALL
+ respusage = "[-j] ";
+#endif /* _FFR_RESPOND_ALL */
+
msglog(LOG_NOTICE,
- "uid %u: usage: vacation [-a alias] [-C cfpath] [-d] [-f db] [-i] [-l] [-m msg] %s[-r interval] [-s sender] [-t time] [-U] [-x] [-z] login\n",
- getuid(), retusage);
+ "uid %u: usage: vacation [-a alias] [-C cfpath] [-d] [-f db] [-i] %s[-l] [-m msg] %s[-r interval] [-s sender] [-t time] [-U] [-x] [-z] login\n",
+ getuid(), respusage, retusage);
exit(EX_USAGE);
}
@@ -1084,6 +1092,8 @@ listdb()
while ((result = cursor->smdbc_get(cursor, &db_key, &db_value,
SMDB_CURSOR_GET_NEXT)) == SMDBE_OK)
{
+ char *timestamp;
+
/* skip magic VIT entry */
if ((int)db_key.size - 1 == strlen(VIT) &&
strncmp((char *)db_key.data, VIT,
@@ -1104,9 +1114,18 @@ listdb()
if (db_key.size > 40)
db_key.size = 40;
+ if (t <= 0)
+ {
+ /* must be an exclude */
+ timestamp = "(exclusion)\n";
+ }
+ else
+ {
+ timestamp = ctime(&t);
+ }
sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%-40.*s %-10s",
(int) db_key.size, (char *) db_key.data,
- ctime(&t));
+ timestamp);
memset(&db_key, '\0', sizeof db_key);
memset(&db_value, '\0', sizeof db_value);
OpenPOWER on IntegriCloud