summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/mail.local
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2000-10-01 02:03:50 +0000
committergshapiro <gshapiro@FreeBSD.org>2000-10-01 02:03:50 +0000
commit1bbf49b55a2601a4b47f84ef0db64d5bbc97608f (patch)
tree8243eef774bd2693d62f2204f2be075a5b646c32 /contrib/sendmail/mail.local
parent0cc8aac437ca5de8f94291323499241c949261f9 (diff)
downloadFreeBSD-src-1bbf49b55a2601a4b47f84ef0db64d5bbc97608f.zip
FreeBSD-src-1bbf49b55a2601a4b47f84ef0db64d5bbc97608f.tar.gz
Fix conflicts from merge of sendmail 8.11.1
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r--contrib/sendmail/mail.local/mail.local.814
-rw-r--r--contrib/sendmail/mail.local/mail.local.c449
2 files changed, 248 insertions, 215 deletions
diff --git a/contrib/sendmail/mail.local/mail.local.8 b/contrib/sendmail/mail.local/mail.local.8
index 246a952..2c21239 100644
--- a/contrib/sendmail/mail.local/mail.local.8
+++ b/contrib/sendmail/mail.local/mail.local.8
@@ -1,4 +1,4 @@
-.\" Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.
+.\" Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
.\" All rights reserved.
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -8,17 +8,17 @@
.\" the sendmail distribution.
.\"
.\"
-.\" $Id: mail.local.8,v 8.14 1999/08/26 15:49:20 ca Exp $
+.\" $Id: mail.local.8,v 8.14.14.3 2000/09/17 17:04:25 gshapiro Exp $
.\"
.\" $FreeBSD$
.\"
-.TH MAIL.LOCAL 8 "$Date: 1999/08/26 15:49:20 $"
+.TH MAIL.LOCAL 8 "$Date: 2000/09/17 17:04:25 $"
.SH NAME
.B mail.local
\- store mail in a mailbox
.SH SYNOPSIS
.B mail.local
-.RB [ \-7 "] [" \-B "] [" \-d "] [" \-l "] [" \-s "] [" \-f
+.RB [ \-7 "] [" \-B "] [" \-b "] [" \-d "] [" \-l "] [" \-s "] [" \-f
.IR from "] " "user ..."
.SH DESCRIPTION
.B Mail.local
@@ -109,6 +109,12 @@ flock(2),
getservbyname(3),
comsat(8),
sendmail(8)
+.SH WARNING
+.B mail.local
+escapes only "^From " lines that follow an empty line.
+If all lines starting with "From " should be escaped,
+use the 'E' flag for the local mailer in the
+sendmail.cf file.
.SH HISTORY
A superset of
.B mail.local
diff --git a/contrib/sendmail/mail.local/mail.local.c b/contrib/sendmail/mail.local/mail.local.c
index 03fe02c..d182b49 100644
--- a/contrib/sendmail/mail.local/mail.local.c
+++ b/contrib/sendmail/mail.local/mail.local.c
@@ -19,7 +19,7 @@ static char copyright[] =
#endif /* ! lint */
#ifndef lint
-static char id[] = "@(#)$Id: mail.local.c,v 8.143.4.13 2000/07/18 05:41:38 gshapiro Exp $";
+static char id[] = "@(#)$Id: mail.local.c,v 8.143.4.37 2000/09/22 00:49:10 doug Exp $";
#endif /* ! lint */
/* $FreeBSD$ */
@@ -34,215 +34,219 @@ static char id[] = "@(#)$Id: mail.local.c,v 8.143.4.13 2000/07/18 05:41:38 gshap
*/
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-
-#include <fcntl.h>
-#include <netdb.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <time.h>
-#include <unistd.h>
-#ifdef EX_OK
-# undef EX_OK /* unistd.h may have another use for this */
-#endif /* EX_OK */
-#include <sysexits.h>
-#include <ctype.h>
-
-#ifndef __P
-# include "sendmail/cdefs.h"
-#endif /* ! __P */
-#include "sendmail/useful.h"
+/* additional mode for open() */
+# define EXTRA_MODE 0
-extern size_t strlcpy __P((char *, const char *, size_t));
-extern size_t strlcat __P((char *, const char *, size_t));
+# include <sys/types.h>
+# include <sys/param.h>
+# include <sys/stat.h>
+# include <sys/socket.h>
+# include <sys/file.h>
-#if defined(BSD4_4) || defined(__osf__) || defined(__GNU_LIBRARY__) || defined(IRIX64) || defined(IRIX5) || defined(IRIX6)
-# ifndef HASSTRERROR
-# define HASSTRERROR 1
-# endif /* ! HASSTRERROR */
-#endif /* defined(BSD4_4) || defined(__osf__) || defined(__GNU_LIBRARY__) ||
- defined(IRIX64) || defined(IRIX5) || defined(IRIX6) */
+# include <netinet/in.h>
+# include <arpa/nameser.h>
-#include "sendmail/errstring.h"
+# include <fcntl.h>
+# include <netdb.h>
+# include <pwd.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+# include <syslog.h>
+# include <time.h>
+# include <unistd.h>
+# ifdef EX_OK
+# undef EX_OK /* unistd.h may have another use for this */
+# endif /* EX_OK */
+# include <sysexits.h>
+# include <ctype.h>
+# ifndef __P
+# include "sendmail/cdefs.h"
+# endif /* ! __P */
+# include "sendmail/useful.h"
-#ifndef LOCKTO_RM
-# define LOCKTO_RM 300 /* timeout for stale lockfile removal */
-#endif /* LOCKTO_RM */
-#ifndef LOCKTO_GLOB
-# define LOCKTO_GLOB 400 /* global timeout for lockfile creation */
-#endif /* LOCKTO_GLOB */
+extern size_t strlcpy __P((char *, const char *, size_t));
+extern size_t strlcat __P((char *, const char *, size_t));
-#ifdef __STDC__
-# include <stdarg.h>
-# define REALLOC(ptr, size) realloc(ptr, size)
-#else /* __STDC__ */
-# include <varargs.h>
+# if defined(BSD4_4) || defined(__osf__) || defined(__GNU_LIBRARY__) || defined(IRIX64) || defined(IRIX5) || defined(IRIX6)
+# ifndef HASSTRERROR
+# define HASSTRERROR 1
+# endif /* ! HASSTRERROR */
+# endif /* defined(BSD4_4) || defined(__osf__) || defined(__GNU_LIBRARY__) || defined(IRIX64) || defined(IRIX5) || defined(IRIX6) */
+
+# include "sendmail/errstring.h"
+
+# ifndef LOCKTO_RM
+# define LOCKTO_RM 300 /* timeout for stale lockfile removal */
+# endif /* ! LOCKTO_RM */
+# ifndef LOCKTO_GLOB
+# define LOCKTO_GLOB 400 /* global timeout for lockfile creation */
+# endif /* ! LOCKTO_GLOB */
+
+# ifdef __STDC__
+# include <stdarg.h>
+# define REALLOC(ptr, size) realloc(ptr, size)
+# else /* __STDC__ */
+# include <varargs.h>
/* define a realloc() which works for NULL pointers */
-# define REALLOC(ptr, size) (((ptr) == NULL) ? malloc(size) : realloc(ptr, size))
-#endif /* __STDC__ */
-
-#if (defined(sun) && defined(__svr4__)) || defined(__SVR4)
-# define USE_LOCKF 1
-# define USE_SETEUID 1
-# define _PATH_MAILDIR "/var/mail"
-#endif /* (defined(sun) && defined(__svr4__)) || defined(__SVR4) */
-
-#ifdef NCR_MP_RAS3
-# define USE_LOCKF 1
-# define HASSNPRINTF 1
-# define _PATH_MAILDIR "/var/mail"
-#endif /* NCR_MP_RAS3 */
-
-#if defined(_AIX)
-# define USE_LOCKF 1
-# define USE_SETEUID 1
-# define USE_VSYSLOG 0
-#endif /* defined(_AIX) */
-
-#if defined(__hpux)
-# define USE_LOCKF 1
-# define USE_SETRESUID 1
-# define USE_VSYSLOG 0
-#endif /* defined(__hpux) */
-
-#ifdef DGUX
-# define HASSNPRINTF 1
-# define USE_LOCKF 1
-# define USE_VSYSLOG 0
-#endif /* DGUX */
-
-#if defined(_CRAY)
-# if !defined(MAXPATHLEN)
-# define MAXPATHLEN PATHSIZE
-# endif /* !defined(MAXPATHLEN) */
-# define USE_VSYSLOG 0
-# define _PATH_MAILDIR "/usr/spool/mail"
-#endif /* defined(_CRAY) */
-
-#if defined(ultrix)
-# define USE_VSYSLOG 0
-#endif /* defined(ultrix) */
-
-#if defined(__osf__)
-# define USE_VSYSLOG 0
-#endif /* defined(__osf__) */
-
-#if defined(NeXT) && !defined(__APPLE__)
-# include <libc.h>
-# define _PATH_MAILDIR "/usr/spool/mail"
-# define S_IRUSR S_IREAD
-# define S_IWUSR S_IWRITE
-#endif /* defined(NeXT) && !defined(__APPLE__) */
-
-#if defined(IRIX64) || defined(IRIX5) || defined(IRIX6)
-# include <paths.h>
-#endif /* defined(IRIX64) || defined(IRIX5) || defined(IRIX6) */
+# define REALLOC(ptr, size) (((ptr) == NULL) ? malloc(size) : realloc(ptr, size))
+# endif /* __STDC__ */
+
+# if (defined(sun) && defined(__svr4__)) || defined(__SVR4)
+# define USE_LOCKF 1
+# define USE_SETEUID 1
+# define _PATH_MAILDIR "/var/mail"
+# endif /* (defined(sun) && defined(__svr4__)) || defined(__SVR4) */
+
+# ifdef NCR_MP_RAS3
+# define USE_LOCKF 1
+# define HASSNPRINTF 1
+# define _PATH_MAILDIR "/var/mail"
+# endif /* NCR_MP_RAS3 */
+
+# if defined(_AIX)
+# define USE_LOCKF 1
+# define USE_SETEUID 1
+# define USE_VSYSLOG 0
+# endif /* defined(_AIX) */
+
+# if defined(__hpux)
+# define USE_LOCKF 1
+# define USE_SETRESUID 1
+# define USE_VSYSLOG 0
+# endif /* defined(__hpux) */
+
+# ifdef DGUX
+# define HASSNPRINTF 1
+# define USE_LOCKF 1
+# define USE_VSYSLOG 0
+# endif /* DGUX */
+
+# if defined(_CRAY)
+# if !defined(MAXPATHLEN)
+# define MAXPATHLEN PATHSIZE
+# endif /* !defined(MAXPATHLEN) */
+# define USE_VSYSLOG 0
+# define _PATH_MAILDIR "/usr/spool/mail"
+# endif /* defined(_CRAY) */
+
+# if defined(ultrix)
+# define USE_VSYSLOG 0
+# endif /* defined(ultrix) */
+
+# if defined(__osf__)
+# define USE_VSYSLOG 0
+# endif /* defined(__osf__) */
+
+# if defined(NeXT) && !defined(__APPLE__)
+# include <libc.h>
+# define _PATH_MAILDIR "/usr/spool/mail"
+# define S_IRUSR S_IREAD
+# define S_IWUSR S_IWRITE
+# endif /* defined(NeXT) && !defined(__APPLE__) */
+
+# if defined(IRIX64) || defined(IRIX5) || defined(IRIX6)
+# include <paths.h>
+# endif /* defined(IRIX64) || defined(IRIX5) || defined(IRIX6) */
/*
* If you don't have flock, you could try using lockf instead.
*/
-#ifdef USE_LOCKF
-# define flock(a, b) lockf(a, b, 0)
-# ifdef LOCK_EX
-# undef LOCK_EX
-# endif /* LOCK_EX */
-# define LOCK_EX F_LOCK
-#endif /* USE_LOCKF */
-
-#ifndef USE_VSYSLOG
-# define USE_VSYSLOG 1
-#endif /* ! USE_VSYSLOG */
-
-#ifndef LOCK_EX
-# include <sys/file.h>
-#endif /* ! LOCK_EX */
-
-#if defined(BSD4_4) || defined(__GLIBC__)
-# include <paths.h>
-# define _PATH_LOCTMP "/var/tmp/local.XXXXXX"
-#endif /* defined(BSD4_4) || defined(__GLIBC__) */
-
-#ifdef BSD4_4
-# define HAS_ST_GEN 1
-#else /* BSD4_4 */
-# ifndef _BSD_VA_LIST_
-# define _BSD_VA_LIST_ va_list
-# endif /* ! _BSD_VA_LIST_ */
-#endif /* BSD4_4 */
-
-#if defined(BSD4_4) || defined(linux)
-# define HASSNPRINTF 1
-#else /* defined(BSD4_4) || defined(linux) */
-# ifndef ultrix
+# ifdef USE_LOCKF
+# define flock(a, b) lockf(a, b, 0)
+# ifdef LOCK_EX
+# undef LOCK_EX
+# endif /* LOCK_EX */
+# define LOCK_EX F_LOCK
+# endif /* USE_LOCKF */
+
+# ifndef USE_VSYSLOG
+# define USE_VSYSLOG 1
+# endif /* ! USE_VSYSLOG */
+
+# ifndef LOCK_EX
+# include <sys/file.h>
+# endif /* ! LOCK_EX */
+
+# if defined(BSD4_4) || defined(__GLIBC__)
+# include <paths.h>
+# define _PATH_LOCTMP "/var/tmp/local.XXXXXX"
+# endif /* defined(BSD4_4) || defined(__GLIBC__) */
+
+# ifdef BSD4_4
+# define HAS_ST_GEN 1
+# else /* BSD4_4 */
+# ifndef _BSD_VA_LIST_
+# define _BSD_VA_LIST_ va_list
+# endif /* ! _BSD_VA_LIST_ */
+# endif /* BSD4_4 */
+
+# if defined(BSD4_4) || defined(linux)
+# define HASSNPRINTF 1
+# else /* defined(BSD4_4) || defined(linux) */
+# ifndef ultrix
extern FILE *fdopen __P((int, const char *));
-# endif /* ! ultrix */
-#endif /* defined(BSD4_4) || defined(linux) */
+# endif /* ! ultrix */
+# endif /* defined(BSD4_4) || defined(linux) */
-#if SOLARIS >= 20300 || (SOLARIS < 10000 && SOLARIS >= 203)
-# define CONTENTLENGTH 1 /* Needs the Content-Length header */
-#endif /* SOLARIS >= 20300 || (SOLARIS < 10000 && SOLARIS >= 203) */
+# if SOLARIS >= 20300 || (SOLARIS < 10000 && SOLARIS >= 203)
+# define CONTENTLENGTH 1 /* Needs the Content-Length header */
+# endif /* SOLARIS >= 20300 || (SOLARIS < 10000 && SOLARIS >= 203) */
-#if SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206)
-# define HASSNPRINTF 1 /* has snprintf starting in 2.6 */
-#endif /* SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206) */
+# if SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206)
+# define HASSNPRINTF 1 /* has snprintf starting in 2.6 */
+# endif /* SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206) */
-#ifdef HPUX11
-# define HASSNPRINTF 1 /* has snprintf starting in 2.6 */
-#endif /* HPUX11 */
+# ifdef HPUX11
+# define HASSNPRINTF 1 /* has snprintf starting in 11.X */
+# endif /* HPUX11 */
-#if _AIX4 >= 40300
-# define HASSNPRINTF 1 /* has snprintf starting in 4.3 */
-#endif /* _AIX4 >= 40300 */
+# if _AIX4 >= 40300
+# define HASSNPRINTF 1 /* has snprintf starting in 4.3 */
+# endif /* _AIX4 >= 40300 */
-#if !HASSNPRINTF
+# if !HASSNPRINTF
extern int snprintf __P((char *, size_t, const char *, ...));
-# ifndef _CRAY
+# ifndef _CRAY
extern int vsnprintf __P((char *, size_t, const char *, ...));
-# endif /* ! _CRAY */
-#endif /* !HASSNPRINTF */
+# endif /* ! _CRAY */
+# endif /* !HASSNPRINTF */
/*
** If you don't have setreuid, and you have saved uids, and you have
** a seteuid() call that doesn't try to emulate using setuid(), then
** you can try defining USE_SETEUID.
*/
-#ifdef USE_SETEUID
-# define setreuid(r, e) seteuid(e)
-#endif /* USE_SETEUID */
+# ifdef USE_SETEUID
+# define setreuid(r, e) seteuid(e)
+# endif /* USE_SETEUID */
/*
** And of course on hpux you have setresuid()
*/
-#ifdef USE_SETRESUID
-# define setreuid(r, e) setresuid(-1, e, -1)
-#endif /* USE_SETRESUID */
+# ifdef USE_SETRESUID
+# define setreuid(r, e) setresuid(-1, e, -1)
+# endif /* USE_SETRESUID */
-#ifndef _PATH_LOCTMP
-# define _PATH_LOCTMP "/var/tmp/local.XXXXXX"
-#endif /* ! _PATH_LOCTMP */
-# ifndef _PATH_MAILDIR
-# define _PATH_MAILDIR "/var/spool/mail"
-# endif /* ! _PATH_MAILDIR */
+# ifndef _PATH_LOCTMP
+# define _PATH_LOCTMP "/var/tmp/local.XXXXXX"
+# endif /* ! _PATH_LOCTMP */
+# ifndef _PATH_MAILDIR
+# define _PATH_MAILDIR "/var/spool/mail"
+# endif /* ! _PATH_MAILDIR */
-#ifndef S_ISREG
-# define S_ISREG(mode) (((mode) & _S_IFMT) == S_IFREG)
-#endif /* ! S_ISREG */
+# ifndef S_ISREG
+# define S_ISREG(mode) (((mode) & _S_IFMT) == S_IFREG)
+# endif /* ! S_ISREG */
-#ifdef MAILLOCK
-# include <maillock.h>
-#endif /* MAILLOCK */
+# ifdef MAILLOCK
+# include <maillock.h>
+# endif /* MAILLOCK */
+
+# define U_UID pw->pw_uid
+# define U_GID pw->pw_gid
#ifndef INADDRSZ
# define INADDRSZ 4 /* size of an IPv4 address in bytes */
@@ -538,7 +542,8 @@ dolmtp(bouncequota)
p = strchr(rcpt_addr[i], '+');
if (p != NULL)
*p++ = '\0';
- deliver(msgfd, rcpt_addr[i], bouncequota);
+ deliver(msgfd, rcpt_addr[i],
+ bouncequota);
}
(void) close(msgfd);
goto rset;
@@ -628,7 +633,7 @@ dolmtp(bouncequota)
{
rcpt_alloc += RCPT_GROW;
rcpt_addr = (char **)
- REALLOC((char *)rcpt_addr,
+ REALLOC((char *) rcpt_addr,
rcpt_alloc *
sizeof(char **));
if (rcpt_addr == NULL)
@@ -811,7 +816,7 @@ store(from, lmtprcpts)
{
if (eline && line[0] == 'F' &&
!memcmp(line, "From ", 5))
- (void)putc('>', fp);
+ (void) putc('>', fp);
eline = FALSE;
#ifdef CONTENTLENGTH
/* discard existing "Content-Length:" headers */
@@ -879,7 +884,8 @@ store(from, lmtprcpts)
snprintf(line, sizeof line, "%s\n",
quad_to_string(BodyLength));
else
- snprintf(line, sizeof line, "%ld\n", (long) BodyLength);
+ snprintf(line, sizeof line, "%ld\n",
+ (long) BodyLength);
strlcpy(&ContentHdr[16], line, sizeof(ContentHdr) - 16);
}
else
@@ -940,7 +946,8 @@ deliver(fd, name, bouncequota)
if (LMTPMode)
{
if (ExitVal == EX_TEMPFAIL)
- printf("451 4.3.0 cannot lookup name: %s\r\n", name);
+ printf("451 4.3.0 cannot lookup name: %s\r\n",
+ name);
else
printf("550 5.1.1 unknown name: %s\r\n", name);
}
@@ -1030,7 +1037,7 @@ tryagain:
{
int save_errno;
int mode = S_IRUSR|S_IWUSR;
- gid_t gid = pw->pw_gid;
+ gid_t gid = U_GID;
#ifdef MAILGID
(void) umask(0007);
@@ -1038,8 +1045,8 @@ tryagain:
mode |= S_IRGRP|S_IWGRP;
#endif /* MAILGID */
- mbfd = open(path, O_APPEND|O_CREAT|O_EXCL|O_WRONLY, mode);
-
+ mbfd = open(path, O_APPEND|O_CREAT|O_EXCL|O_WRONLY|EXTRA_MODE,
+ mode);
save_errno = errno;
if (lstat(path, &sb) < 0)
@@ -1049,36 +1056,61 @@ tryagain:
"%s: lstat: file changed after open", path);
goto err1;
}
- else
- sb.st_uid = pw->pw_uid;
if (mbfd == -1)
{
if (save_errno == EEXIST)
goto tryagain;
+
+ /* open failed, don't try again */
+ mailerr("450 4.2.0", "%s: %s", path,
+ errstring(save_errno));
+ goto err0;
}
- else if (fchown(mbfd, pw->pw_uid, gid) < 0)
+ else if (fchown(mbfd, U_UID, gid) < 0)
{
mailerr("451 4.3.0", "chown %u.%u: %s",
- pw->pw_uid, gid, name);
+ U_UID, gid, name);
goto err1;
}
+ else
+ {
+ /*
+ ** open() was successful, now close it so can
+ ** be opened as the right owner again.
+ ** Paranoia: reset mbdf since the file descriptor
+ ** is no longer valid; better safe than sorry.
+ */
+
+ sb.st_uid = U_UID;
+ (void) close(mbfd);
+ mbfd = -1;
+ }
}
else if (sb.st_nlink != 1 || !S_ISREG(sb.st_mode))
{
mailerr("550 5.2.0", "%s: irregular file", path);
goto err0;
}
- else if (sb.st_uid != pw->pw_uid)
+ else if (sb.st_uid != U_UID)
{
ExitVal = EX_CANTCREAT;
mailerr("550 5.2.0", "%s: wrong ownership (%d)",
path, sb.st_uid);
goto err0;
}
- else
- mbfd = open(path, O_APPEND|O_WRONLY, 0);
- if (mbfd == -1)
+ /* change UID for quota checks */
+ if (setreuid(0, U_UID) < 0)
+ {
+ mailerr("450 4.2.0", "setreuid(0, %d): %s (r=%d, e=%d)",
+ U_UID, errstring(errno), getuid(), geteuid());
+ goto err1;
+ }
+#ifdef DEBUG
+ fprintf(stderr, "new euid = %d\n", geteuid());
+#endif /* DEBUG */
+ mbfd = open(path, O_APPEND|O_WRONLY|EXTRA_MODE, 0);
+ if (mbfd < 0)
{
mailerr("450 4.2.0", "%s: %s", path, errstring(errno));
goto err0;
@@ -1089,9 +1121,9 @@ tryagain:
!S_ISREG(fsb.st_mode) ||
sb.st_dev != fsb.st_dev ||
sb.st_ino != fsb.st_ino ||
-#if HAS_ST_GEN && 0 /* AFS returns random values for st_gen */
+# if HAS_ST_GEN && 0 /* AFS returns random values for st_gen */
sb.st_gen != fsb.st_gen ||
-#endif /* HAS_ST_GEN && 0 */
+# endif /* HAS_ST_GEN && 0 */
sb.st_uid != fsb.st_uid)
{
ExitVal = EX_TEMPFAIL;
@@ -1113,11 +1145,11 @@ tryagain:
/* Get the starting offset of the new message for biff. */
curoff = lseek(mbfd, (off_t)0, SEEK_END);
if (sizeof curoff > sizeof(long))
- (void)snprintf(biffmsg, sizeof(biffmsg), "%s@%s\n",
- name, quad_to_string(curoff));
+ (void) snprintf(biffmsg, sizeof(biffmsg), "%s@%s\n",
+ name, quad_to_string(curoff));
else
- (void)snprintf(biffmsg, sizeof(biffmsg), "%s@%ld\n",
- name, curoff);
+ (void) snprintf(biffmsg, sizeof(biffmsg), "%s@%ld\n",
+ name, (long) curoff);
}
/* Copy the message into the file. */
@@ -1127,14 +1159,8 @@ tryagain:
errstring(errno));
goto err1;
}
- if (setreuid(0, pw->pw_uid) < 0)
- {
- mailerr("450 4.2.0", "setreuid(0, %d): %s (r=%d, e=%d)",
- pw->pw_uid, errstring(errno), getuid(), geteuid());
- goto err1;
- }
#ifdef DEBUG
- fprintf(stderr, "new euid = %d\n", geteuid());
+ fprintf(stderr, "before writing: euid = %d\n", geteuid());
#endif /* DEBUG */
#ifdef CONTENTLENGTH
headerbytes = (BodyLength >= 0) ? HeaderLength : -1 ;
@@ -1203,7 +1229,8 @@ err3:
fprintf(stderr, "reset euid = %d\n", geteuid());
#endif /* DEBUG */
(void) ftruncate(mbfd, curoff);
-err1: (void) close(mbfd);
+err1: if (mbfd >= 0)
+ (void) close(mbfd);
err0: unlockmbox();
return;
}
@@ -1250,7 +1277,7 @@ int
lockmbox(name)
char *name;
{
- int r;
+ int r = 0;
if (Locked)
return 0;
@@ -1398,7 +1425,7 @@ void
usage()
{
ExitVal = EX_USAGE;
- mailerr(NULL, "usage: mail.local [-B] [-l] [-f from] [-s] user ...");
+ mailerr(NULL, "usage: mail.local [-7] [-B] [-b] [-l] [-f from] user ...");
exit(ExitVal);
}
@@ -1674,8 +1701,8 @@ _gettemp(path, doopen)
{
if (doopen)
{
- if ((*doopen =
- open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
+ if ((*doopen = open(path, O_CREAT|O_EXCL|O_RDWR,
+ 0600)) >= 0)
return(1);
if (errno != EEXIST)
return(0);
OpenPOWER on IntegriCloud