aboutsummaryrefslogtreecommitdiff
path: root/contrib/sendmail/mail.local
diff options
context:
space:
mode:
authorGregory Neil Shapiro <gshapiro@FreeBSD.org>2003-02-08 20:35:51 +0000
committerGregory Neil Shapiro <gshapiro@FreeBSD.org>2003-02-08 20:35:51 +0000
commit2ef40764f06885f97d380ee8de0ced64930423db (patch)
treee9e902fe45cc13b5eeb0f81f2aa041f4296bdd54 /contrib/sendmail/mail.local
parent9e80f49658bb874247c840b7a5989b0a38553927 (diff)
downloadsrc-2ef40764f06885f97d380ee8de0ced64930423db.tar.gz
src-2ef40764f06885f97d380ee8de0ced64930423db.zip
Resolve conflicts from sendmail 8.12.7 import
Notes
Notes: svn path=/head/; revision=110563
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r--contrib/sendmail/mail.local/mail.local.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/contrib/sendmail/mail.local/mail.local.c b/contrib/sendmail/mail.local/mail.local.c
index e6d6984d01a6..55857b913399 100644
--- a/contrib/sendmail/mail.local/mail.local.c
+++ b/contrib/sendmail/mail.local/mail.local.c
@@ -20,7 +20,7 @@ SM_IDSTR(copyright,
Copyright (c) 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n")
-SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239 2002/05/24 20:56:32 gshapiro Exp $")
+SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239.2.2 2002/09/24 02:09:09 ca Exp $")
#include <stdlib.h>
#include <sm/errstring.h>
@@ -670,6 +670,8 @@ store(from, inbody)
(void) sm_strlcpy(tmpbuf, _PATH_LOCTMP, sizeof tmpbuf);
if ((fd = mkstemp(tmpbuf)) < 0 || (fp = fdopen(fd, "w+")) == NULL)
{
+ if (fd >= 0)
+ (void) close(fd);
mailerr("451 4.3.0", "Unable to open temporary file");
return -1;
}
@@ -1217,7 +1219,8 @@ err3:
#ifdef DEBUG
fprintf(stderr, "reset euid = %d\n", (int) geteuid());
#endif /* DEBUG */
- (void) ftruncate(mbfd, curoff);
+ if (mbfd >= 0)
+ (void) ftruncate(mbfd, curoff);
err1: if (mbfd >= 0)
(void) close(mbfd);
err0: unlockmbox();
@@ -1233,7 +1236,29 @@ err0: unlockmbox();
errcode = "552 5.2.2";
#endif /* EDQUOT */
mailerr(errcode, "%s: %s", path, sm_errstring(errno));
- (void) truncate(path, curoff);
+ mbfd = open(path, O_WRONLY|EXTRA_MODE, 0);
+ if (mbfd < 0
+ || fstat(mbfd, &sb) < 0 ||
+ sb.st_nlink != 1 ||
+ !S_ISREG(sb.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 */
+ sb.st_gen != fsb.st_gen ||
+# endif /* HAS_ST_GEN && 0 */
+ sb.st_uid != fsb.st_uid
+ )
+ {
+ /* Don't use a bogus file */
+ if (mbfd >= 0)
+ {
+ (void) close(mbfd);
+ mbfd = -1;
+ }
+ }
+
+ /* Attempt to truncate back to pre-write size */
+ goto err3;
}
else if (!nobiff)
notifybiff(biffmsg);