summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-07-24 17:27:14 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-07-24 17:27:14 +0000
commit04be6204f118ee452b9ac608af4c5732839cfdba (patch)
tree4f43aa414e521c41dbc804442b49d4b304d96ee3 /usr.bin
parent408827f4d787d011ab811cfd58c5e5d08f849396 (diff)
tempnam(3) goes bye bye.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mail/cmd1.c7
-rw-r--r--usr.bin/mail/collect.c41
-rw-r--r--usr.bin/mail/edit.c48
-rw-r--r--usr.bin/mail/extern.h6
-rw-r--r--usr.bin/mail/fio.c14
-rw-r--r--usr.bin/mail/lex.c10
-rw-r--r--usr.bin/mail/names.c23
-rw-r--r--usr.bin/mail/quit.c24
-rw-r--r--usr.bin/mail/send.c24
-rw-r--r--usr.bin/mail/temp.c9
10 files changed, 109 insertions, 97 deletions
diff --git a/usr.bin/mail/cmd1.c b/usr.bin/mail/cmd1.c
index e6e0c783043..52553e92beb 100644
--- a/usr.bin/mail/cmd1.c
+++ b/usr.bin/mail/cmd1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd1.c,v 1.9 1997/07/22 18:54:34 millert Exp $ */
+/* $OpenBSD: cmd1.c,v 1.10 1997/07/24 17:27:09 millert Exp $ */
/* $NetBSD: cmd1.c,v 1.9 1997/07/09 05:29:48 mikel Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95";
#else
-static char rcsid[] = "$OpenBSD: cmd1.c,v 1.9 1997/07/22 18:54:34 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmd1.c,v 1.10 1997/07/24 17:27:09 millert Exp $";
#endif
#endif /* not lint */
@@ -204,7 +204,8 @@ printhead(mesg)
if (mp->m_flag & MBOX)
dispc = 'M';
parse(headline, &hl, pbuf);
- snprintf(wcount, sizeof(wcount), "%3d/%-5d", mp->m_lines, mp->m_size);
+ (void)snprintf(wcount, sizeof(wcount), "%3d/%-5d", mp->m_lines,
+ mp->m_size);
subjlen = screenwidth - 50 - strlen(wcount);
name = value("show-rcpt") != NULL ?
skin(hfield("to", mp)) : nameof(mp, 0);
diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c
index 32bac7934d8..987d3381169 100644
--- a/usr.bin/mail/collect.c
+++ b/usr.bin/mail/collect.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: collect.c,v 1.11 1997/07/22 18:54:36 millert Exp $ */
+/* $OpenBSD: collect.c,v 1.12 1997/07/24 17:27:10 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.11 1997/07/22 18:54:36 millert Exp $";
+static char rcsid[] = "$OpenBSD: collect.c,v 1.12 1997/07/24 17:27:10 millert Exp $";
#endif
#endif /* not lint */
@@ -81,10 +81,9 @@ collect(hp, printheaders)
int printheaders;
{
FILE *fbuf;
- int lc, cc, escape, eofcount;
+ int lc, cc, escape, eofcount, fd;
register int c, t;
- char linebuf[LINESIZE], *cp;
- extern char *tempMail;
+ char linebuf[LINESIZE], tempname[PATHSIZE], *cp;
char getsub;
sigset_t oset, nset;
int longline, lastlong, rc; /* Can deal with lines > LINESIZE */
@@ -114,7 +113,7 @@ collect(hp, printheaders)
savettou = signal(SIGTTOU, collstop);
savettin = signal(SIGTTIN, collstop);
if (sigsetjmp(collabort, 1) || sigsetjmp(colljmp, 1)) {
- rm(tempMail);
+ (void)rm(tempname);
goto err;
}
sigdelset(&oset, SIGINT);
@@ -122,11 +121,14 @@ collect(hp, printheaders)
sigprocmask(SIG_SETMASK, &oset, NULL);
noreset++;
- if ((collf = Fopen(tempMail, "w+")) == NULL) {
- warn(tempMail);
+ (void)snprintf(tempname, sizeof(tempname),
+ "%s/mail.RsXXXXXXXXXX", tmpdir);
+ if ((fd = mkstemp(tempname)) == -1 ||
+ (collf = Fdopen(fd, "w+")) == NULL) {
+ warn(tempname);
goto err;
}
- unlink(tempMail);
+ (void)rm(tempname);
/*
* If we are going to prompt for a subject,
@@ -350,7 +352,7 @@ cont:
* standard list processing garbage.
* If ~f is given, we don't shift over.
*/
- if (forward(linebuf + 2, collf, c) < 0)
+ if (forward(linebuf + 2, collf, tempname, c) < 0)
goto err;
goto cont;
case '?':
@@ -507,15 +509,18 @@ mespipe(fp, cmd)
char cmd[];
{
FILE *nf;
+ int fd;
sig_t sigint = signal(SIGINT, SIG_IGN);
- extern char *tempEdit;
- char *shell;
+ char *shell, tempname[PATHSIZE];
- if ((nf = Fopen(tempEdit, "w+")) == NULL) {
- warn(tempEdit);
+ (void)snprintf(tempname, sizeof(tempname),
+ "%s/mail.ReXXXXXXXXXX", tmpdir);
+ if ((fd = mkstemp(tempname)) == -1 ||
+ (nf = Fdopen(fd, "w+")) == NULL) {
+ warn(tempname);
goto out;
}
- (void)unlink(tempEdit);
+ (void)rm(tempname);
/*
* stdin = current message.
* stdout = new message.
@@ -551,13 +556,13 @@ out:
* should shift over and 'f' if not.
*/
int
-forward(ms, fp, f)
+forward(ms, fp, fn, f)
char ms[];
FILE *fp;
+ char *fn;
int f;
{
register int *msgvec;
- extern char *tempMail;
struct ignoretab *ig;
char *tabst;
@@ -586,7 +591,7 @@ forward(ms, fp, f)
touch(mp);
printf(" %d", *msgvec);
if (send(mp, fp, ig, tabst) < 0) {
- warn(tempMail);
+ warn(fn);
return(-1);
}
}
diff --git a/usr.bin/mail/edit.c b/usr.bin/mail/edit.c
index d290d621c09..67efa927b1d 100644
--- a/usr.bin/mail/edit.c
+++ b/usr.bin/mail/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.5 1997/07/14 00:24:26 millert Exp $ */
+/* $OpenBSD: edit.c,v 1.6 1997/07/24 17:27:10 millert Exp $ */
/* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: edit.c,v 1.5 1997/07/14 00:24:26 millert Exp $";
+static char rcsid[] = "$OpenBSD: edit.c,v 1.6 1997/07/24 17:27:10 millert Exp $";
#endif
#endif /* not lint */
@@ -155,17 +155,19 @@ run_editor(fp, size, type, readonly)
register FILE *nf = NULL;
register int t;
time_t modtime;
- char *edit;
+ char *edit, tempname[PATHSIZE];
struct stat statb;
- extern char *tempEdit;
- if ((t = creat(tempEdit, readonly ? 0400 : 0600)) < 0) {
- warn(tempEdit);
+ (void)snprintf(tempname, sizeof(tempname),
+ "%s/mail.ReXXXXXXXXXX", tmpdir);
+ if ((t = mkstemp(tempname)) == -1 ||
+ (nf = Fdopen(t, "w")) == NULL) {
+ warn(tempname);
goto out;
}
- if ((nf = Fdopen(t, "w")) == NULL) {
- warn(tempEdit);
- (void)unlink(tempEdit);
+ if (readonly && fchmod(t, 0400) == -1) {
+ warn(tempname);
+ (void)rm(tempname);
goto out;
}
if (size >= 0)
@@ -181,22 +183,22 @@ run_editor(fp, size, type, readonly)
modtime = statb.st_mtime;
if (ferror(nf)) {
(void)Fclose(nf);
- warn(tempEdit);
- (void)unlink(tempEdit);
+ warn(tempname);
+ (void)rm(tempname);
nf = NULL;
goto out;
}
if (Fclose(nf) < 0) {
- warn(tempEdit);
- (void)unlink(tempEdit);
+ warn(tempname);
+ (void)rm(tempname);
nf = NULL;
goto out;
}
nf = NULL;
if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NULL)
edit = type == 'e' ? _PATH_EX : _PATH_VI;
- if (run_command(edit, 0, -1, -1, tempEdit, NULL, NULL) < 0) {
- (void)unlink(tempEdit);
+ if (run_command(edit, 0, -1, -1, tempname, NULL, NULL) < 0) {
+ (void)rm(tempname);
goto out;
}
/*
@@ -204,26 +206,26 @@ run_editor(fp, size, type, readonly)
* temporary and return.
*/
if (readonly) {
- (void)unlink(tempEdit);
+ (void)rm(tempname);
goto out;
}
- if (stat(tempEdit, &statb) < 0) {
- warn(tempEdit);
+ if (stat(tempname, &statb) < 0) {
+ warn(tempname);
goto out;
}
if (modtime == statb.st_mtime) {
- (void)unlink(tempEdit);
+ (void)rm(tempname);
goto out;
}
/*
* Now switch to new file.
*/
- if ((nf = Fopen(tempEdit, "a+")) == NULL) {
- warn(tempEdit);
- (void)unlink(tempEdit);
+ if ((nf = Fopen(tempname, "a+")) == NULL) {
+ warn(tempname);
+ (void)rm(tempname);
goto out;
}
- (void)unlink(tempEdit);
+ (void)rm(tempname);
out:
return(nf);
}
diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h
index a46540d8369..ea3246294c0 100644
--- a/usr.bin/mail/extern.h
+++ b/usr.bin/mail/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.8 1997/07/24 16:23:36 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.9 1997/07/24 17:27:10 millert Exp $ */
/* $NetBSD: extern.h,v 1.7 1997/07/09 05:22:00 mikel Exp $ */
/*-
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/20/95
- * $OpenBSD: extern.h,v 1.8 1997/07/24 16:23:36 millert Exp $
+ * $OpenBSD: extern.h,v 1.9 1997/07/24 17:27:10 millert Exp $
*/
struct name;
@@ -135,7 +135,7 @@ 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 forward __P((char [], FILE *, int));
+int forward __P((char [], FILE *, char *, int));
void free_child __P((int));
int from __P((void *));
off_t fsize __P((FILE *));
diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c
index 90bebf42427..9b5d4495f19 100644
--- a/usr.bin/mail/fio.c
+++ b/usr.bin/mail/fio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fio.c,v 1.9 1997/07/24 16:23:37 millert Exp $ */
+/* $OpenBSD: fio.c,v 1.10 1997/07/24 17:27:11 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.9 1997/07/24 16:23:37 millert Exp $";
+static char rcsid[] = "$OpenBSD: fio.c,v 1.10 1997/07/24 17:27:11 millert Exp $";
#endif
#endif /* not lint */
@@ -77,7 +77,7 @@ setptr(ibuf, offset)
(void)snprintf(pathbuf, sizeof(pathbuf), "%s/mail.XXXXXXXXXX", tmpdir);
if ((c = mkstemp(pathbuf)) == -1 || (mestmp = Fdopen(c, "r+")) == NULL)
err(1, "can't open %s", pathbuf);
- (void)unlink(pathbuf);
+ (void)rm(pathbuf);
if (offset == 0) {
msgCount = 0;
@@ -368,12 +368,12 @@ expand(name)
/* fall through */
}
if (name[0] == '+' && getfold(cmdbuf, sizeof(cmdbuf)) >= 0) {
- snprintf(xname, sizeof(xname), "%s/%s", cmdbuf, name + 1);
+ (void)snprintf(xname, sizeof(xname), "%s/%s", cmdbuf, name + 1);
name = savestr(xname);
}
/* catch the most common shell meta character */
if (name[0] == '~' && (name[1] == '/' || name[1] == '\0')) {
- snprintf(xname, sizeof(xname), "%s%s", homedir, name + 1);
+ (void)snprintf(xname, sizeof(xname), "%s%s", homedir, name + 1);
name = savestr(xname);
}
if (!anyof(name, "~{[*?$`'\"\\"))
@@ -382,7 +382,7 @@ expand(name)
warn("pipe");
return(name);
}
- snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name);
+ (void)snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name);
if ((shell = value("SHELL")) == NULL)
shell = _PATH_CSHELL;
pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NULL);
@@ -437,7 +437,7 @@ getfold(name, namelen)
strncpy(name, folder, namelen-1);
name[namelen-1] = '\0';
} else
- snprintf(name, namelen, "%s/%s", homedir, folder);
+ (void)snprintf(name, namelen, "%s/%s", homedir, folder);
return(0);
}
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index 85f1d9bf74f..342f4d2198a 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.11 1997/07/24 16:23:38 millert Exp $ */
+/* $OpenBSD: lex.c,v 1.12 1997/07/24 17:27:11 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.11 1997/07/24 16:23:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: lex.c,v 1.12 1997/07/24 17:27:11 millert Exp $";
#endif
#endif /* not lint */
@@ -70,7 +70,7 @@ setfile(name)
struct stat stb;
char isedit = *name != '%';
char *who = name[1] ? name + 1 : myname;
- char tempname[MAXPATHLEN];
+ char tempname[PATHSIZE];
static int shudclob;
if ((name = expand(name)) == NULL)
@@ -146,7 +146,7 @@ setfile(name)
if ((itf = fopen(tempname, "r")) == NULL)
err(1, tempname);
(void)fcntl(fileno(itf), F_SETFD, 1);
- rm(tempname);
+ (void)rm(tempname);
setptr(ibuf, 0);
setmsize(msgCount);
/*
@@ -660,7 +660,7 @@ newfileinfo(omsgCount)
if (getfold(fname, sizeof(fname)) >= 0) {
strncat(fname, "/", sizeof(fname) - strlen(fname) - 1);
if (strncmp(fname, mailname, strlen(fname)) == 0) {
- snprintf(zname, sizeof(zname), "+%s",
+ (void)snprintf(zname, sizeof(zname), "+%s",
mailname + strlen(fname));
ename = zname;
}
diff --git a/usr.bin/mail/names.c b/usr.bin/mail/names.c
index 32b0f4357c7..943c945834b 100644
--- a/usr.bin/mail/names.c
+++ b/usr.bin/mail/names.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: names.c,v 1.6 1997/07/14 00:24:29 millert Exp $ */
+/* $OpenBSD: names.c,v 1.7 1997/07/24 17:27:12 millert Exp $ */
/* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: names.c,v 1.6 1997/07/14 00:24:29 millert Exp $";
+static char rcsid[] = "$OpenBSD: names.c,v 1.7 1997/07/24 17:27:12 millert Exp $";
#endif
#endif /* not lint */
@@ -230,7 +230,6 @@ outof(names, fo, hp)
char *date, *fname;
FILE *fout, *fin;
int ispipe;
- extern char *tempEdit;
top = names;
np = names;
@@ -253,15 +252,21 @@ outof(names, fo, hp)
*/
if (image < 0) {
- if ((fout = Fopen(tempEdit, "a")) == NULL) {
- warn(tempEdit);
+ int fd;
+ char tempname[PATHSIZE];
+
+ (void)snprintf(tempname, sizeof(tempname),
+ "%s/mail.ReXXXXXXXXXX", tmpdir);
+ if ((fd = mkstemp(tempname)) == -1 ||
+ (fout = Fdopen(fd, "a")) == NULL) {
+ warn(tempname);
senderr++;
goto cant;
}
- image = open(tempEdit, 2);
- (void)unlink(tempEdit);
+ image = open(tempname, O_RDWR);
+ (void)rm(tempname);
if (image < 0) {
- warn(tempEdit);
+ warn(tempname);
senderr++;
(void)Fclose(fout);
goto cant;
@@ -275,7 +280,7 @@ outof(names, fo, hp)
(void)putc('\n', fout);
(void)fflush(fout);
if (ferror(fout))
- warn(tempEdit);
+ warn(tempname);
(void)Fclose(fout);
}
diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c
index 819f2ced2c8..3d4965ee5d0 100644
--- a/usr.bin/mail/quit.c
+++ b/usr.bin/mail/quit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: quit.c,v 1.7 1997/07/24 16:23:39 millert Exp $ */
+/* $OpenBSD: quit.c,v 1.8 1997/07/24 17:27:12 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.7 1997/07/24 16:23:39 millert Exp $";
+static char rcsid[] = "$OpenBSD: quit.c,v 1.8 1997/07/24 17:27:12 millert Exp $";
#endif
#endif /* not lint */
@@ -81,7 +81,7 @@ quit()
register struct message *mp;
int c, fd;
struct stat minfo;
- char *mbox, tempname[MAXPATHLEN];
+ char *mbox, tempname[PATHSIZE];
/*
* If we are read only, we can't do anything,
@@ -144,7 +144,7 @@ quit()
(void)Fclose(rbuf);
if ((rbuf = Fopen(tempname, "r")) == NULL)
goto newmail;
- rm(tempname);
+ (void)rm(tempname);
}
/*
@@ -228,13 +228,13 @@ quit()
}
if ((ibuf = Fopen(tempname, "r")) == NULL) {
warn(tempname);
- rm(tempname);
+ (void)rm(tempname);
(void)Fclose(obuf);
(void)Fclose(fbuf);
spool_unlock();
return;
}
- rm(tempname);
+ (void)rm(tempname);
if ((abuf = Fopen(mbox, "r")) != NULL) {
while ((c = getc(abuf)) != EOF)
(void)putc(c, obuf);
@@ -422,7 +422,7 @@ edstop()
register struct message *mp;
FILE *obuf, *ibuf, *readstat = NULL;
struct stat statb;
- char tempname[MAXPATHLEN];
+ char tempname[PATHSIZE];
if (readonly)
return;
@@ -453,7 +453,7 @@ edstop()
if (stat(mailname, &statb) >= 0 && statb.st_size > mailsize) {
int fd;
- snprintf(tempname, sizeof(tempname), "%s/mbox.XXXXXXXXXX",
+ (void)snprintf(tempname, sizeof(tempname), "%s/mbox.XXXXXXXXXX",
tmpdir);
if ((fd = mkstemp(tempname)) == -1 ||
(obuf = Fdopen(fd, "w")) == NULL) {
@@ -464,7 +464,7 @@ edstop()
if ((ibuf = Fopen(mailname, "r")) == NULL) {
warn(mailname);
(void)Fclose(obuf);
- rm(tempname);
+ (void)rm(tempname);
relsesigs();
reset(0);
}
@@ -475,11 +475,11 @@ edstop()
(void)Fclose(obuf);
if ((ibuf = Fopen(tempname, "r")) == NULL) {
warn(tempname);
- rm(tempname);
+ (void)rm(tempname);
relsesigs();
reset(0);
}
- rm(tempname);
+ (void)rm(tempname);
}
printf("\"%s\" ", mailname);
fflush(stdout);
@@ -514,7 +514,7 @@ edstop()
}
(void)Fclose(obuf);
if (gotcha) {
- rm(mailname);
+ (void)rm(mailname);
puts("removed");
} else
puts("complete");
diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c
index 85183bf2b55..a9378a1feee 100644
--- a/usr.bin/mail/send.c
+++ b/usr.bin/mail/send.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: send.c,v 1.7 1997/07/22 18:54:41 millert Exp $ */
+/* $OpenBSD: send.c,v 1.8 1997/07/24 17:27:13 millert Exp $ */
/* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: send.c,v 1.7 1997/07/22 18:54:41 millert Exp $";
+static char rcsid[] = "$OpenBSD: send.c,v 1.8 1997/07/24 17:27:13 millert Exp $";
#endif
#endif /* not lint */
@@ -431,20 +431,24 @@ infix(hp, fi)
struct header *hp;
FILE *fi;
{
- extern char *tempMail;
register FILE *nfo, *nfi;
- register int c;
+ int c, fd;
+ char tempname[PATHSIZE];
- if ((nfo = Fopen(tempMail, "w")) == NULL) {
- warn(tempMail);
+ (void)snprintf(tempname, sizeof(tempname),
+ "%s/mail.RsXXXXXXXXXX", tmpdir);
+ if ((fd = mkstemp(tempname)) == -1 ||
+ (nfo = Fdopen(fd, "w")) == NULL) {
+ warn(tempname);
return(fi);
}
- if ((nfi = Fopen(tempMail, "r")) == NULL) {
- warn(tempMail);
+ if ((nfi = Fopen(tempname, "r")) == NULL) {
+ warn(tempname);
(void)Fclose(nfo);
+ (void)rm(tempname);
return(fi);
}
- (void)rm(tempMail);
+ (void)rm(tempname);
(void)puthead(hp, nfo, GTO|GSUBJECT|GCC|GBCC|GNL|GCOMMA);
c = getc(fi);
while (c != EOF) {
@@ -458,7 +462,7 @@ infix(hp, fi)
}
(void)fflush(nfo);
if (ferror(nfo)) {
- warn(tempMail);
+ warn(tempname);
(void)Fclose(nfo);
(void)Fclose(nfi);
rewind(fi);
diff --git a/usr.bin/mail/temp.c b/usr.bin/mail/temp.c
index 97509ad274b..b6a49b1d08d 100644
--- a/usr.bin/mail/temp.c
+++ b/usr.bin/mail/temp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: temp.c,v 1.8 1997/07/24 16:23:39 millert Exp $ */
+/* $OpenBSD: temp.c,v 1.9 1997/07/24 17:27:13 millert Exp $ */
/* $NetBSD: temp.c,v 1.5 1996/06/08 19:48:42 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)temp.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: temp.c,v 1.8 1997/07/24 16:23:39 millert Exp $";
+static char rcsid[] = "$OpenBSD: temp.c,v 1.9 1997/07/24 17:27:13 millert Exp $";
#endif
#endif /* not lint */
@@ -51,8 +51,6 @@ static char rcsid[] = "$OpenBSD: temp.c,v 1.8 1997/07/24 16:23:39 millert Exp $"
* Give names to all the temporary files that we will need.
*/
-char *tempMail;
-char *tempEdit;
char *tmpdir;
void
@@ -72,9 +70,6 @@ tinit()
cp--;
}
- tempMail = tempnam(tmpdir, "Rs");
- tempEdit = tempnam(tmpdir, "Re");
-
/*
* It's okay to call savestr in here because main will
* do a spreserve() after us.