diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2003-02-08 20:35:51 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2003-02-08 20:35:51 +0000 |
commit | 55f617e6f03e9e96b121cdde8289102d3a460b4e (patch) | |
tree | e9e902fe45cc13b5eeb0f81f2aa041f4296bdd54 /contrib/sendmail/mail.local | |
parent | 7bd0c4fe894c9bc5e90bb93736d3d0f84dc7a7dc (diff) | |
download | FreeBSD-src-55f617e6f03e9e96b121cdde8289102d3a460b4e.zip FreeBSD-src-55f617e6f03e9e96b121cdde8289102d3a460b4e.tar.gz |
Resolve conflicts from sendmail 8.12.7 import
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r-- | contrib/sendmail/mail.local/mail.local.c | 31 |
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 e6d6984..55857b9 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); |