diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2004-08-01 01:04:57 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2004-08-01 01:04:57 +0000 |
commit | 1fc446a819a244515d9461fa50d34ee191414d6f (patch) | |
tree | f6477ae85b00ee6d58b086b0d1d597dd9a403391 /contrib/sendmail/libsmutil | |
parent | 238623a0204c90e8d61dbde7b3b499a5036f2e5d (diff) | |
download | FreeBSD-src-1fc446a819a244515d9461fa50d34ee191414d6f.zip FreeBSD-src-1fc446a819a244515d9461fa50d34ee191414d6f.tar.gz |
Import sendmail 8.13.1
Diffstat (limited to 'contrib/sendmail/libsmutil')
-rw-r--r-- | contrib/sendmail/libsmutil/Makefile.m4 | 2 | ||||
-rw-r--r-- | contrib/sendmail/libsmutil/cf.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/libsmutil/lockfile.c | 3 | ||||
-rw-r--r-- | contrib/sendmail/libsmutil/safefile.c | 32 |
4 files changed, 33 insertions, 6 deletions
diff --git a/contrib/sendmail/libsmutil/Makefile.m4 b/contrib/sendmail/libsmutil/Makefile.m4 index 36c5d7a..ea37305 100644 --- a/contrib/sendmail/libsmutil/Makefile.m4 +++ b/contrib/sendmail/libsmutil/Makefile.m4 @@ -1,4 +1,4 @@ -dnl $Id: Makefile.m4,v 8.16.4.1 2002/06/21 21:58:35 ca Exp $ +dnl $Id: Makefile.m4,v 8.17 2002/06/21 22:01:34 ca Exp $ include(confBUILDTOOLSDIR`/M4/switch.m4') define(`confREQUIRE_LIBSM', `true') diff --git a/contrib/sendmail/libsmutil/cf.c b/contrib/sendmail/libsmutil/cf.c index 1db2a67..f313762 100644 --- a/contrib/sendmail/libsmutil/cf.c +++ b/contrib/sendmail/libsmutil/cf.c @@ -9,7 +9,7 @@ */ #include <sendmail.h> -SM_RCSID("@(#)$Id: cf.c,v 8.18.2.1 2002/09/24 21:48:23 ca Exp $") +SM_RCSID("@(#)$Id: cf.c,v 8.19 2002/09/24 20:40:59 ca Exp $") #include <sendmail/pathnames.h> /* diff --git a/contrib/sendmail/libsmutil/lockfile.c b/contrib/sendmail/libsmutil/lockfile.c index 5eca360..17d6237 100644 --- a/contrib/sendmail/libsmutil/lockfile.c +++ b/contrib/sendmail/libsmutil/lockfile.c @@ -13,7 +13,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: lockfile.c,v 8.19 2001/09/11 04:04:55 gshapiro Exp $") +SM_RCSID("@(#)$Id: lockfile.c,v 8.21 2003/11/10 22:57:38 ca Exp $") /* @@ -43,7 +43,6 @@ lockfile(fd, filename, ext, type) #if !HASFLOCK int action; struct flock lfd; - extern int errno; memset(&lfd, '\0', sizeof lfd); if (bitset(LOCK_UN, type)) diff --git a/contrib/sendmail/libsmutil/safefile.c b/contrib/sendmail/libsmutil/safefile.c index aed40a0..c6cfb53 100644 --- a/contrib/sendmail/libsmutil/safefile.c +++ b/contrib/sendmail/libsmutil/safefile.c @@ -15,7 +15,7 @@ #include <sm/io.h> #include <sm/errstring.h> -SM_RCSID("@(#)$Id: safefile.c,v 8.124 2002/05/24 20:50:15 gshapiro Exp $") +SM_RCSID("@(#)$Id: safefile.c,v 8.127 2004/05/27 22:37:51 msk Exp $") /* @@ -304,7 +304,7 @@ safefile(fn, uid, gid, user, flags, mode, st) bitset(S_IXUSR|S_IXGRP|S_IXOTH, st->st_mode)) { if (tTd(44, 4)) - sm_dprintf("\t[exec bits %lo]\tE_SM_ISEXEC]\n", + sm_dprintf("\t[exec bits %lo]\tE_SM_ISEXEC\n", (unsigned long) st->st_mode); return E_SM_ISEXEC; } @@ -684,6 +684,9 @@ safeopen(fn, omode, cmode, sff) int cmode; long sff; { +#if !NOFTRUNCATE + bool truncate; +#endif /* !NOFTRUNCATE */ int rval; int fd; int smode; @@ -735,6 +738,12 @@ safeopen(fn, omode, cmode, sff) return -1; } +#if !NOFTRUNCATE + truncate = bitset(O_TRUNC, omode); + if (truncate) + omode &= ~O_TRUNC; +#endif /* !NOFTRUNCATE */ + fd = dfopen(fn, omode, cmode, sff); if (fd < 0) return fd; @@ -745,6 +754,22 @@ safeopen(fn, omode, cmode, sff) errno = E_SM_FILECHANGE; return -1; } + +#if !NOFTRUNCATE + if (truncate && + ftruncate(fd, (off_t) 0) < 0) + { + int save_errno; + + save_errno = errno; + syserr("554 5.3.0 cannot open: file %s could not be truncated", + fn); + (void) close(fd); + errno = save_errno; + return -1; + } +#endif /* !NOFTRUNCATE */ + return fd; } /* @@ -940,6 +965,9 @@ dfopen(filename, omode, cmode, sff) locktype = LOCK_EX; else locktype = LOCK_SH; + if (bitset(SFF_NBLOCK, sff)) + locktype |= LOCK_NB; + if (!lockfile(fd, filename, NULL, locktype)) { int save_errno = errno; |