Convert the DONT_FSYNC compile time option to a runtime option (like

nobiff).  The options to turn these on are specified in the
LOCAL_MAILER_ARGS define the the sendmail.mc that you build from.
This commit is contained in:
peter 1996-10-29 05:35:24 +00:00
parent 6d127efe9f
commit 7bfbad3404
3 changed files with 27 additions and 21 deletions

View File

@ -2,9 +2,6 @@
PROG= mail.local
MAN8= mail.local.8
.if defined(DONT_FSYNC)
CFLAGS+= -DDONT_FSYNC
.endif
BINOWN= root
BINMODE=4555
INSTALLFLAGS=-fschg

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mail.local.8 8.2 (Berkeley) 12/11/93
.\" $Id$
.\" $Id: mail.local.8,v 1.2 1996/10/29 05:22:51 peter Exp $
.\"
.Dd December 11, 1993
.Dt MAIL.LOCAL 8
@ -42,6 +42,7 @@
.Nm mail.local
.Op Fl f Ar from
.Op Fl b
.Op Fl s
.Ar user ...
.Sh DESCRIPTION
.Nm Mail.local
@ -61,6 +62,12 @@ Specify the sender's name.
Turn off the attempts to notify the
.Dq biff
service.
.It Fl s
Turn off the
.Xr fsync 2
call that forces the mailbox to be committed to disk before returning a
.Dq success
status.
.El
.Pp
Individual mail messages in the mailbox are delimited by an empty

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: mail.local.c,v 1.2 1996/10/29 05:22:52 peter Exp $
*/
#ifndef lint
@ -176,7 +176,7 @@ extern FILE *fdopen __P((int, const char *));
int eval = EX_OK; /* sysexits.h error value. */
void deliver __P((int, char *, int));
void deliver __P((int, char *, int, int));
void e_to_sys __P((int));
void err __P((const char *, ...)) __dead2;
void notifybiff __P((char *));
@ -193,7 +193,7 @@ main(argc, argv)
char *argv[];
{
struct passwd *pw;
int ch, fd, nobiff;
int ch, fd, nobiff, nofsync;
uid_t uid;
char *from;
extern char *optarg;
@ -214,7 +214,8 @@ main(argc, argv)
from = NULL;
nobiff = 0;
while ((ch = getopt(argc, argv, "bdf:r:")) != EOF)
nofsync = 0;
while ((ch = getopt(argc, argv, "bdf:r:s")) != EOF)
switch(ch) {
case 'b':
nobiff++;
@ -229,6 +230,9 @@ main(argc, argv)
}
from = optarg;
break;
case 's':
nofsync++;
break;
case '?':
default:
usage();
@ -259,7 +263,7 @@ main(argc, argv)
* at the expense of repeated failures and multiple deliveries.
*/
for (fd = store(from); *argv; ++argv)
deliver(fd, *argv, nobiff);
deliver(fd, *argv, nobiff, nofsync);
exit(eval);
}
@ -314,8 +318,8 @@ store(from)
}
void
deliver(fd, name, nobiff)
int fd, nobiff;
deliver(fd, name, nobiff, nofsync)
int fd, nobiff, nofsync;
char *name;
{
struct stat fsb, sb;
@ -457,6 +461,13 @@ deliver(fd, name, nobiff)
if (nr < 0) {
e_to_sys(errno);
warn("temporary file: %s", strerror(errno));
goto err3;
}
/* Flush to disk, don't wait for update. */
if (!nofsync && fsync(mbfd)) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
err3:
if (setreuid(0, 0) < 0) {
e_to_sys(errno);
@ -470,15 +481,6 @@ err1: (void)close(mbfd);
err0: unlockmbox();
return;
}
#if !defined(DONT_FSYNC)
/* Flush to disk, don't wait for update. */
if (fsync(mbfd)) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
goto err3;
}
#endif
/* Close and check -- NFS doesn't write until the close. */
if (close(mbfd)) {
@ -588,7 +590,7 @@ void
usage()
{
eval = EX_USAGE;
err("usage: mail.local [-b] [-f from] user ...");
err("usage: mail.local [-b] [-f from] [-s] user ...");
}
#if __STDC__