diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-06-24 03:59:29 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-06-24 03:59:29 +0000 |
commit | 700c63457f17cd807c1f10effadddf89638c8258 (patch) | |
tree | c610339d5a972c74aaab5b63110f916bad0dc0be /gnu/usr.sbin/sendmail/libsmutil | |
parent | 42d2671ccee983bc79c99c98837fc58abd068775 (diff) |
Update to sendmail.8.13.0
Diffstat (limited to 'gnu/usr.sbin/sendmail/libsmutil')
-rw-r--r-- | gnu/usr.sbin/sendmail/libsmutil/cf.c | 2 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsmutil/lockfile.c | 3 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsmutil/safefile.c | 32 |
3 files changed, 32 insertions, 5 deletions
diff --git a/gnu/usr.sbin/sendmail/libsmutil/cf.c b/gnu/usr.sbin/sendmail/libsmutil/cf.c index 6f4546443e8..411adf5dfbd 100644 --- a/gnu/usr.sbin/sendmail/libsmutil/cf.c +++ b/gnu/usr.sbin/sendmail/libsmutil/cf.c @@ -9,7 +9,7 @@ */ #include <sendmail.h> -SM_RCSID("@(#)$Sendmail: cf.c,v 8.18.2.1 2002/09/24 21:48:23 ca Exp $") +SM_RCSID("@(#)$Sendmail: cf.c,v 8.19 2002/09/24 20:40:59 ca Exp $") #include <sendmail/pathnames.h> /* diff --git a/gnu/usr.sbin/sendmail/libsmutil/lockfile.c b/gnu/usr.sbin/sendmail/libsmutil/lockfile.c index 9b6eb4df596..bea6633eb1c 100644 --- a/gnu/usr.sbin/sendmail/libsmutil/lockfile.c +++ b/gnu/usr.sbin/sendmail/libsmutil/lockfile.c @@ -13,7 +13,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Sendmail: lockfile.c,v 8.19 2001/09/11 04:04:55 gshapiro Exp $") +SM_RCSID("@(#)$Sendmail: 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/gnu/usr.sbin/sendmail/libsmutil/safefile.c b/gnu/usr.sbin/sendmail/libsmutil/safefile.c index a633d5dadd9..8488c187019 100644 --- a/gnu/usr.sbin/sendmail/libsmutil/safefile.c +++ b/gnu/usr.sbin/sendmail/libsmutil/safefile.c @@ -15,7 +15,7 @@ #include <sm/io.h> #include <sm/errstring.h> -SM_RCSID("@(#)$Sendmail: safefile.c,v 8.124 2002/05/24 20:50:15 gshapiro Exp $") +SM_RCSID("@(#)$Sendmail: 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; |