fix a bug that would probably come up once every ten years in creating
the queue id. should merge argv flag processing with option processing.
SCCS-vsn: usr.sbin/sendmail/src/main.c 3.117
SCCS-vsn: usr.sbin/sendmail/src/conf.c 3.58
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.117
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.90
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.206
SCCS-vsn: usr.sbin/sendmail/src/util.c 3.32
SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.45
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 3.34
-SCCSID(@(#)conf.c 3.57 %G%);
+SCCSID(@(#)conf.c 3.58 %G%);
\f/*
** Header info table
** Final (null) entry contains the flags used for any other field.
\f/*
** Header info table
** Final (null) entry contains the flags used for any other field.
time_t TimeOut = 3*24*60*60L; /* default timeout for queue files */
int ReadTimeout = 10*60; /* timeout on external reads */
int LogLevel = 9; /* default logging level */
time_t TimeOut = 3*24*60*60L; /* default timeout for queue files */
int ReadTimeout = 10*60; /* timeout on external reads */
int LogLevel = 9; /* default logging level */
+bool SuperSafe = TRUE; /* always create qf file */
# include "sendmail.h"
# include <sys/stat.h>
# include "sendmail.h"
# include <sys/stat.h>
-SCCSID(@(#)deliver.c 3.116 %G%);
+SCCSID(@(#)deliver.c 3.117 %G%);
/*
** DELIVER -- Deliver a message to a list of addresses.
/*
** DELIVER -- Deliver a message to a list of addresses.
{
# ifdef QUEUE
queueup(e, FALSE);
{
# ifdef QUEUE
queueup(e, FALSE);
+ e->e_df = e->e_qf = NULL;
+ e->e_dontqueue = TRUE;
# else QUEUE
syserr("checkerrors: trying to queue %s", e->e_df);
# endif QUEUE
# else QUEUE
syserr("checkerrors: trying to queue %s", e->e_df);
# endif QUEUE
# include "sendmail.h"
# include <sys/stat.h>
# include "sendmail.h"
# include <sys/stat.h>
-SCCSID(@(#)main.c 3.116 %G%);
+SCCSID(@(#)main.c 3.117 %G%);
/*
** SENDMAIL -- Post mail to a set of destinations.
/*
** SENDMAIL -- Post mail to a set of destinations.
** slower than it must be.
*/
** slower than it must be.
*/
+ if (Mode == MD_QUEUE || Mode == MD_FORK ||
+ (Mode != MD_VERIFY && SuperSafe))
+ queueup(CurEnv, TRUE);
+
if (Mode == MD_FORK)
{
if (fork() > 0)
if (Mode == MD_FORK)
{
if (fork() > 0)
}
else if (Mode == MD_QUEUE)
{
}
else if (Mode == MD_QUEUE)
{
+ CurEnv->e_df = CurEnv->e_qf = NULL;
+ CurEnv->e_dontqueue = TRUE;
** QUEUENAME -- build a file name in the queue directory for this envelope.
**
** Assigns an id code if one does not already exist.
** QUEUENAME -- build a file name in the queue directory for this envelope.
**
** Assigns an id code if one does not already exist.
+** This code is very careful to avoid trashing existing files
+** under any circumstances.
+** We first create an xf file that is only used when
+** assigning an id. This file is always empty, so that
+** we can never accidently truncate an lf file.
**
** Parameters:
** e -- envelope to build it in/from.
**
** Parameters:
** e -- envelope to build it in/from.
char counter = 'A' - 1;
char qf[20];
char lf[20];
char counter = 'A' - 1;
char qf[20];
char lf[20];
/* find a unique id */
(void) sprintf(qf, "qf_%05d", getpid());
strcpy(lf, qf);
lf[0] = 'l';
/* find a unique id */
(void) sprintf(qf, "qf_%05d", getpid());
strcpy(lf, qf);
lf[0] = 'l';
+ strcpy(xf, qf);
+ xf[0] = 'x';
- qf[2] = lf[2] = ++counter;
+ qf[2] = lf[2] = xf[2] = ++counter;
# ifdef DEBUG
if (tTd(7, 20))
# ifdef DEBUG
if (tTd(7, 20))
- printf("queuename: trying \"%s\"\n", lf);
+ printf("queuename: trying \"%s\"\n", xf);
# endif DEBUG
if (access(lf, 0) >= 0 || access(qf, 0) >= 0)
continue;
errno = 0;
# endif DEBUG
if (access(lf, 0) >= 0 || access(qf, 0) >= 0)
continue;
errno = 0;
- fd = creat(lf, 0600);
- if (fd < 0)
+ i = creat(xf, 0600);
+ if (i < 0)
- (void) unlink(lf); /* kernel bug on ENFILE */
+ (void) unlink(xf); /* kernel bug */
- (void) close(fd);
- if (link(lf, qf) < 0)
- (void) unlink(lf);
- else
+ (void) close(i);
+ i = link(xf, lf);
+ (void) unlink(xf);
+ if (i < 0)
+ continue;
+ if (link(lf, qf) >= 0)
# include <errno.h>
# ifndef QUEUE
# include <errno.h>
# ifndef QUEUE
-SCCSID(@(#)queue.c 3.44 %G% (no queueing));
+SCCSID(@(#)queue.c 3.45 %G% (no queueing));
-SCCSID(@(#)queue.c 3.44 %G%);
+SCCSID(@(#)queue.c 3.45 %G%);
/*
** QUEUEUP -- queue a message up for future transmission.
/*
** QUEUEUP -- queue a message up for future transmission.
syserr("cannot link(%s, %s), df=%s", tf, qf, e->e_df);
else
(void) unlink(tf);
syserr("cannot link(%s, %s), df=%s", tf, qf, e->e_df);
else
(void) unlink(tf);
# ifdef LOG
/* save log info */
if (LogLevel > 15)
syslog(LOG_DEBUG, "%s: queueup, qf=%s, df=%s\n", e->e_id, qf, e->e_df);
# endif LOG
# ifdef LOG
/* save log info */
if (LogLevel > 15)
syslog(LOG_DEBUG, "%s: queueup, qf=%s, df=%s\n", e->e_id, qf, e->e_df);
# endif LOG
-
- /* disconnect this temp file from the job; don't requeue later */
- e->e_df = NULL;
- e->e_dontqueue = TRUE;
}
\f/*
** RUNQUEUE -- run the jobs in the queue.
}
\f/*
** RUNQUEUE -- run the jobs in the queue.
-SCCSID(@(#)readcf.c 3.33 %G%);
+SCCSID(@(#)readcf.c 3.34 %G%);
/*
** READCF -- read control file.
/*
** READCF -- read control file.
extern char *HelpFile; /* defined in conf.c */
extern char *HelpFile; /* defined in conf.c */
# ifdef DEBUG
if (tTd(37, 1))
# ifdef DEBUG
if (tTd(37, 1))
tval = convtime(val);
else if (index("gLu", opt) != NULL)
ival = atoi(val);
tval = convtime(val);
else if (index("gLu", opt) != NULL)
ival = atoi(val);
+ else if (index("s", opt) != NULL)
+ bval = atobool(val);
else if (val[0] == '\0')
val = "";
else
else if (val[0] == '\0')
val = "";
else
-# ifdef V6
- case 'd': /* dst timezone name */
- DstTimeZone = val;
- break;
-# endif V6
-
case 'g': /* default gid */
DefGid = ival;
break;
case 'g': /* default gid */
DefGid = ival;
break;
-# ifdef V6
- case 's': /* standard time time zone */
- StdTimeZone = val;
+ case 's': /* be super safe, even if expensive */
+ SuperSafe = bval;
case 'T': /* queue timeout */
TimeOut = tval;
break;
case 'T': /* queue timeout */
TimeOut = tval;
break;
+ case 't': /* time zone name */
+# ifdef V6
+ StdTimezone = val;
+ DstTimezone = index(val, ',');
+ if (DstTimezone == NULL)
+ goto syntax;
+ *DstTimezone++ = '\0';
+# endif V6
+ break;
+
case 'u': /* set default uid */
DefUid = ival;
break;
case 'u': /* set default uid */
DefUid = ival;
break;
- syserr("setoption: line %d: illegal option %c", LineNumber, opt);
+ syntax:
+ syserr("setoption: line %d: syntax error on \"%c%s\"",
+ LineNumber, opt, val);
# ifdef _DEFINE
# define EXTERN
# ifndef lint
# ifdef _DEFINE
# define EXTERN
# ifndef lint
-static char SmailSccsId[] = "@(#)sendmail.h 3.89 %G%";
+static char SmailSccsId[] = "@(#)sendmail.h 3.90 %G%";
# endif lint
# else _DEFINE
# define EXTERN extern
# endif lint
# else _DEFINE
# define EXTERN extern
EXTERN bool ArpaMode; /* set if running arpanet protocol */
EXTERN bool NoConnect; /* don't connect to non-local mailers */
EXTERN bool FatalErrors; /* set if fatal errors during processing */
EXTERN bool ArpaMode; /* set if running arpanet protocol */
EXTERN bool NoConnect; /* don't connect to non-local mailers */
EXTERN bool FatalErrors; /* set if fatal errors during processing */
+extern bool SuperSafe; /* be extra careful, despite cost [conf.c] */
extern time_t TimeOut; /* time until timeout [conf.c] */
EXTERN FILE *InChannel; /* input connection */
EXTERN FILE *OutChannel; /* output connection */
extern time_t TimeOut; /* time until timeout [conf.c] */
EXTERN FILE *InChannel; /* input connection */
EXTERN FILE *OutChannel; /* output connection */
# include "sendmail.h"
# include "conf.h"
# include "sendmail.h"
# include "conf.h"
-SCCSID(@(#)util.c 3.31 %G%);
+SCCSID(@(#)util.c 3.32 %G%);
/*
** STRIPQUOTES -- Strip quotes & quote bits from a string.
/*
** STRIPQUOTES -- Strip quotes & quote bits from a string.
(void) time(&t);
return (t);
}
(void) time(&t);
return (t);
}
+\f/*
+** ATOBOOL -- convert a string representation to boolean.
+**
+** Defaults to "TRUE"
+**
+** Parameters:
+** s -- string to convert. Takes "tTyY" as true,
+** others as false.
+**
+** Returns:
+** A boolean representation of the string.
+**
+** Side Effects:
+** none.
+*/
+
+bool
+atobool(s)
+ register char *s;
+{
+ if (*s == '\0' || index("tTyY", *s) != NULL)
+ return (TRUE);
+ return (FALSE);
+}
-static char SccsId[] = "@(#)SendMail version 3.205 of %G%";
+static char SccsId[] = "@(#)SendMail version 3.206 of %G%";
-char Version[] = "3.205 [%G%]";
+char Version[] = "3.206 [%G%]";