diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2000-10-01 01:49:02 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2000-10-01 01:49:02 +0000 |
commit | f84ac9120cb7d9f087e5dcb863c4bf25ba2985e6 (patch) | |
tree | 1965ed8ab83d1520308eb01c0471d69de74d7653 /contrib/sendmail/mail.local | |
parent | 4332139a9a11f773ffe5109bed871561e3c290a1 (diff) | |
download | FreeBSD-src-f84ac9120cb7d9f087e5dcb863c4bf25ba2985e6.zip FreeBSD-src-f84ac9120cb7d9f087e5dcb863c4bf25ba2985e6.tar.gz |
Import of sendmail version 8.11.1 into vendor branch SENDMAIL with
release tag v8_11_1.
Obtained from: ftp://ftp.sendmail.org/pub/sendmail/
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r-- | contrib/sendmail/mail.local/Makefile.m4 | 8 | ||||
-rw-r--r-- | contrib/sendmail/mail.local/mail.local.8 | 14 | ||||
-rw-r--r-- | contrib/sendmail/mail.local/mail.local.c | 449 |
3 files changed, 253 insertions, 218 deletions
diff --git a/contrib/sendmail/mail.local/Makefile.m4 b/contrib/sendmail/mail.local/Makefile.m4 index f5344f8..516850f 100644 --- a/contrib/sendmail/mail.local/Makefile.m4 +++ b/contrib/sendmail/mail.local/Makefile.m4 @@ -1,10 +1,14 @@ include(confBUILDTOOLSDIR`/M4/switch.m4') +# sendmail dir +SMSRCDIR= ifdef(`confSMSRCDIR', `confSMSRCDIR', `${SRCDIR}/sendmail') +PREPENDDEF(`confENVDEF', `confMAPDEF') +PREPENDDEF(`confINCDIRS', `-I${SMSRCDIR} ') + bldPRODUCT_START(`executable', `mail.local') define(`bldNO_INSTALL') define(`bldSOURCES', `mail.local.c ') bldPUSH_SMLIB(`smutil') -PREPENDDEF(`confENVDEF', `confMAPDEF') bldPRODUCT_END bldPRODUCT_START(`manpage', `mail.local') @@ -25,5 +29,3 @@ install-mail.local: mail.local divert bldFINISH - - diff --git a/contrib/sendmail/mail.local/mail.local.8 b/contrib/sendmail/mail.local/mail.local.8 index 40f4641..e6e8ea3 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,15 +8,15 @@ .\" 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 $ .\" -.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 "] [" \-d "] [" \-l "] [" \-f +.RB [ \-7 "] [" \-b "] [" \-d "] [" \-l "] [" \-f .IR from "] " "user ..." .SH DESCRIPTION .B Mail.local @@ -96,6 +96,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 1b9562b..8178f7b 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 */ /* @@ -32,215 +32,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 "/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 "/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 "/tmp/local.XXXXXX" -#endif /* ! _PATH_LOCTMP */ -# ifndef _PATH_MAILDIR -# define _PATH_MAILDIR "/var/spool/mail" -# endif /* ! _PATH_MAILDIR */ +# ifndef _PATH_LOCTMP +# define _PATH_LOCTMP "/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 */ @@ -525,7 +529,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; @@ -615,7 +620,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) @@ -798,7 +803,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 */ @@ -866,7 +871,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 @@ -927,7 +933,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); } @@ -1017,7 +1024,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); @@ -1025,8 +1032,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) @@ -1036,36 +1043,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; @@ -1076,9 +1108,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; @@ -1098,11 +1130,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, (long) curoff); + (void) snprintf(biffmsg, sizeof(biffmsg), "%s@%ld\n", + name, (long) curoff); /* Copy the message into the file. */ if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) @@ -1111,14 +1143,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 ; @@ -1187,7 +1213,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; } @@ -1234,7 +1261,7 @@ int lockmbox(name) char *name; { - int r; + int r = 0; if (Locked) return 0; @@ -1382,7 +1409,7 @@ void usage() { ExitVal = EX_USAGE; - mailerr(NULL, "usage: mail.local [-l] [-f from] user ..."); + mailerr(NULL, "usage: mail.local [-7] [-b] [-l] [-f from] user ..."); exit(ExitVal); } @@ -1658,8 +1685,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); |