diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-12 17:51:54 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-12 17:51:54 +0000 |
commit | 7a7f36bfa25dfe05f4e3efaa2cae3267993d48de (patch) | |
tree | 7ad2a9d3740dd68469c74664e76c510bb3bfa35c | |
parent | a0ceaddf9d85bcb4241b5053b342cee85c041e77 (diff) |
Don't call truncate() directly; have rm() do it if we get EPERM on unlink()
In popen.c, findchild() may return NULL so catch that case.
-rw-r--r-- | usr.bin/mail/fio.c | 14 | ||||
-rw-r--r-- | usr.bin/mail/popen.c | 10 | ||||
-rw-r--r-- | usr.bin/mail/quit.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/v7.local.c | 6 |
4 files changed, 24 insertions, 12 deletions
diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c index 139c4eef2e0..01a1647bf7f 100644 --- a/usr.bin/mail/fio.c +++ b/usr.bin/mail/fio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fio.c,v 1.15 1998/06/11 06:20:18 deraadt Exp $ */ +/* $OpenBSD: fio.c,v 1.16 1998/06/12 17:51:51 millert Exp $ */ /* $NetBSD: fio.c,v 1.8 1997/07/07 22:57:55 phil Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: fio.c,v 1.15 1998/06/11 06:20:18 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: fio.c,v 1.16 1998/06/12 17:51:51 millert Exp $"; #endif #endif /* not lint */ @@ -271,7 +271,7 @@ append(mp, f) } /* - * Delete a file, but only if the file is a plain file. + * Delete or truncate a file, but only if the file is a plain file. */ int rm(name) @@ -285,7 +285,13 @@ rm(name) errno = EISDIR; return(-1); } - return(unlink(name)); + if (unlink(name) == -1) { + if (errno == EPERM) + return(truncate(name, 0)); + else + return(-1); + } + return(0); } static int sigdepth; /* depth of holdsigs() */ diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index 59074db2bf3..2292b7dc5ba 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.16 1998/05/04 05:37:52 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.17 1998/06/12 17:51:53 millert Exp $ */ /* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: popen.c,v 1.16 1998/05/04 05:37:52 millert Exp $"; +static char rcsid[] = "$OpenBSD: popen.c,v 1.17 1998/06/12 17:51:53 millert Exp $"; #endif #endif /* not lint */ @@ -388,6 +388,9 @@ wait_child(pid) struct child *cp = findchild(pid, 0); sigset_t nset, oset; + if (cp == NULL) + return(-1); + sigemptyset(&nset); sigaddset(&nset, SIGCHLD); sigprocmask(SIG_BLOCK, &nset, &oset); @@ -410,6 +413,9 @@ free_child(pid) struct child *cp = findchild(pid, 0); sigset_t nset, oset; + if (cp == NULL) + return; + sigemptyset(&nset); sigaddset(&nset, SIGCHLD); sigprocmask(SIG_BLOCK, &nset, &oset); diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c index f97de5e195e..183d64b4e6c 100644 --- a/usr.bin/mail/quit.c +++ b/usr.bin/mail/quit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quit.c,v 1.9 1997/11/14 00:23:55 millert Exp $ */ +/* $OpenBSD: quit.c,v 1.10 1998/06/12 17:51:52 millert Exp $ */ /* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: quit.c,v 1.9 1997/11/14 00:23:55 millert Exp $"; +static char rcsid[] = "$OpenBSD: quit.c,v 1.10 1998/06/12 17:51:52 millert Exp $"; #endif #endif /* not lint */ @@ -323,7 +323,7 @@ quit() } /* - * Finally, remove his /usr/mail file. + * Finally, remove his /var/mail file. * If new mail has arrived, copy it back. */ diff --git a/usr.bin/mail/v7.local.c b/usr.bin/mail/v7.local.c index 1bd7e77e336..050052f1246 100644 --- a/usr.bin/mail/v7.local.c +++ b/usr.bin/mail/v7.local.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v7.local.c,v 1.11 1998/06/12 17:15:24 millert Exp $ */ +/* $OpenBSD: v7.local.c,v 1.12 1998/06/12 17:51:50 millert Exp $ */ /* $NetBSD: v7.local.c,v 1.8 1997/05/13 06:15:58 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: v7.local.c,v 1.11 1998/06/12 17:15:24 millert Exp $"; +static char rcsid[] = "$OpenBSD: v7.local.c,v 1.12 1998/06/12 17:51:50 millert Exp $"; #endif #endif /* not lint */ @@ -86,7 +86,7 @@ void demail() { - if (value("keep") != NULL || truncate(mailname, 0) == -1) + if (value("keep") != NULL || rm(mailname) < 0) (void)close(creat(mailname, 0600)); } |