summaryrefslogtreecommitdiff
path: root/usr.bin/mail
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-11 12:54:26 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-11 12:54:26 +0000
commit1c5940ab5503bf389f03195f3d01a93353919abb (patch)
treea1e9691c11b7f36906f0943dc7d8464a56b98adc /usr.bin/mail
parent5f733ec731243d90e1e65f27ce29e683e7a253a6 (diff)
from christos;
- Fix PR/105: Implement dot locking protocol and check return value of flock. - Fix PR/2247: Don't call unknown users "ubluit". Issue an error message. - Fix/add prototypes. - Fix warnings. - Use POSIX signal mask calls.
Diffstat (limited to 'usr.bin/mail')
-rw-r--r--usr.bin/mail/Makefile10
-rw-r--r--usr.bin/mail/USD.doc/Makefile3
-rw-r--r--usr.bin/mail/USD.doc/mail0.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail1.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail2.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail3.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail4.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail5.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail6.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail7.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail8.nr2
-rw-r--r--usr.bin/mail/USD.doc/mail9.nr2
-rw-r--r--usr.bin/mail/USD.doc/maila.nr2
-rw-r--r--usr.bin/mail/aux.c31
-rw-r--r--usr.bin/mail/cmd1.c78
-rw-r--r--usr.bin/mail/cmd2.c77
-rw-r--r--usr.bin/mail/cmd3.c105
-rw-r--r--usr.bin/mail/cmdtab.c148
-rw-r--r--usr.bin/mail/collect.c42
-rw-r--r--usr.bin/mail/def.h8
-rw-r--r--usr.bin/mail/dotlock.c198
-rw-r--r--usr.bin/mail/edit.c20
-rw-r--r--usr.bin/mail/extern.h127
-rw-r--r--usr.bin/mail/fio.c25
-rw-r--r--usr.bin/mail/getname.c13
-rw-r--r--usr.bin/mail/glob.h5
-rw-r--r--usr.bin/mail/head.c12
-rw-r--r--usr.bin/mail/lex.c32
-rw-r--r--usr.bin/mail/list.c44
-rw-r--r--usr.bin/mail/mail.12
-rw-r--r--usr.bin/mail/main.c13
-rw-r--r--usr.bin/mail/names.c22
-rw-r--r--usr.bin/mail/pathnames.h7
-rw-r--r--usr.bin/mail/popen.c62
-rw-r--r--usr.bin/mail/quit.c44
-rw-r--r--usr.bin/mail/rcv.h7
-rw-r--r--usr.bin/mail/send.c36
-rw-r--r--usr.bin/mail/strings.c10
-rw-r--r--usr.bin/mail/temp.c17
-rw-r--r--usr.bin/mail/tty.c33
-rw-r--r--usr.bin/mail/v7.local.c16
-rw-r--r--usr.bin/mail/vars.c10
-rw-r--r--usr.bin/mail/version.c10
43 files changed, 899 insertions, 390 deletions
diff --git a/usr.bin/mail/Makefile b/usr.bin/mail/Makefile
index f67171f6e18..a04338e4334 100644
--- a/usr.bin/mail/Makefile
+++ b/usr.bin/mail/Makefile
@@ -1,10 +1,10 @@
-# $OpenBSD: Makefile,v 1.2 1996/03/27 19:32:29 niklas Exp $
-# from: @(#)Makefile 8.2 (Berkeley) 1/25/94
+# $OpenBSD: Makefile,v 1.3 1996/06/11 12:53:31 deraadt Exp $
+# $NetBSD: Makefile,v 1.8 1996/06/08 19:48:09 christos Exp $
PROG= mail
-SRCS= version.c aux.c cmd1.c cmd2.c cmd3.c cmdtab.c collect.c edit.c fio.c \
- getname.c head.c v7.local.c lex.c list.c main.c names.c popen.c \
- quit.c send.c strings.c temp.c tty.c vars.c
+SRCS= version.c aux.c cmd1.c cmd2.c cmd3.c cmdtab.c collect.c dotlock.c \
+ edit.c fio.c getname.c head.c v7.local.c lex.c list.c main.c names.c \
+ popen.c quit.c send.c strings.c temp.c tty.c vars.c
SFILES= mail.help mail.tildehelp
EFILES= mail.rc
LINKS= ${BINDIR}/mail ${BINDIR}/Mail ${BINDIR}/mail ${BINDIR}/mailx
diff --git a/usr.bin/mail/USD.doc/Makefile b/usr.bin/mail/USD.doc/Makefile
index e0d58da9368..affbe897365 100644
--- a/usr.bin/mail/USD.doc/Makefile
+++ b/usr.bin/mail/USD.doc/Makefile
@@ -1,5 +1,4 @@
-# from: @(#)Makefile 8.1 (Berkeley) 6/8/93
-# $Id: Makefile,v 1.1 1995/10/18 08:45:39 deraadt Exp $
+# $OpenBSD: Makefile,v 1.2 1996/06/11 12:54:17 deraadt Exp $
DIR= usd/07.mail
SRCS= mail0.nr mail1.nr mail2.nr mail3.nr mail4.nr mail5.nr mail6.nr \
diff --git a/usr.bin/mail/USD.doc/mail0.nr b/usr.bin/mail/USD.doc/mail0.nr
index 15955be564e..73431aad098 100644
--- a/usr.bin/mail/USD.doc/mail0.nr
+++ b/usr.bin/mail/USD.doc/mail0.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail0.nr,v 1.2 1996/06/11 12:54:18 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail1.nr b/usr.bin/mail/USD.doc/mail1.nr
index bbb920de359..4e0176fcf56 100644
--- a/usr.bin/mail/USD.doc/mail1.nr
+++ b/usr.bin/mail/USD.doc/mail1.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail1.nr,v 1.2 1996/06/11 12:54:18 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail2.nr b/usr.bin/mail/USD.doc/mail2.nr
index f64aaa6eda8..454de8715bc 100644
--- a/usr.bin/mail/USD.doc/mail2.nr
+++ b/usr.bin/mail/USD.doc/mail2.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail2.nr,v 1.2 1996/06/11 12:54:19 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail3.nr b/usr.bin/mail/USD.doc/mail3.nr
index 64f7634462d..d6477b657b8 100644
--- a/usr.bin/mail/USD.doc/mail3.nr
+++ b/usr.bin/mail/USD.doc/mail3.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail3.nr,v 1.2 1996/06/11 12:54:20 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail4.nr b/usr.bin/mail/USD.doc/mail4.nr
index b67bf0385b4..103d10b5f3d 100644
--- a/usr.bin/mail/USD.doc/mail4.nr
+++ b/usr.bin/mail/USD.doc/mail4.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail4.nr,v 1.2 1996/06/11 12:54:20 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail5.nr b/usr.bin/mail/USD.doc/mail5.nr
index b70ce950460..fa7e2bbbd56 100644
--- a/usr.bin/mail/USD.doc/mail5.nr
+++ b/usr.bin/mail/USD.doc/mail5.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail5.nr,v 1.2 1996/06/11 12:54:21 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail6.nr b/usr.bin/mail/USD.doc/mail6.nr
index e016234633c..a8f1dae0235 100644
--- a/usr.bin/mail/USD.doc/mail6.nr
+++ b/usr.bin/mail/USD.doc/mail6.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail6.nr,v 1.2 1996/06/11 12:54:22 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail7.nr b/usr.bin/mail/USD.doc/mail7.nr
index 0b2590b19fc..c7da12026af 100644
--- a/usr.bin/mail/USD.doc/mail7.nr
+++ b/usr.bin/mail/USD.doc/mail7.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail7.nr,v 1.2 1996/06/11 12:54:23 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail8.nr b/usr.bin/mail/USD.doc/mail8.nr
index e8e056b81d2..491c7353a05 100644
--- a/usr.bin/mail/USD.doc/mail8.nr
+++ b/usr.bin/mail/USD.doc/mail8.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail8.nr,v 1.2 1996/06/11 12:54:24 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/mail9.nr b/usr.bin/mail/USD.doc/mail9.nr
index 99f7518e845..fc5f2c183ab 100644
--- a/usr.bin/mail/USD.doc/mail9.nr
+++ b/usr.bin/mail/USD.doc/mail9.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: mail9.nr,v 1.2 1996/06/11 12:54:24 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/USD.doc/maila.nr b/usr.bin/mail/USD.doc/maila.nr
index 84b01fede67..3a66facc7db 100644
--- a/usr.bin/mail/USD.doc/maila.nr
+++ b/usr.bin/mail/USD.doc/maila.nr
@@ -1,3 +1,5 @@
+.\" $OpenBSD: maila.nr,v 1.2 1996/06/11 12:54:25 deraadt Exp $
+.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c
index c7bfb6421eb..66bf4e73a7e 100644
--- a/usr.bin/mail/aux.c
+++ b/usr.bin/mail/aux.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: aux.c,v 1.2 1996/06/11 12:53:32 deraadt Exp $ */
+/* $NetBSD: aux.c,v 1.4 1996/06/08 19:48:10 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)aux.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: aux.c,v 1.1 1995/10/18 08:45:37 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: aux.c,v 1.2 1996/06/11 12:53:32 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -44,6 +50,7 @@ static char rcsid[] = "$Id: aux.c,v 1.1 1995/10/18 08:45:37 deraadt Exp $";
*
* Auxiliary functions.
*/
+static char *save2str __P((char *, char *));
/*
* Return a pointer to a dynamic copy of the argument.
@@ -63,7 +70,7 @@ savestr(str)
/*
* Make a copy of new argument incorporating old one.
*/
-char *
+static char *
save2str(str, old)
char *str, *old;
{
@@ -180,7 +187,7 @@ hfield(field, mp)
while (lc > 0) {
if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0)
return oldhfield;
- if (hfield = ishfield(linebuf, colon, field))
+ if ((hfield = ishfield(linebuf, colon, field)) != NULL)
oldhfield = save2str(hfield, oldhfield);
}
return oldhfield;
@@ -304,9 +311,10 @@ struct sstack {
* that they are no longer reading from a tty (in all probability).
*/
int
-source(arglist)
- char **arglist;
+source(v)
+ void *v;
{
+ char **arglist = v;
FILE *fi;
char *cp;
@@ -366,7 +374,6 @@ alter(name)
{
struct stat sb;
struct timeval tv[2];
- time_t time();
if (stat(name, &sb))
return;
@@ -465,7 +472,7 @@ skin(name)
gotlt = 0;
lastsp = 0;
bufend = nbuf;
- for (cp = name, cp2 = bufend; c = *cp++; ) {
+ for (cp = name, cp2 = bufend; (c = *cp++) != '\0'; ) {
switch (c) {
case '(':
cp = skip_comment(cp);
@@ -477,13 +484,13 @@ skin(name)
* Start of a "quoted-string".
* Copy it in its entirety.
*/
- while (c = *cp) {
+ while ((c = *cp) != '\0') {
cp++;
if (c == '"')
break;
if (c != '\\')
*cp2++ = c;
- else if (c = *cp) {
+ else if ((c = *cp) != '\0') {
*cp2++ = c;
cp++;
}
@@ -515,7 +522,7 @@ skin(name)
if (c == '(')
cp = skip_comment(cp);
else if (c == '"')
- while (c = *cp) {
+ while ((c = *cp) != '\0') {
cp++;
if (c == '"')
break;
@@ -663,7 +670,7 @@ copy(s1, s2)
register char *s1, *s2;
{
- while (*s2++ = *s1++)
+ while ((*s2++ = *s1++) != '\0')
;
return s2 - 1;
}
diff --git a/usr.bin/mail/cmd1.c b/usr.bin/mail/cmd1.c
index 21f2e7b274c..3ec58dd05f4 100644
--- a/usr.bin/mail/cmd1.c
+++ b/usr.bin/mail/cmd1.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: cmd1.c,v 1.2 1996/03/27 19:32:30 niklas Exp $ */
+/* $OpenBSD: cmd1.c,v 1.3 1996/06/11 12:53:32 deraadt Exp $ */
+/* $NetBSD: cmd1.c,v 1.5 1996/06/08 19:48:11 christos Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -34,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)cmd1.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: cmd1.c,v 1.2 1996/03/27 19:32:30 niklas Exp $";
+#if 0
+static char sccsid[] = "@(#)cmd1.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: cmd1.c,v 1.3 1996/06/11 12:53:32 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -55,9 +59,10 @@ static char rcsid[] = "$OpenBSD: cmd1.c,v 1.2 1996/03/27 19:32:30 niklas Exp $";
static int screen;
int
-headers(msgvec)
- int *msgvec;
+headers(v)
+ void *v;
{
+ int *msgvec = v;
register int n, mesg, flag;
register struct message *mp;
int size;
@@ -96,9 +101,10 @@ headers(msgvec)
* Scroll to the next/previous screen
*/
int
-scroll(arg)
- char arg[];
+scroll(v)
+ void *v;
{
+ char *arg = v;
register int s, size;
int cur[1];
@@ -150,9 +156,10 @@ screensize()
* in the passed message list.
*/
int
-from(msgvec)
- int *msgvec;
+from(v)
+ void *v;
{
+ int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != NULL; ip++)
@@ -214,7 +221,8 @@ printhead(mesg)
* Print out the value of dot.
*/
int
-pdot()
+pdot(v)
+ void *v;
{
printf("%d\n", dot - &message[0] + 1);
return(0);
@@ -224,7 +232,8 @@ pdot()
* Print out all the possible commands.
*/
int
-pcmdlist()
+pcmdlist(v)
+ void *v;
{
extern const struct cmd cmdtab[];
register const struct cmd *cp;
@@ -249,9 +258,10 @@ pcmdlist()
* Paginate messages, honor ignored fields.
*/
int
-more(msgvec)
- int *msgvec;
+more(v)
+ void *v;
{
+ int *msgvec = v;
return (type1(msgvec, 1, 1));
}
@@ -259,9 +269,10 @@ more(msgvec)
* Paginate messages, even printing ignored fields.
*/
int
-More(msgvec)
- int *msgvec;
+More(v)
+ void *v;
{
+ int *msgvec = v;
return (type1(msgvec, 0, 1));
}
@@ -270,9 +281,10 @@ More(msgvec)
* Type out messages, honor ignored fields.
*/
int
-type(msgvec)
- int *msgvec;
+type(v)
+ void *v;
{
+ int *msgvec = v;
return(type1(msgvec, 1, 0));
}
@@ -281,9 +293,10 @@ type(msgvec)
* Type out messages, even printing ignored fields.
*/
int
-Type(msgvec)
- int *msgvec;
+Type(v)
+ void *v;
{
+ int *msgvec = v;
return(type1(msgvec, 0, 0));
}
@@ -298,10 +311,15 @@ type1(msgvec, doign, page)
int doign, page;
{
register *ip;
- register struct message *mp;
- register char *cp;
+ struct message *mp;
+ char *cp;
int nlines;
FILE *obuf;
+#if __GNUC__
+ /* Avoid longjmp clobbering */
+ (void) &cp;
+ (void) &obuf;
+#endif
obuf = stdout;
if (setjmp(pipestop))
@@ -362,9 +380,10 @@ brokpipe(signo)
* and defaults to 5.
*/
int
-top(msgvec)
- int *msgvec;
+top(v)
+ void *v;
{
+ int *msgvec = v;
register int *ip;
register struct message *mp;
int c, topl, lines, lineb;
@@ -404,9 +423,10 @@ top(msgvec)
* get mboxed.
*/
int
-stouch(msgvec)
- int msgvec[];
+stouch(v)
+ void *v;
{
+ int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
@@ -421,9 +441,10 @@ stouch(msgvec)
* Make sure all passed messages get mboxed.
*/
int
-mboxit(msgvec)
- int msgvec[];
+mboxit(v)
+ void *v;
{
+ int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
@@ -438,7 +459,8 @@ mboxit(msgvec)
* List the folders the user currently has.
*/
int
-folders()
+folders(v)
+ void *v;
{
char dirname[BUFSIZ];
char *cmd;
diff --git a/usr.bin/mail/cmd2.c b/usr.bin/mail/cmd2.c
index 249b4fb2aed..3c71588f03d 100644
--- a/usr.bin/mail/cmd2.c
+++ b/usr.bin/mail/cmd2.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: cmd2.c,v 1.2 1996/06/11 12:53:33 deraadt Exp $ */
+/* $NetBSD: cmd2.c,v 1.5 1996/06/08 19:48:13 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)cmd2.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: cmd2.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: cmd2.c,v 1.2 1996/06/11 12:53:33 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -45,6 +51,7 @@ static char rcsid[] = "$Id: cmd2.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
*
* More user commands.
*/
+static int igcomp __P((const void *, const void *));
/*
* If any arguments were given, go to the next applicable argument
@@ -52,9 +59,10 @@ static char rcsid[] = "$Id: cmd2.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
* If given as first command with no arguments, print first message.
*/
int
-next(msgvec)
- int *msgvec;
+next(v)
+ void *v;
{
+ int *msgvec = v;
register struct message *mp;
register int *ip, *ip2;
int list[2], mdot;
@@ -131,9 +139,10 @@ hitit:
* so we can discard when the user quits.
*/
int
-save(str)
- char str[];
+save(v)
+ void *v;
{
+ char *str = v;
return save1(str, 1, "save", saveignore);
}
@@ -142,9 +151,10 @@ save(str)
* Copy a message to a file without affected its saved-ness
*/
int
-copycmd(str)
- char str[];
+copycmd(v)
+ void *v;
{
+ char *str = v;
return save1(str, 0, "copy", saveignore);
}
@@ -215,9 +225,10 @@ save1(str, mark, cmd, ignore)
* file name, minus header and trailing blank line.
*/
int
-swrite(str)
- char str[];
+swrite(v)
+ void *v;
{
+ char *str = v;
return save1(str, 1, "write", ignoreall);
}
@@ -270,9 +281,10 @@ snarf(linebuf, flag)
* Delete messages.
*/
int
-delete(msgvec)
- int msgvec[];
+delete(v)
+ void *v;
{
+ int *msgvec = v;
delm(msgvec);
return 0;
}
@@ -281,9 +293,10 @@ delete(msgvec)
* Delete messages, then type the new dot.
*/
int
-deltype(msgvec)
- int msgvec[];
+deltype(v)
+ void *v;
{
+ int *msgvec = v;
int list[2];
int lastdot;
@@ -346,9 +359,10 @@ delm(msgvec)
* Undelete the indicated messages.
*/
int
-undeletecmd(msgvec)
- int *msgvec;
+undeletecmd(v)
+ void *v;
{
+ int *msgvec = v;
register struct message *mp;
register *ip;
@@ -365,7 +379,8 @@ undeletecmd(msgvec)
* Interactively dump core on "core"
*/
int
-core()
+core(v)
+ void *v;
{
int pid;
extern union wait wait_status;
@@ -392,9 +407,10 @@ core()
* Clobber as many bytes of stack as the user requests.
*/
int
-clobber(argv)
- char **argv;
+clobber(v)
+ void *v;
{
+ char **argv = v;
register int times;
if (argv[0] == 0)
@@ -427,9 +443,10 @@ clob1(n)
* If no arguments, print the current list of retained fields.
*/
int
-retfield(list)
- char *list[];
+retfield(v)
+ void *v;
{
+ char **list = v;
return ignore1(list, ignore + 1, "retained");
}
@@ -439,25 +456,28 @@ retfield(list)
* If no arguments, print the current list of ignored fields.
*/
int
-igfield(list)
- char *list[];
+igfield(v)
+ void *v;
{
+ char **list = v;
return ignore1(list, ignore, "ignored");
}
int
-saveretfield(list)
- char *list[];
+saveretfield(v)
+ void *v;
{
+ char **list = v;
return ignore1(list, saveignore + 1, "retained");
}
int
-saveigfield(list)
- char *list[];
+saveigfield(v)
+ void *v;
{
+ char **list = v;
return ignore1(list, saveignore, "ignored");
}
@@ -502,7 +522,6 @@ igshow(tab, which)
register int h;
struct ignore *igp;
char **ap, **ring;
- int igcomp();
if (tab->i_count == 0) {
printf("No fields currently being %s.\n", which);
@@ -523,7 +542,7 @@ igshow(tab, which)
/*
* Compare two names for sorting ignored field list.
*/
-int
+static int
igcomp(l, r)
const void *l, *r;
{
diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c
index e70ff53b3ae..ce3ec6bc805 100644
--- a/usr.bin/mail/cmd3.c
+++ b/usr.bin/mail/cmd3.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: cmd3.c,v 1.2 1996/06/11 12:53:34 deraadt Exp $ */
+/* $NetBSD: cmd3.c,v 1.5 1996/06/08 19:48:14 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)cmd3.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: cmd3.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
+#else
+static char rcsid[] = "$OpenBSD: cmd3.c,v 1.2 1996/06/11 12:53:34 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -44,15 +50,17 @@ static char rcsid[] = "$Id: cmd3.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
*
* Still more user commands.
*/
+static int diction __P((const void *, const void *));
/*
* Process a shell escape by saving signals, ignoring signals,
* and forking a sh -c
*/
int
-shell(str)
- char *str;
+shell(v)
+ void *v;
{
+ char *str = v;
sig_t sigint = signal(SIGINT, SIG_IGN);
char *shell;
char cmd[BUFSIZ];
@@ -73,8 +81,8 @@ shell(str)
*/
/*ARGSUSED*/
int
-dosh(str)
- char *str;
+dosh(v)
+ void *v;
{
sig_t sigint = signal(SIGINT, SIG_IGN);
char *shell;
@@ -147,7 +155,8 @@ overf:
*/
int
-help()
+help(v)
+ void *v;
{
register c;
register FILE *f;
@@ -166,9 +175,10 @@ help()
* Change user's working directory.
*/
int
-schdir(arglist)
- char **arglist;
+schdir(v)
+ void *v;
{
+ char **arglist = v;
char *cp;
if (*arglist == NOSTR)
@@ -184,9 +194,10 @@ schdir(arglist)
}
int
-respond(msgvec)
- int *msgvec;
+respond(v)
+ void *v;
{
+ int *msgvec = v;
if (value("Replyall") == NOSTR)
return (_respond(msgvec));
else
@@ -284,9 +295,10 @@ reedit(subj)
* back to the system mailbox.
*/
int
-preserve(msgvec)
- int *msgvec;
+preserve(v)
+ void *v;
{
+ int *msgvec = v;
register struct message *mp;
register int *ip, mesg;
@@ -308,9 +320,10 @@ preserve(msgvec)
* Mark all given messages as unread.
*/
int
-unread(msgvec)
- int msgvec[];
+unread(v)
+ void *v;
{
+ int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != NULL; ip++) {
@@ -325,9 +338,10 @@ unread(msgvec)
* Print the size of each message.
*/
int
-messize(msgvec)
- int *msgvec;
+messize(v)
+ void *v;
{
+ int *msgvec = v;
register struct message *mp;
register int *ip, mesg;
@@ -344,12 +358,12 @@ messize(msgvec)
* by returning an error.
*/
int
-rexit(e)
- int e;
+rexit(v)
+ void *v;
{
if (sourcing)
return(1);
- exit(e);
+ exit(0);
/*NOTREACHED*/
}
@@ -358,9 +372,10 @@ rexit(e)
* of csh.
*/
int
-set(arglist)
- char **arglist;
+set(v)
+ void *v;
{
+ char **arglist = v;
register struct var *vp;
register char *cp, *cp2;
char varbuf[BUFSIZ], **ap, **p;
@@ -405,9 +420,10 @@ set(arglist)
* Unset a bunch of variable values.
*/
int
-unset(arglist)
- char **arglist;
+unset(v)
+ void *v;
{
+ char **arglist = v;
register struct var *vp, *vp2;
int errs, h;
char **ap;
@@ -443,9 +459,10 @@ unset(arglist)
* Put add users to a group.
*/
int
-group(argv)
- char **argv;
+group(v)
+ void *v;
{
+ char **argv = v;
register struct grouphead *gh;
register struct group *gp;
register int h;
@@ -504,7 +521,6 @@ sort(list)
char **list;
{
register char **ap;
- int diction();
for (ap = list; *ap != NOSTR; ap++)
;
@@ -517,7 +533,7 @@ sort(list)
* Do a dictionary order comparison of the arguments from
* qsort.
*/
-int
+static int
diction(a, b)
const void *a, *b;
{
@@ -530,8 +546,8 @@ diction(a, b)
/*ARGSUSED*/
int
-null(e)
- int e;
+null(v)
+ void *v;
{
return 0;
}
@@ -541,9 +557,10 @@ null(e)
* the current file.
*/
int
-file(argv)
- register char **argv;
+file(v)
+ void *v;
{
+ char **argv = v;
if (argv[0] == NOSTR) {
newfileinfo();
@@ -559,9 +576,10 @@ file(argv)
* Expand file names like echo
*/
int
-echo(argv)
- char **argv;
+echo(v)
+ void *v;
{
+ char **argv = v;
register char **ap;
register char *cp;
@@ -578,9 +596,10 @@ echo(argv)
}
int
-Respond(msgvec)
- int *msgvec;
+Respond(v)
+ void *v;
{
+ int *msgvec = v;
if (value("Replyall") == NOSTR)
return (_Respond(msgvec));
else
@@ -628,9 +647,10 @@ _Respond(msgvec)
* .mailrc and do some things if sending, others if receiving.
*/
int
-ifcmd(argv)
- char **argv;
+ifcmd(v)
+ void *v;
{
+ char **argv = v;
register char *cp;
if (cond != CANY) {
@@ -660,7 +680,8 @@ ifcmd(argv)
* flip over the conditional flag.
*/
int
-elsecmd()
+elsecmd(v)
+ void *v;
{
switch (cond) {
@@ -688,7 +709,8 @@ elsecmd()
* End of if statement. Just set cond back to anything.
*/
int
-endifcmd()
+endifcmd(v)
+ void *v;
{
if (cond == CANY) {
@@ -703,9 +725,10 @@ endifcmd()
* Set the list of alternate names.
*/
int
-alternates(namelist)
- char **namelist;
+alternates(v)
+ void *v;
{
+ char **namelist = v;
register int c;
register char **ap, **ap2, *cp;
diff --git a/usr.bin/mail/cmdtab.c b/usr.bin/mail/cmdtab.c
index c7b1cdd0fa5..f35947e5a75 100644
--- a/usr.bin/mail/cmdtab.c
+++ b/usr.bin/mail/cmdtab.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: cmdtab.c,v 1.2 1996/03/27 19:32:31 niklas Exp $ */
+/* $OpenBSD: cmdtab.c,v 1.3 1996/06/11 12:53:35 deraadt Exp $ */
+/* $NetBSD: cmdtab.c,v 1.6 1996/06/08 19:48:15 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.2 1996/03/27 19:32:31 niklas Exp $";
+#if 0
+static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.3 1996/06/11 12:53:35 deraadt Exp $";
+#endif
#endif /* not lint */
#include "def.h"
@@ -48,73 +52,73 @@ static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.2 1996/03/27 19:32:31 niklas Exp $
*/
const struct cmd cmdtab[] = {
- "next", next, NDMLIST, 0, MMNDEL,
- "alias", group, M|RAWLIST, 0, 1000,
- "print", type, MSGLIST, 0, MMNDEL,
- "type", type, MSGLIST, 0, MMNDEL,
- "Type", Type, MSGLIST, 0, MMNDEL,
- "Print", Type, MSGLIST, 0, MMNDEL,
- "visual", visual, I|MSGLIST, 0, MMNORM,
- "top", top, MSGLIST, 0, MMNDEL,
- "touch", stouch, W|MSGLIST, 0, MMNDEL,
- "preserve", preserve, W|MSGLIST, 0, MMNDEL,
- "delete", delete, W|P|MSGLIST, 0, MMNDEL,
- "dp", deltype, W|MSGLIST, 0, MMNDEL,
- "dt", deltype, W|MSGLIST, 0, MMNDEL,
- "undelete", undeletecmd, P|MSGLIST, MDELETED,MMNDEL,
- "unset", unset, M|RAWLIST, 1, 1000,
- "mail", sendmail, R|M|I|STRLIST, 0, 0,
- "mbox", mboxit, W|MSGLIST, 0, 0,
- "more", more, MSGLIST, 0, MMNDEL,
- "page", more, MSGLIST, 0, MMNDEL,
- "More", More, MSGLIST, 0, MMNDEL,
- "Page", More, MSGLIST, 0, MMNDEL,
- "unread", unread, MSGLIST, 0, MMNDEL,
- "!", shell, I|STRLIST, 0, 0,
- "copy", copycmd, M|STRLIST, 0, 0,
- "chdir", schdir, M|RAWLIST, 0, 1,
- "cd", schdir, M|RAWLIST, 0, 1,
- "save", save, STRLIST, 0, 0,
- "source", source, M|RAWLIST, 1, 1,
- "set", set, M|RAWLIST, 0, 1000,
- "shell", dosh, I|NOLIST, 0, 0,
- "version", pversion, M|NOLIST, 0, 0,
- "group", group, M|RAWLIST, 0, 1000,
- "write", swrite, STRLIST, 0, 0,
- "from", from, MSGLIST, 0, MMNORM,
- "file", file, T|M|RAWLIST, 0, 1,
- "folder", file, T|M|RAWLIST, 0, 1,
- "folders", folders, T|M|NOLIST, 0, 0,
- "?", help, M|NOLIST, 0, 0,
- "z", scroll, M|STRLIST, 0, 0,
- "headers", headers, MSGLIST, 0, MMNDEL,
- "help", help, M|NOLIST, 0, 0,
- "=", pdot, NOLIST, 0, 0,
- "Reply", Respond, R|I|MSGLIST, 0, MMNDEL,
- "Respond", Respond, R|I|MSGLIST, 0, MMNDEL,
- "reply", respond, R|I|MSGLIST, 0, MMNDEL,
- "respond", respond, R|I|MSGLIST, 0, MMNDEL,
- "edit", editor, I|MSGLIST, 0, MMNORM,
- "echo", echo, M|RAWLIST, 0, 1000,
- "quit", quitcmd, NOLIST, 0, 0,
- "list", pcmdlist, M|NOLIST, 0, 0,
- "xit", rexit, M|NOLIST, 0, 0,
- "exit", rexit, M|NOLIST, 0, 0,
- "size", messize, MSGLIST, 0, MMNDEL,
- "hold", preserve, W|MSGLIST, 0, MMNDEL,
- "if", ifcmd, F|M|RAWLIST, 1, 1,
- "else", elsecmd, F|M|RAWLIST, 0, 0,
- "endif", endifcmd, F|M|RAWLIST, 0, 0,
- "alternates", alternates, M|RAWLIST, 0, 1000,
- "ignore", igfield, M|RAWLIST, 0, 1000,
- "discard", igfield, M|RAWLIST, 0, 1000,
- "retain", retfield, M|RAWLIST, 0, 1000,
- "saveignore", saveigfield, M|RAWLIST, 0, 1000,
- "savediscard", saveigfield, M|RAWLIST, 0, 1000,
- "saveretain", saveretfield, M|RAWLIST, 0, 1000,
-/* "Header", Header, STRLIST, 0, 1000, */
- "core", core, M|NOLIST, 0, 0,
- "#", null, M|NOLIST, 0, 0,
- "clobber", clobber, M|RAWLIST, 0, 1,
- 0, 0, 0, 0, 0
+ { "next", next, NDMLIST, 0, MMNDEL },
+ { "alias", group, M|RAWLIST, 0, 1000 },
+ { "print", type, MSGLIST, 0, MMNDEL },
+ { "type", type, MSGLIST, 0, MMNDEL },
+ { "Type", Type, MSGLIST, 0, MMNDEL },
+ { "Print", Type, MSGLIST, 0, MMNDEL },
+ { "visual", visual, I|MSGLIST, 0, MMNORM },
+ { "top", top, MSGLIST, 0, MMNDEL },
+ { "touch", stouch, W|MSGLIST, 0, MMNDEL },
+ { "preserve", preserve, W|MSGLIST, 0, MMNDEL },
+ { "delete", delete, W|P|MSGLIST, 0, MMNDEL },
+ { "dp", deltype, W|MSGLIST, 0, MMNDEL },
+ { "dt", deltype, W|MSGLIST, 0, MMNDEL },
+ { "undelete", undeletecmd, P|MSGLIST, MDELETED,MMNDEL },
+ { "unset", unset, M|RAWLIST, 1, 1000 },
+ { "mail", sendmail, R|M|I|STRLIST, 0, 0 },
+ { "mbox", mboxit, W|MSGLIST, 0, 0 },
+ { "more", more, MSGLIST, 0, MMNDEL },
+ { "page", more, MSGLIST, 0, MMNDEL },
+ { "More", More, MSGLIST, 0, MMNDEL },
+ { "Page", More, MSGLIST, 0, MMNDEL },
+ { "unread", unread, MSGLIST, 0, MMNDEL },
+ { "!", shell, I|STRLIST, 0, 0 },
+ { "copy", copycmd, M|STRLIST, 0, 0 },
+ { "chdir", schdir, M|RAWLIST, 0, 1 },
+ { "cd", schdir, M|RAWLIST, 0, 1 },
+ { "save", save, STRLIST, 0, 0 },
+ { "source", source, M|RAWLIST, 1, 1 },
+ { "set", set, M|RAWLIST, 0, 1000 },
+ { "shell", dosh, I|NOLIST, 0, 0 },
+ { "version", pversion, M|NOLIST, 0, 0 },
+ { "group", group, M|RAWLIST, 0, 1000 },
+ { "write", swrite, STRLIST, 0, 0 },
+ { "from", from, MSGLIST, 0, MMNORM },
+ { "file", file, T|M|RAWLIST, 0, 1 },
+ { "folder", file, T|M|RAWLIST, 0, 1 },
+ { "folders", folders, T|M|NOLIST, 0, 0 },
+ { "?", help, M|NOLIST, 0, 0 },
+ { "z", scroll, M|STRLIST, 0, 0 },
+ { "headers", headers, MSGLIST, 0, MMNDEL },
+ { "help", help, M|NOLIST, 0, 0 },
+ { "=", pdot, NOLIST, 0, 0 },
+ { "Reply", Respond, R|I|MSGLIST, 0, MMNDEL },
+ { "Respond", Respond, R|I|MSGLIST, 0, MMNDEL },
+ { "reply", respond, R|I|MSGLIST, 0, MMNDEL },
+ { "respond", respond, R|I|MSGLIST, 0, MMNDEL },
+ { "edit", editor, I|MSGLIST, 0, MMNORM },
+ { "echo", echo, M|RAWLIST, 0, 1000 },
+ { "quit", quitcmd, NOLIST, 0, 0 },
+ { "list", pcmdlist, M|NOLIST, 0, 0 },
+ { "xit", rexit, M|NOLIST, 0, 0 },
+ { "exit", rexit, M|NOLIST, 0, 0 },
+ { "size", messize, MSGLIST, 0, MMNDEL },
+ { "hold", preserve, W|MSGLIST, 0, MMNDEL },
+ { "if", ifcmd, F|M|RAWLIST, 1, 1 },
+ { "else", elsecmd, F|M|RAWLIST, 0, 0 },
+ { "endif", endifcmd, F|M|RAWLIST, 0, 0 },
+ { "alternates", alternates, M|RAWLIST, 0, 1000 },
+ { "ignore", igfield, M|RAWLIST, 0, 1000 },
+ { "discard", igfield, M|RAWLIST, 0, 1000 },
+ { "retain", retfield, M|RAWLIST, 0, 1000 },
+ { "saveignore", saveigfield, M|RAWLIST, 0, 1000 },
+ { "savediscard",saveigfield, M|RAWLIST, 0, 1000 },
+ { "saveretain", saveretfield, M|RAWLIST, 0, 1000 },
+/* { "Header", Header, STRLIST, 0, 1000 }, */
+ { "core", core, M|NOLIST, 0, 0 },
+ { "#", null, M|NOLIST, 0, 0 },
+ { "clobber", clobber, M|RAWLIST, 0, 1 },
+ { 0, 0, 0, 0, 0 }
};
diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c
index 151c64ab159..c17e46ceef5 100644
--- a/usr.bin/mail/collect.c
+++ b/usr.bin/mail/collect.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: collect.c,v 1.2 1996/06/11 12:53:35 deraadt Exp $ */
+/* $NetBSD: collect.c,v 1.6 1996/06/08 19:48:16 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)collect.c 8.2 (Berkeley) 4/19/94";
-static char rcsid[] = "$Id: collect.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
+#else
+static char rcsid[] = "$OpenBSD: collect.c,v 1.2 1996/06/11 12:53:35 deraadt Exp $";
+#endif
#endif /* not lint */
/*
@@ -80,15 +86,23 @@ collect(hp, printheaders)
char linebuf[LINESIZE], *cp;
extern char *tempMail;
char getsub;
- int omask;
- void collint(), collhup(), collstop();
+ sigset_t oset, nset;
+#if __GNUC__
+ /* Avoid longjmp clobbering */
+ (void) &escape;
+ (void) &eofcount;
+ (void) &getsub;
+#endif
collf = NULL;
/*
* Start catching signals from here, but we're still die on interrupts
* until we're in the main loop.
*/
- omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGHUP);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
if ((saveint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
signal(SIGINT, collint);
if ((savehup = signal(SIGHUP, SIG_IGN)) != SIG_IGN)
@@ -100,7 +114,7 @@ collect(hp, printheaders)
rm(tempMail);
goto err;
}
- sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
+ sigprocmask(SIG_SETMASK, &oset, NULL);
noreset++;
if ((collf = Fopen(tempMail, "w+")) == NULL) {
@@ -191,7 +205,7 @@ cont:
/*
* Dump core.
*/
- core();
+ core(NULL);
break;
case '!':
/*
@@ -375,13 +389,16 @@ out:
if (collf != NULL)
rewind(collf);
noreset--;
- sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGHUP);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
signal(SIGINT, saveint);
signal(SIGHUP, savehup);
signal(SIGTSTP, savetstp);
signal(SIGTTOU, savettou);
signal(SIGTTIN, savettin);
- sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
return collf;
}
@@ -561,10 +578,13 @@ collstop(s)
int s;
{
sig_t old_action = signal(s, SIG_DFL);
+ sigset_t nset;
- sigsetmask(sigblock(0) & ~sigmask(s));
+ sigemptyset(&nset);
+ sigaddset(&nset, s);
+ sigprocmask(SIG_UNBLOCK, &nset, NULL);
kill(0, s);
- sigblock(sigmask(s));
+ sigprocmask(SIG_BLOCK, &nset, NULL);
signal(s, old_action);
if (colljmp_p) {
colljmp_p = 0;
diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h
index df80f32861c..f3d28d7f7d3 100644
--- a/usr.bin/mail/def.h
+++ b/usr.bin/mail/def.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: def.h,v 1.2 1996/06/11 12:53:36 deraadt Exp $ */
+/* $NetBSD: def.h,v 1.8 1996/06/08 19:48:18 christos Exp $ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,8 +32,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)def.h 8.2 (Berkeley) 3/21/94
- * $Id: def.h,v 1.1 1995/10/18 08:45:38 deraadt Exp $
+ * @(#)def.h 8.2 (Berkeley) 3/21/94
+ * $NetBSD: def.h,v 1.8 1996/06/08 19:48:18 christos Exp $
*/
/*
@@ -105,7 +107,7 @@ struct message {
*/
struct cmd {
char *c_name; /* Name of command */
- int (*c_func)(); /* Implementor of the command */
+ int (*c_func) __P((void *));/* Implementor of the command */
short c_argtype; /* Type of arglist (see below) */
short c_msgflag; /* Required flags of messages */
short c_msgmask; /* Relevant flags of messages */
diff --git a/usr.bin/mail/dotlock.c b/usr.bin/mail/dotlock.c
new file mode 100644
index 00000000000..a16bf531ed1
--- /dev/null
+++ b/usr.bin/mail/dotlock.c
@@ -0,0 +1,198 @@
+/* $OpenBSD: dotlock.c,v 1.1 1996/06/11 12:53:37 deraadt Exp $ */
+/* $NetBSD: dotlock.c,v 1.1 1996/06/08 19:48:19 christos Exp $ */
+
+/*
+ * Copyright (c) 1996 Christos Zoulas. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char rcsid[] = "$OpenBSD: dotlock.c,v 1.1 1996/06/11 12:53:37 deraadt Exp $";
+#endif
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+
+#include "extern.h"
+
+#ifndef O_SYNC
+#define O_SYNC 0
+#endif
+
+static int create_exclusive __P((const char *));
+/*
+ * Create a unique file. O_EXCL does not really work over NFS so we follow
+ * the following trick: [Inspired by S.R. van den Berg]
+ *
+ * - make a mostly unique filename and try to create it.
+ * - link the unique filename to our target
+ * - get the link count of the target
+ * - unlink the mostly unique filename
+ * - if the link count was 2, then we are ok; else we've failed.
+ */
+static int
+create_exclusive(fname)
+ const char *fname;
+{
+ char path[MAXPATHLEN], hostname[MAXHOSTNAMELEN];
+ const char *ptr;
+ struct timeval tv;
+ pid_t pid;
+ size_t ntries, cookie;
+ int fd, serrno;
+ struct stat st;
+
+ (void) gettimeofday(&tv, NULL);
+ (void) gethostname(hostname, MAXHOSTNAMELEN);
+ pid = getpid();
+
+ cookie = pid ^ tv.tv_usec;
+
+ /*
+ * We generate a semi-unique filename, from hostname.(pid ^ usec)
+ */
+ if ((ptr = strrchr(fname, '/')) == NULL)
+ ptr = fname;
+ else
+ ptr++;
+
+ (void) snprintf(path, sizeof(path), "%.*s.%s.%x",
+ ptr - fname, fname, hostname, cookie);
+
+ /*
+ * We try to create the unique filename.
+ */
+ for (ntries = 0; ntries < 5; ntries++) {
+ fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_SYNC, 0);
+ if (fd != -1) {
+ (void) close(fd);
+ break;
+ }
+ else if (errno == EEXIST)
+ continue;
+ else
+ return -1;
+ }
+
+ /*
+ * We link the path to the name
+ */
+ if (link(path, fname) == -1)
+ goto bad;
+
+ /*
+ * Note that we stat our own exclusively created name, not the
+ * destination, since the destination can be affected by others.
+ */
+ if (stat(path, &st) == -1)
+ goto bad;
+
+ (void) unlink(path);
+
+ /*
+ * If the number of links was two (one for the unique file and one
+ * for the lock), we've won the race
+ */
+ if (st.st_nlink != 2) {
+ errno = EEXIST;
+ return -1;
+ }
+ return 0;
+
+bad:
+ serrno = errno;
+ (void) unlink(path);
+ errno = serrno;
+ return -1;
+}
+
+int
+dot_lock(fname, pollinterval, fp, msg)
+ const char *fname; /* Pathname to lock */
+ int pollinterval; /* Interval to check for lock, -1 return */
+ FILE *fp; /* File to print message */
+ const char *msg; /* Message to print */
+{
+ char path[MAXPATHLEN];
+ sigset_t nset, oset;
+
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGHUP);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGQUIT);
+ sigaddset(&nset, SIGTERM);
+ sigaddset(&nset, SIGTTIN);
+ sigaddset(&nset, SIGTTOU);
+ sigaddset(&nset, SIGTSTP);
+ sigaddset(&nset, SIGCHLD);
+
+ (void) snprintf(path, sizeof(path), "%s.lock", fname);
+
+ for (;;) {
+ (void) sigprocmask(SIG_BLOCK, &nset, &oset);
+ if (create_exclusive(path) != -1) {
+ (void) sigprocmask(SIG_SETMASK, &oset, NULL);
+ return 0;
+ }
+ else
+ (void) sigprocmask(SIG_SETMASK, &oset, NULL);
+
+ if (errno != EEXIST)
+ return -1;
+
+ if (fp && msg)
+ (void) fputs(msg, fp);
+
+ if (pollinterval) {
+ if (pollinterval == -1) {
+ errno = EEXIST;
+ return -1;
+ }
+ sleep(pollinterval);
+ }
+ }
+}
+
+void
+dot_unlock(fname)
+ const char *fname;
+{
+ char path[MAXPATHLEN];
+
+ (void) snprintf(path, sizeof(path), "%s.lock", fname);
+ (void) unlink(path);
+}
diff --git a/usr.bin/mail/edit.c b/usr.bin/mail/edit.c
index 23b27a23465..60dbc3d8d47 100644
--- a/usr.bin/mail/edit.c
+++ b/usr.bin/mail/edit.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: edit.c,v 1.2 1996/06/11 12:53:38 deraadt Exp $ */
+/* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)edit.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: edit.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: edit.c,v 1.2 1996/06/11 12:53:38 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -50,9 +56,10 @@ static char rcsid[] = "$Id: edit.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
* Edit a message list.
*/
int
-editor(msgvec)
- int *msgvec;
+editor(v)
+ void *v;
{
+ int *msgvec = v;
return edit1(msgvec, 'e');
}
@@ -61,9 +68,10 @@ editor(msgvec)
* Invoke the visual editor on a message list.
*/
int
-visual(msgvec)
- int *msgvec;
+visual(v)
+ void *v;
{
+ int *msgvec = v;
return edit1(msgvec, 'v');
}
diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h
index 469a3faddec..28ed945ba35 100644
--- a/usr.bin/mail/extern.h
+++ b/usr.bin/mail/extern.h
@@ -1,4 +1,5 @@
-/* $OpenBSD: extern.h,v 1.2 1996/03/27 19:32:32 niklas Exp $ */
+/* $OpenBSD: extern.h,v 1.3 1996/06/11 12:53:39 deraadt Exp $ */
+/* $NetBSD: extern.h,v 1.4 1996/06/08 19:48:21 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -33,14 +34,18 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 6/6/93
+ * $NetBSD: extern.h,v 1.4 1996/06/08 19:48:21 christos Exp $
*/
+struct name;
struct name *cat __P((struct name *, struct name *));
struct name *delname __P((struct name *, char []));
struct name *elide __P((struct name *));
struct name *extract __P((char [], int));
+struct grouphead;
struct name *gexpand __P((struct name *, struct grouphead *, int, int));
struct name *nalloc __P((char [], int));
+struct header;
struct name *outof __P((struct name *, FILE *, struct header *));
struct name *put __P((struct name *, struct name *));
struct name *tailof __P((struct name *));
@@ -55,6 +60,7 @@ char *detract __P((struct name *, int));
char *expand __P((char *));
char *getdeadletter __P((void));
char *getname __P((int));
+struct message;
char *hfield __P((char [], struct message *));
FILE *infix __P((struct header *, FILE *));
char *ishfield __P((char [], char[], char *));
@@ -75,14 +81,14 @@ char *value __P((char []));
char *vcopy __P((char []));
char *yankword __P((char *, char []));
int Fclose __P((FILE *));
-int More __P((int *));
+int More __P((void *));
int Pclose __P((FILE *));
-int Respond __P((int *));
-int Type __P((int *));
+int Respond __P((void *));
+int Type __P((void *));
int _Respond __P((int []));
int _respond __P((int *));
void alter __P((char *));
-int alternates __P((char **));
+int alternates __P((void *));
void announce __P((void));
int anyof __P((char *, char *));
int append __P((struct message *, FILE *));
@@ -94,43 +100,44 @@ void brokpipe __P((int));
int charcount __P((char *, int));
int check __P((int, int));
void clob1 __P((int));
-int clobber __P((char **));
+int clobber __P((void *));
void close_all_files __P((void));
int cmatch __P((char *, char *));
void collhup __P((int));
void collint __P((int));
void collstop __P((int));
void commands __P((void));
-int copycmd __P((char []));
-int core __P((void));
+int copycmd __P((void *));
+int core __P((void *));
int count __P((struct name *));
-int delete __P((int []));
+int delete __P((void *));
int delm __P((int []));
-int deltype __P((int []));
+int deltype __P((void *));
void demail __P((void));
-int diction __P((const void *, const void *));
-int dosh __P((char *));
-int echo __P((char **));
+int dosh __P((void *));
+int dot_lock __P((const char *, int, FILE *, const char *));
+void dot_unlock __P((const char *));
+int echo __P((void *));
int edit1 __P((int *, int));
-int editor __P((int *));
+int editor __P((void *));
void edstop __P((void));
-int elsecmd __P((void));
-int endifcmd __P((void));
+int elsecmd __P((void *));
+int endifcmd __P((void *));
int evalcol __P((int));
int execute __P((char [], int));
int exwrite __P((char [], FILE *, int));
void fail __P((char [], char []));
-int file __P((char **));
+int file __P((void *));
struct grouphead *
findgroup __P((char []));
void findmail __P((char *, char *));
int first __P((int, int));
void fixhead __P((struct header *, struct name *));
void fmt __P((char *, struct name *, FILE *, int));
-int folders __P((void));
+int folders __P((void *));
int forward __P((char [], FILE *, int));
void free_child __P((int));
-int from __P((int *));
+int from __P((void *));
off_t fsize __P((FILE *));
int getfold __P((char *));
int gethfield __P((FILE *, char [], int, char **));
@@ -138,16 +145,16 @@ int getmsglist __P((char *, int *, int));
int getrawlist __P((char [], char **, int));
int getuserid __P((char []));
int grabh __P((struct header *, int));
-int group __P((char **));
+int group __P((void *));
void hangup __P((int));
int hash __P((char *));
void hdrstop __P((int));
-int headers __P((int *));
-int help __P((void));
+int headers __P((void *));
+int help __P((void *));
void holdsigs __P((void));
-int ifcmd __P((char **));
-int igcomp __P((const void *, const void *));
-int igfield __P((char *[]));
+int ifcmd __P((void *));
+int igfield __P((void *));
+struct ignoretab;
int ignore1 __P((char *[], struct ignoretab *, char *));
int igshow __P((struct ignoretab *, char *));
void intr __P((int));
@@ -171,85 +178,87 @@ void mark __P((int));
int markall __P((char [], int));
int matchsender __P((char *, int));
int matchsubj __P((char *, int));
-int mboxit __P((int []));
+int mboxit __P((void *));
int member __P((char *, struct ignoretab *));
void mesedit __P((FILE *, int));
void mespipe __P((FILE *, char []));
-int messize __P((int *));
+int messize __P((void *));
int metamess __P((int, int));
-int more __P((int *));
+int more __P((void *));
int newfileinfo __P((void));
-int next __P((int *));
-int null __P((int));
-void panic __P((const char *, ...));
+int next __P((void *));
+int null __P((void *));
+void panic __P((const char *, ...))
+ __attribute__((__format__(__printf__,1,2),__noreturn__));
+struct headline;
void parse __P((char [], struct headline *, char []));
-int pcmdlist __P((void));
-int pdot __P((void));
-void prepare_child __P((int, int, int));
-int preserve __P((int *));
+int pcmdlist __P((void *));
+int pdot __P((void *));
+void prepare_child __P((sigset_t *, int, int));
+int preserve __P((void *));
void prettyprint __P((struct name *));
void printgroup __P((char []));
void printhead __P((int));
int puthead __P((struct header *, FILE *, int));
int putline __P((FILE *, char *));
-int pversion __P((int));
+int pversion __P((void *));
void quit __P((void));
-int quitcmd __P((void));
+int quitcmd __P((void *));
int raise __P((int));
int readline __P((FILE *, char *, int));
void register_file __P((FILE *, int, int));
void regret __P((int));
void relsesigs __P((void));
-int respond __P((int *));
-int retfield __P((char *[]));
-int rexit __P((int));
+int respond __P((void *));
+int retfield __P((void *));
+int rexit __P((void *));
int rm __P((char *));
-int run_command __P((char *, int, int, int, char *, char *, char *));
-int save __P((char []));
+int run_command __P((char *, sigset_t *, int, int, char *, char *, char *));
+int save __P((void *));
int save1 __P((char [], int, char *, struct ignoretab *));
void savedeadletter __P((FILE *));
-int saveigfield __P((char *[]));
+int saveigfield __P((void *));
int savemail __P((char [], FILE *));
-int saveretfield __P((char *[]));
+int saveretfield __P((void *));
int scan __P((char **));
void scaninit __P((void));
-int schdir __P((char **));
+int schdir __P((void *));
int screensize __P((void));
-int scroll __P((char []));
+int scroll __P((void *));
int send __P((struct message *, FILE *, struct ignoretab *, char *));
-int sendmail __P((char *));
-int set __P((char **));
+int sendmail __P((void *));
+int set __P((void *));
int setfile __P((char *));
void setmsize __P((int));
void setptr __P((FILE *));
void setscreensize __P((void));
-int shell __P((char *));
+int shell __P((void *));
void sigchild __P((int));
void sort __P((char **));
-int source __P((char **));
+int source __P((void *));
void spreserve __P((void));
void sreset __P((void));
-int start_command __P((char *, int, int, int, char *, char *, char *));
+int start_command __P((char *, sigset_t *, int, int, char *, char *, char *));
void statusput __P((struct message *, FILE *, char *));
void stop __P((int));
-int stouch __P((int []));
-int swrite __P((char []));
+int stouch __P((void *));
+int swrite __P((void *));
void tinit __P((void));
-int top __P((int *));
+int top __P((void *));
void touch __P((struct message *));
void ttyint __P((int));
void ttystop __P((int));
-int type __P((int *));
+int type __P((void *));
int type1 __P((int *, int, int));
-int undeletecmd __P((int *));
+int undeletecmd __P((void *));
void unmark __P((int));
char **unpack __P((struct name *));
-int unread __P((int []));
+int unread __P((void *));
void unregister_file __P((FILE *));
-int unset __P((char **));
+int unset __P((void *));
int unstack __P((void));
void vfree __P((char *));
-int visual __P((int *));
+int visual __P((void *));
int wait_child __P((int));
int wait_command __P((int));
int writeback __P((FILE *));
diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c
index 198b299fd9c..1813bdc09ff 100644
--- a/usr.bin/mail/fio.c
+++ b/usr.bin/mail/fio.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: fio.c,v 1.2 1996/06/11 12:53:39 deraadt Exp $ */
+/* $NetBSD: fio.c,v 1.5 1996/06/08 19:48:22 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)fio.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: fio.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)fio.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: fio.c,v 1.2 1996/06/11 12:53:39 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -122,7 +128,7 @@ setptr(ibuf)
;
if (cp[-1] != ':')
break;
- while (c = *cp++)
+ while ((c = *cp++) != '\0')
if (c == 'R')
this.m_flag |= MREAD;
else if (c == 'O')
@@ -256,7 +262,7 @@ rm(name)
}
static int sigdepth; /* depth of holdsigs() */
-static int omask;
+static sigset_t nset, oset;
/*
* Hold signals SIGHUP, SIGINT, and SIGQUIT.
*/
@@ -264,8 +270,13 @@ void
holdsigs()
{
- if (sigdepth++ == 0)
- omask = sigblock(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT));
+ if (sigdepth++ == 0) {
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGHUP);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGQUIT);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
+ }
}
/*
@@ -276,7 +287,7 @@ relsesigs()
{
if (--sigdepth == 0)
- sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
}
/*
diff --git a/usr.bin/mail/getname.c b/usr.bin/mail/getname.c
index 1791b82b791..5f62d42ba62 100644
--- a/usr.bin/mail/getname.c
+++ b/usr.bin/mail/getname.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: getname.c,v 1.2 1996/06/11 12:53:40 deraadt Exp $ */
+/* $NetBSD: getname.c,v 1.4 1996/06/08 19:48:23 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)getname.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: getname.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)getname.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: getname.c,v 1.2 1996/06/11 12:53:40 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -43,8 +49,7 @@ static char rcsid[] = "$Id: getname.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
/* Getname / getuserid for those with hashed passwd data base). */
/*
- * Search the passwd file for a uid. Return name through ref parameter
- * if found, indicating success with 0 return. Return -1 on error.
+ * Search the passwd file for a uid. Return name on success, NOSTR on failure
*/
char *
getname(uid)
diff --git a/usr.bin/mail/glob.h b/usr.bin/mail/glob.h
index 6f4d76789dc..30d87ef86d3 100644
--- a/usr.bin/mail/glob.h
+++ b/usr.bin/mail/glob.h
@@ -1,3 +1,6 @@
+/* $OpenBSD: glob.h,v 1.2 1996/06/11 12:53:41 deraadt Exp $ */
+/* $NetBSD: glob.h,v 1.4 1996/06/08 19:48:25 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)glob.h 8.1 (Berkeley) 6/6/93
- * $Id: glob.h,v 1.1 1995/10/18 08:45:38 deraadt Exp $
+ * $NetBSD: glob.h,v 1.4 1996/06/08 19:48:25 christos Exp $
*/
/*
diff --git a/usr.bin/mail/head.c b/usr.bin/mail/head.c
index b9f810b099c..c151fb087a3 100644
--- a/usr.bin/mail/head.c
+++ b/usr.bin/mail/head.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: head.c,v 1.2 1996/06/11 12:53:42 deraadt Exp $ */
+/* $NetBSD: head.c,v 1.5 1996/06/08 19:48:26 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)head.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: head.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: head.c,v 1.2 1996/06/11 12:53:42 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -140,7 +146,7 @@ copyin(src, space)
char *top;
top = cp = *space;
- while (*cp++ = *src++)
+ while ((*cp++ = *src++) != '\0')
;
*space = cp;
return (top);
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index d5741a0bbfa..36dccc59a13 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: lex.c,v 1.2 1996/03/27 19:32:33 niklas Exp $ */
+/* $OpenBSD: lex.c,v 1.3 1996/06/11 12:53:42 deraadt Exp $ */
+/* $NetBSD: lex.c,v 1.7 1996/06/08 19:48:28 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)lex.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: lex.c,v 1.2 1996/03/27 19:32:33 niklas Exp $";
+#if 0
+static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: lex.c,v 1.3 1996/06/11 12:53:42 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -171,7 +175,10 @@ commands()
int eofloop = 0;
register int n;
char linebuf[LINESIZE];
- void intr(), stop(), hangup();
+#if __GNUC__
+ /* Avoid longjmp clobbering */
+ (void) &eofloop;
+#endif
if (!sourcing) {
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
@@ -249,7 +256,7 @@ execute(linebuf, contxt)
{
char word[LINESIZE];
char *arglist[MAXARGC];
- const struct cmd *com;
+ const struct cmd *com = NULL;
register char *cp, *cp2;
register int c;
int muvec[2];
@@ -301,7 +308,7 @@ execute(linebuf, contxt)
*/
if ((com->c_argtype & F) == 0)
- if (cond == CRCV && !rcvmode || cond == CSEND && rcvmode)
+ if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode))
return(0);
/*
@@ -424,6 +431,8 @@ out:
unstack();
return 0;
}
+ if (com == NULL)
+ return(0);
if (value("autoprint") != NOSTR && com->c_argtype & P)
if ((dot->m_flag & MDELETED) == 0) {
muvec[0] = dot - &message[0] + 1;
@@ -526,10 +535,13 @@ stop(s)
int s;
{
sig_t old_action = signal(s, SIG_DFL);
+ sigset_t nset;
- sigsetmask(sigblock(0) & ~sigmask(s));
+ sigemptyset(&nset);
+ sigaddset(&nset, s);
+ sigprocmask(SIG_UNBLOCK, &nset, NULL);
kill(0, s);
- sigblock(sigmask(s));
+ sigprocmask(SIG_BLOCK, &nset, NULL);
signal(s, old_action);
if (reset_on_stop) {
reset_on_stop = 0;
@@ -636,8 +648,8 @@ newfileinfo()
/*ARGSUSED*/
int
-pversion(e)
- int e;
+pversion(v)
+ void *v;
{
extern char *version;
diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c
index 297d21d7f2f..dea57d67666 100644
--- a/usr.bin/mail/list.c
+++ b/usr.bin/mail/list.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: list.c,v 1.2 1996/06/11 12:53:43 deraadt Exp $ */
+/* $NetBSD: list.c,v 1.4 1996/06/08 19:48:30 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)list.c 8.2 (Berkeley) 4/19/94";
-static char rcsid[] = "$Id: list.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)list.c 8.2 (Berkeley) 4/19/94";
+#else
+static char rcsid[] = "$OpenBSD: list.c,v 1.2 1996/06/11 12:53:43 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -101,12 +107,12 @@ struct coltab {
int co_mask; /* m_status bits to mask */
int co_equal; /* ... must equal this */
} coltab[] = {
- 'n', CMNEW, MNEW, MNEW,
- 'o', CMOLD, MNEW, 0,
- 'u', CMUNREAD, MREAD, 0,
- 'd', CMDELETED, MDELETED, MDELETED,
- 'r', CMREAD, MREAD, MREAD,
- 0, 0, 0, 0
+ { 'n', CMNEW, MNEW, MNEW },
+ { 'o', CMOLD, MNEW, 0 },
+ { 'u', CMUNREAD, MREAD, 0 },
+ { 'd', CMDELETED, MDELETED, MDELETED },
+ { 'r', CMREAD, MREAD, MREAD },
+ { 0, 0, 0, 0 }
};
static int lastcolmod;
@@ -454,8 +460,8 @@ getrawlist(line, argv, argc)
if (c == '?')
*cp2++ = '\177';
/* null doesn't show up anyway */
- else if (c >= 'A' && c <= '_' ||
- c >= 'a' && c <= 'z')
+ else if ((c >= 'A' && c <= '_') ||
+ (c >= 'a' && c <= 'z'))
*cp2++ = c & 037;
else {
*cp2++ = '^';
@@ -488,15 +494,15 @@ struct lex {
char l_char;
char l_token;
} singles[] = {
- '$', TDOLLAR,
- '.', TDOT,
- '^', TUP,
- '*', TSTAR,
- '-', TDASH,
- '+', TPLUS,
- '(', TOPEN,
- ')', TCLOSE,
- 0, 0
+ { '$', TDOLLAR },
+ { '.', TDOT },
+ { '^', TUP },
+ { '*', TSTAR },
+ { '-', TDASH },
+ { '+', TPLUS },
+ { '(', TOPEN },
+ { ')', TCLOSE },
+ { 0, 0 }
};
int
diff --git a/usr.bin/mail/mail.1 b/usr.bin/mail/mail.1
index 7d8e8b068cf..e330b39699a 100644
--- a/usr.bin/mail/mail.1
+++ b/usr.bin/mail/mail.1
@@ -1,3 +1,4 @@
+.\" $OpenBSD: mail.1,v 1.2 1996/06/11 12:53:44 deraadt Exp $
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,6 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)mail.1 8.2 (Berkeley) 12/30/93
-.\" $Id: mail.1,v 1.1 1995/10/18 08:45:39 deraadt Exp $
.\"
.Dd December 30, 1993
.Dt MAIL 1
diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c
index 033a8949925..1e312217555 100644
--- a/usr.bin/mail/main.c
+++ b/usr.bin/mail/main.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: main.c,v 1.2 1996/06/11 12:53:45 deraadt Exp $ */
+/* $NetBSD: main.c,v 1.5 1996/06/08 19:48:31 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -38,12 +41,16 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: main.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: main.c,v 1.2 1996/06/11 12:53:45 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
#include <fcntl.h>
+#include <sys/ioctl.h>
#include "extern.h"
/*
@@ -64,9 +71,7 @@ main(argc, argv)
char *subject;
char *ef;
char nosrc = 0;
- void hdrstop();
sig_t prevint;
- void sigchild();
/*
* Set up a reasonable environment.
diff --git a/usr.bin/mail/names.c b/usr.bin/mail/names.c
index c8e06f97e64..7a8a8153715 100644
--- a/usr.bin/mail/names.c
+++ b/usr.bin/mail/names.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: names.c,v 1.2 1996/06/11 12:53:45 deraadt Exp $ */
+/* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)names.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: names.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: names.c,v 1.2 1996/06/11 12:53:45 deraadt Exp $";
+#endif
#endif /* not lint */
/*
@@ -220,8 +226,8 @@ outof(names, fo, hp)
{
register int c;
register struct name *np, *top;
- time_t now, time();
- char *date, *fname, *ctime();
+ time_t now;
+ char *date, *fname;
FILE *fout, *fin;
int ispipe;
extern char *tempEdit;
@@ -282,6 +288,7 @@ outof(names, fo, hp)
if (ispipe) {
int pid;
char *shell;
+ sigset_t nset;
/*
* XXX
@@ -292,8 +299,11 @@ outof(names, fo, hp)
*/
if ((shell = value("SHELL")) == NOSTR)
shell = _PATH_CSHELL;
- pid = start_command(shell, sigmask(SIGHUP)|
- sigmask(SIGINT)|sigmask(SIGQUIT),
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGHUP);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGQUIT);
+ pid = start_command(shell, &nset,
image, -1, "-c", fname, NOSTR);
if (pid < 0) {
senderr++;
diff --git a/usr.bin/mail/pathnames.h b/usr.bin/mail/pathnames.h
index 347586faea8..5b62b79a13c 100644
--- a/usr.bin/mail/pathnames.h
+++ b/usr.bin/mail/pathnames.h
@@ -1,3 +1,6 @@
+/* $OpenBSD: pathnames.h,v 1.2 1996/06/11 12:53:46 deraadt Exp $ */
+/* $NetBSD: pathnames.h,v 1.4 1996/06/08 19:48:34 christos Exp $ */
+
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,8 +33,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)pathnames.h 8.1 (Berkeley) 6/6/93
- * $Id: pathnames.h,v 1.1 1995/10/18 08:45:39 deraadt Exp $
+ * @(#)pathnames.h 8.1 (Berkeley) 6/6/93
+ * $NetBSD: pathnames.h,v 1.4 1996/06/08 19:48:34 christos Exp $
*/
#include <paths.h>
diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c
index 8fc26c7f4df..7cf344b74f6 100644
--- a/usr.bin/mail/popen.c
+++ b/usr.bin/mail/popen.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: popen.c,v 1.2 1996/06/11 12:53:47 deraadt Exp $ */
+/* $NetBSD: popen.c,v 1.4 1996/06/08 19:48:35 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)popen.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: popen.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: popen.c,v 1.2 1996/06/11 12:53:47 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -62,6 +68,7 @@ struct child {
static struct child *child;
static struct child *findchild __P((int));
static void delchild __P((struct child *));
+static int file_pid __P((FILE *));
FILE *
Fopen(file, mode)
@@ -106,6 +113,7 @@ Popen(cmd, mode)
int p[2];
int myside, hisside, fd0, fd1;
int pid;
+ sigset_t nset;
FILE *fp;
if (pipe(p) < 0)
@@ -121,7 +129,8 @@ Popen(cmd, mode)
hisside = fd0 = p[READ];
fd1 = -1;
}
- if ((pid = start_command(cmd, 0, fd0, fd1, NOSTR, NOSTR, NOSTR)) < 0) {
+ sigemptyset(&nset);
+ if ((pid = start_command(cmd, &nset, fd0, fd1, NOSTR, NOSTR, NOSTR)) < 0) {
close(p[READ]);
close(p[WRITE]);
return NULL;
@@ -137,14 +146,17 @@ Pclose(ptr)
FILE *ptr;
{
int i;
- int omask;
+ sigset_t nset, oset;
i = file_pid(ptr);
unregister_file(ptr);
(void) fclose(ptr);
- omask = sigblock(sigmask(SIGINT)|sigmask(SIGHUP));
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGHUP);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
i = wait_child(i);
- sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
return i;
}
@@ -181,7 +193,7 @@ unregister_file(fp)
{
struct fp **pp, *p;
- for (pp = &fp_head; p = *pp; pp = &p->link)
+ for (pp = &fp_head; (p = *pp) != NULL; pp = &p->link)
if (p->fp == fp) {
*pp = p->link;
free((char *) p);
@@ -190,6 +202,7 @@ unregister_file(fp)
panic("Invalid file pointer");
}
+static int
file_pid(fp)
FILE *fp;
{
@@ -213,7 +226,8 @@ file_pid(fp)
int
run_command(cmd, mask, infd, outfd, a0, a1, a2)
char *cmd;
- int mask, infd, outfd;
+ sigset_t *mask;
+ int infd, outfd;
char *a0, *a1, *a2;
{
int pid;
@@ -227,7 +241,8 @@ run_command(cmd, mask, infd, outfd, a0, a1, a2)
int
start_command(cmd, mask, infd, outfd, a0, a1, a2)
char *cmd;
- int mask, infd, outfd;
+ sigset_t *mask;
+ int infd, outfd;
char *a0, *a1, *a2;
{
int pid;
@@ -253,10 +268,12 @@ start_command(cmd, mask, infd, outfd, a0, a1, a2)
}
void
-prepare_child(mask, infd, outfd)
- int mask, infd, outfd;
+prepare_child(nset, infd, outfd)
+ sigset_t *nset;
+ int infd, outfd;
{
int i;
+ sigset_t fset;
/*
* All file descriptors other than 0, 1, and 2 are supposed to be
@@ -267,11 +284,12 @@ prepare_child(mask, infd, outfd)
if (outfd >= 0)
dup2(outfd, 1);
for (i = 1; i <= NSIG; i++)
- if (mask & sigmask(i))
+ if (sigismember(nset, i))
(void) signal(i, SIG_IGN);
- if ((mask & sigmask(SIGINT)) == 0)
+ if (!sigismember(nset, SIGINT))
(void) signal(SIGINT, SIG_DFL);
- (void) sigsetmask(0);
+ sigfillset(&fset);
+ (void) sigprocmask(SIG_UNBLOCK, &fset, NULL);
}
int
@@ -345,14 +363,17 @@ int
wait_child(pid)
int pid;
{
- int mask = sigblock(sigmask(SIGCHLD));
+ sigset_t nset, oset;
register struct child *cp = findchild(pid);
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
while (!cp->done)
- sigpause(mask);
+ sigsuspend(&oset);
wait_status = cp->status;
delchild(cp);
- sigsetmask(mask);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
return wait_status.w_status ? -1 : 0;
}
@@ -363,12 +384,15 @@ void
free_child(pid)
int pid;
{
- int mask = sigblock(sigmask(SIGCHLD));
+ sigset_t nset, oset;
register struct child *cp = findchild(pid);
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
if (cp->done)
delchild(cp);
else
cp->free = 1;
- sigsetmask(mask);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
}
diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c
index 0acb222c40d..bf63671f4cb 100644
--- a/usr.bin/mail/quit.c
+++ b/usr.bin/mail/quit.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: quit.c,v 1.2 1996/06/11 12:53:48 deraadt Exp $ */
+/* $NetBSD: quit.c,v 1.5 1996/06/08 19:48:37 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)quit.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: quit.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)quit.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: quit.c,v 1.2 1996/06/11 12:53:48 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -50,7 +56,8 @@ static char rcsid[] = "$Id: quit.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
* The "quit" command.
*/
int
-quitcmd()
+quitcmd(v)
+ void *v;
{
/*
* If we are sourcing, then return 1 so execute() can handle it.
@@ -70,7 +77,7 @@ void
quit()
{
int mcount, p, modify, autohold, anystat, holdbit, nohold;
- FILE *ibuf, *obuf, *fbuf, *rbuf, *readstat, *abuf;
+ FILE *ibuf = NULL, *obuf, *fbuf, *rbuf, *readstat = NULL, *abuf;
register struct message *mp;
register int c;
extern char *tempQuit, *tempResid;
@@ -105,7 +112,14 @@ quit()
fbuf = Fopen(mailname, "r");
if (fbuf == NULL)
goto newmail;
- flock(fileno(fbuf), LOCK_EX);
+ if (flock(fileno(fbuf), LOCK_EX) == -1) {
+nolock:
+ perror("Unable to lock mailbox");
+ Fclose(fbuf);
+ return;
+ }
+ if (dot_lock(mailname, 1, stdout, ".") == -1)
+ goto nolock;
rbuf = NULL;
if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) {
printf("New mail has arrived.\n");
@@ -178,12 +192,14 @@ quit()
printf("Held %d message%s in %s\n",
p, p == 1 ? "" : "s", mailname);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
if (c == 0) {
if (p != 0) {
writeback(rbuf);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
goto cream;
@@ -202,6 +218,7 @@ quit()
if ((obuf = Fopen(tempQuit, "w")) == NULL) {
perror(tempQuit);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
if ((ibuf = Fopen(tempQuit, "r")) == NULL) {
@@ -209,6 +226,7 @@ quit()
rm(tempQuit);
Fclose(obuf);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
rm(tempQuit);
@@ -222,6 +240,7 @@ quit()
Fclose(ibuf);
Fclose(obuf);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
Fclose(obuf);
@@ -230,13 +249,15 @@ quit()
perror(mbox);
Fclose(ibuf);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
}
- if (value("append") != NOSTR) {
+ else {
if ((obuf = Fopen(mbox, "a")) == NULL) {
perror(mbox);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
fchmod(fileno(obuf), 0600);
@@ -248,6 +269,7 @@ quit()
Fclose(ibuf);
Fclose(obuf);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
@@ -274,6 +296,7 @@ quit()
perror(mbox);
Fclose(obuf);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
Fclose(obuf);
@@ -290,6 +313,7 @@ quit()
if (p != 0) {
writeback(rbuf);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
@@ -310,16 +334,20 @@ cream:
Fclose(abuf);
alter(mailname);
Fclose(fbuf);
+ dot_unlock(mailname);
return;
}
demail();
Fclose(fbuf);
+ dot_unlock(mailname);
return;
newmail:
printf("Thou hast new mail.\n");
- if (fbuf != NULL)
+ if (fbuf != NULL) {
Fclose(fbuf);
+ dot_unlock(mailname);
+ }
}
/*
@@ -388,7 +416,7 @@ edstop()
extern char *tmpdir;
register int gotcha, c;
register struct message *mp;
- FILE *obuf, *ibuf, *readstat;
+ FILE *obuf, *ibuf, *readstat = NULL;
struct stat statb;
char *tempname;
diff --git a/usr.bin/mail/rcv.h b/usr.bin/mail/rcv.h
index c09e2c54d07..6e7cd87d468 100644
--- a/usr.bin/mail/rcv.h
+++ b/usr.bin/mail/rcv.h
@@ -1,3 +1,6 @@
+/* $OpenBSD: rcv.h,v 1.2 1996/06/11 12:53:48 deraadt Exp $ */
+/* $NetBSD: rcv.h,v 1.4 1996/06/08 19:48:38 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,8 +33,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)rcv.h 8.1 (Berkeley) 6/6/93
- * $Id: rcv.h,v 1.1 1995/10/18 08:45:39 deraadt Exp $
+ * @(#)rcv.h 8.1 (Berkeley) 6/6/93
+ * $NetBSD: rcv.h,v 1.4 1996/06/08 19:48:38 christos Exp $
*/
/*
diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c
index b41bfa2207a..e4a1d6bf5c8 100644
--- a/usr.bin/mail/send.c
+++ b/usr.bin/mail/send.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: send.c,v 1.2 1996/06/11 12:53:50 deraadt Exp $ */
+/* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)send.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: send.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: send.c,v 1.2 1996/06/11 12:53:50 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -62,11 +68,11 @@ send(mp, obuf, doign, prefix)
long count;
register FILE *ibuf;
char line[LINESIZE];
- int ishead, infld, ignoring, dostat, firstline;
+ int ishead, infld, ignoring = 0, dostat, firstline;
register char *cp, *cp2;
- register int c;
+ register int c = 0;
int length;
- int prefixlen;
+ int prefixlen = 0;
/*
* Compute the prefix string, without trailing whitespace
@@ -273,9 +279,10 @@ mail(to, cc, bcc, smopts, subject)
* the mail routine below.
*/
int
-sendmail(str)
- char *str;
+sendmail(v)
+ void *v;
{
+ char *str = v;
struct header head;
head.h_to = extract(str, GTO);
@@ -373,9 +380,15 @@ mail1(hp, printheaders)
goto out;
}
if (pid == 0) {
- prepare_child(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)|
- sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU),
- fileno(mtf), -1);
+ sigset_t nset;
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGHUP);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGQUIT);
+ sigaddset(&nset, SIGTSTP);
+ sigaddset(&nset, SIGTTIN);
+ sigaddset(&nset, SIGTTOU);
+ prepare_child(&nset, fileno(mtf), -1);
if ((cp = value("sendmail")) != NOSTR)
cp = expand(cp);
else
@@ -539,8 +552,7 @@ savemail(name, fi)
register FILE *fo;
char buf[BUFSIZ];
register i;
- time_t now, time();
- char *ctime();
+ time_t now;
if ((fo = Fopen(name, "a")) == NULL) {
perror(name);
diff --git a/usr.bin/mail/strings.c b/usr.bin/mail/strings.c
index 5fc24d7b69d..33e0793d5e6 100644
--- a/usr.bin/mail/strings.c
+++ b/usr.bin/mail/strings.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: strings.c,v 1.2 1996/06/11 12:53:50 deraadt Exp $ */
+/* $NetBSD: strings.c,v 1.5 1996/06/08 19:48:40 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)strings.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: strings.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)strings.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: strings.c,v 1.2 1996/06/11 12:53:50 deraadt Exp $";
+#endif
#endif /* not lint */
/*
diff --git a/usr.bin/mail/temp.c b/usr.bin/mail/temp.c
index 6736aefac91..90373e0b091 100644
--- a/usr.bin/mail/temp.c
+++ b/usr.bin/mail/temp.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: temp.c,v 1.2 1996/06/11 12:53:51 deraadt Exp $ */
+/* $NetBSD: temp.c,v 1.5 1996/06/08 19:48:42 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)temp.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: temp.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)temp.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: temp.c,v 1.2 1996/06/11 12:53:51 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
@@ -57,7 +63,6 @@ void
tinit()
{
register char *cp;
- int len;
if ((tmpdir = getenv("TMPDIR")) == NULL) {
tmpdir = _PATH_TMP;
@@ -81,11 +86,9 @@ tinit()
}
} else {
if ((cp = username()) == NOSTR) {
- myname = "ubluit";
- if (rcvmode) {
- printf("Who are you!?\n");
+ myname = "nobody";
+ if (rcvmode)
exit(1);
- }
} else
myname = savestr(cp);
}
diff --git a/usr.bin/mail/tty.c b/usr.bin/mail/tty.c
index a982214ee47..6b3f4d2c20a 100644
--- a/usr.bin/mail/tty.c
+++ b/usr.bin/mail/tty.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: tty.c,v 1.2 1996/06/11 12:53:52 deraadt Exp $ */
+/* $NetBSD: tty.c,v 1.5 1996/06/08 19:48:43 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)tty.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: tty.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: tty.c,v 1.2 1996/06/11 12:53:52 deraadt Exp $";
+#endif
#endif /* not lint */
/*
@@ -44,6 +50,7 @@ static char rcsid[] = "$Id: tty.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
#include "rcv.h"
#include "extern.h"
+#include <sys/ioctl.h>
static cc_t c_erase; /* Current erase char */
static cc_t c_kill; /* Current kill char */
@@ -71,7 +78,10 @@ grabh(hp, gflags)
sig_t savettou;
sig_t savettin;
int errs;
- void ttyint();
+#ifdef __GNUC__
+ /* Avoid longjmp clobbering */
+ (void) &saveint;
+#endif
savetstp = signal(SIGTSTP, SIG_DFL);
savettou = signal(SIGTTOU, SIG_DFL);
@@ -157,8 +167,12 @@ readtty(pr, src)
{
char ch, canonb[BUFSIZ];
int c;
- register char *cp, *cp2;
- void ttystop();
+ char *cp, *cp2;
+#if __GNUC__
+ /* Avoid longjmp clobbering */
+ (void) &c;
+ (void) &cp2;
+#endif
fputs(pr, stdout);
fflush(stdout);
@@ -175,7 +189,7 @@ readtty(pr, src)
fflush(stdout);
#else
cp = src == NOSTR ? "" : src;
- while (c = *cp++) {
+ while ((c = *cp++) != '\0') {
if ((c_erase != _POSIX_VDISABLE && c == c_erase) ||
(c_kill != _POSIX_VDISABLE && c == c_kill)) {
ch = '\\';
@@ -258,10 +272,13 @@ ttystop(s)
int s;
{
sig_t old_action = signal(s, SIG_DFL);
+ sigset_t nset;
- sigsetmask(sigblock(0) & ~sigmask(s));
+ sigemptyset(&nset);
+ sigaddset(&nset, s);
+ sigprocmask(SIG_BLOCK, &nset, NULL);
kill(0, s);
- sigblock(sigmask(s));
+ sigprocmask(SIG_UNBLOCK, &nset, NULL);
signal(s, old_action);
longjmp(rewrite, 1);
}
diff --git a/usr.bin/mail/v7.local.c b/usr.bin/mail/v7.local.c
index 9d56548d106..dba1f57b9fa 100644
--- a/usr.bin/mail/v7.local.c
+++ b/usr.bin/mail/v7.local.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: v7.local.c,v 1.2 1996/06/11 12:53:53 deraadt Exp $ */
+/* $NetBSD: v7.local.c,v 1.7 1996/06/08 19:48:44 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)v7.local.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: v7.local.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: v7.local.c,v 1.2 1996/06/11 12:53:53 deraadt Exp $";
+#endif
#endif /* not lint */
/*
@@ -83,8 +89,12 @@ char *
username()
{
char *np;
+ uid_t uid;
if ((np = getenv("USER")) != NOSTR)
return np;
- return getname(getuid());
+ if ((np = getname(uid = getuid())) != NOSTR)
+ return np;
+ printf("Cannot associate a name with uid %d\n", uid);
+ return NOSTR;
}
diff --git a/usr.bin/mail/vars.c b/usr.bin/mail/vars.c
index 0316cb27f4f..22a1d9d8cf7 100644
--- a/usr.bin/mail/vars.c
+++ b/usr.bin/mail/vars.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: vars.c,v 1.2 1996/06/11 12:53:53 deraadt Exp $ */
+/* $NetBSD: vars.c,v 1.4 1996/06/08 19:48:45 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)vars.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: vars.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: vars.c,v 1.2 1996/06/11 12:53:53 deraadt Exp $";
+#endif
#endif /* not lint */
#include "rcv.h"
diff --git a/usr.bin/mail/version.c b/usr.bin/mail/version.c
index d9f4030ab26..376bae68980 100644
--- a/usr.bin/mail/version.c
+++ b/usr.bin/mail/version.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: version.c,v 1.2 1996/06/11 12:53:54 deraadt Exp $ */
+/* $NetBSD: version.c,v 1.4 1996/06/08 19:48:46 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)version.c 8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$Id: version.c,v 1.1 1995/10/18 08:45:39 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 6/6/93";
+#else
+static char rcsid[] = "$OpenBSD: version.c,v 1.2 1996/06/11 12:53:54 deraadt Exp $";
+#endif
#endif /* not lint */
/*