summaryrefslogtreecommitdiff
path: root/usr.bin/mail
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-05-04 05:37:54 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-05-04 05:37:54 +0000
commit7c88b13a799889e879308794cf19b7522908d8df (patch)
tree0fecff7fd89b96609ed82fda93e33ca1cd6a5b82 /usr.bin/mail
parenta69cca63880811a6afaeb7a83b0dcc60b94ae4b0 (diff)
Never remove a mail spool, as we may not have proper prics, just truncate. Also block signals in a few critical areas
Diffstat (limited to 'usr.bin/mail')
-rw-r--r--usr.bin/mail/collect.c15
-rw-r--r--usr.bin/mail/lex.c8
-rw-r--r--usr.bin/mail/popen.c8
-rw-r--r--usr.bin/mail/v7.local.c8
4 files changed, 29 insertions, 10 deletions
diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c
index c4ee500e718..8f5492c1728 100644
--- a/usr.bin/mail/collect.c
+++ b/usr.bin/mail/collect.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: collect.c,v 1.15 1997/11/14 00:23:45 millert Exp $ */
+/* $OpenBSD: collect.c,v 1.16 1998/05/04 05:37:47 millert Exp $ */
/* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
#else
-static char rcsid[] = "$OpenBSD: collect.c,v 1.15 1997/11/14 00:23:45 millert Exp $";
+static char rcsid[] = "$OpenBSD: collect.c,v 1.16 1998/05/04 05:37:47 millert Exp $";
#endif
#endif /* not lint */
@@ -631,22 +631,29 @@ void
collint(s)
int s;
{
+ sigset_t set, oset;
+
/*
* the control flow is subtle, because we can be called from ~q.
*/
+ (void)sigfillset(&set);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
if (hadintr == 0 && isatty(0)) {
if (value("ignore") != NULL) {
puts("@");
fflush(stdout);
clearerr(stdin);
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
return;
}
hadintr = 1;
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
siglongjmp(colljmp, 1);
}
rewind(collf);
if (value("nosave") == NULL)
savedeadletter(collf);
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
siglongjmp(collabort, 1);
}
@@ -655,6 +662,10 @@ void
collhup(s)
int s;
{
+ sigset_t set;
+
+ (void)sigfillset(&set);
+ (void)sigprocmask(SIG_BLOCK, &set, NULL);
rewind(collf);
savedeadletter(collf);
/*
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index 79b3b8eed87..748e7ce6e3f 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.15 1997/11/14 00:23:48 millert Exp $ */
+/* $OpenBSD: lex.c,v 1.16 1998/05/04 05:37:49 millert Exp $ */
/* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95";
#else
-static char rcsid[] = "$OpenBSD: lex.c,v 1.15 1997/11/14 00:23:48 millert Exp $";
+static char rcsid[] = "$OpenBSD: lex.c,v 1.16 1998/05/04 05:37:49 millert Exp $";
#endif
#endif /* not lint */
@@ -549,7 +549,10 @@ void
intr(s)
int s;
{
+ sigset_t set, oset;
+ (void)sigfillset(&set);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
noreset = 0;
if (!inithdr)
sawcom++;
@@ -565,6 +568,7 @@ intr(s)
}
fputs("Interrupt\n", stderr);
reset(0);
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
}
/*
diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c
index 0d83687872b..59074db2bf3 100644
--- a/usr.bin/mail/popen.c
+++ b/usr.bin/mail/popen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popen.c,v 1.15 1998/02/15 21:20:02 niklas Exp $ */
+/* $OpenBSD: popen.c,v 1.16 1998/05/04 05:37:52 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.15 1998/02/15 21:20:02 niklas Exp $";
+static char rcsid[] = "$OpenBSD: popen.c,v 1.16 1998/05/04 05:37:52 millert Exp $";
#endif
#endif /* not lint */
@@ -356,7 +356,10 @@ sigchild(signo)
int status;
struct child *cp;
int save_errno = errno;
+ sigset_t set, oset;
+ (void)sigfillset(&set);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
while ((pid =
waitpid((pid_t)-1, &status, WNOHANG)) > 0) {
cp = findchild(pid, 1);
@@ -369,6 +372,7 @@ sigchild(signo)
cp->status = status;
}
}
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
errno = save_errno;
}
diff --git a/usr.bin/mail/v7.local.c b/usr.bin/mail/v7.local.c
index 05f32a040d7..467df474c1d 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.9 1997/07/30 06:32:41 millert Exp $ */
+/* $OpenBSD: v7.local.c,v 1.10 1998/05/04 05:37:53 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.9 1997/07/30 06:32:41 millert Exp $";
+static char rcsid[] = "$OpenBSD: v7.local.c,v 1.10 1998/05/04 05:37:53 millert Exp $";
#endif
#endif /* not lint */
@@ -86,8 +86,8 @@ void
demail()
{
- if (value("keep") != NULL || rm(mailname) < 0)
- (void)close(creat(mailname, 0600));
+ if (value("keep") != NULL)
+ (void)truncate(mailname, 0);
}
/*