summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-10-30 17:16:47 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-10-30 17:16:47 +0000
commit458b80a106b294d4d78828e7d7c6439c802ad85e (patch)
treef36039ac4384c3d624775aee8319bf790ee48296 /bin
parentd5efc44ca959b708884e380e90b9c7191680f130 (diff)
Use mkstemp(3) for here document (<<) temporary files instead of $$
Problem noted by proton@ENERGYMECH.NET
Diffstat (limited to 'bin')
-rw-r--r--bin/csh/csh.14
-rw-r--r--bin/csh/csh.c5
-rw-r--r--bin/csh/csh.h3
-rw-r--r--bin/csh/dol.c9
4 files changed, 9 insertions, 12 deletions
diff --git a/bin/csh/csh.1 b/bin/csh/csh.1
index ad9bc4cd76e..1793043ab03 100644
--- a/bin/csh/csh.1
+++ b/bin/csh/csh.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: csh.1,v 1.37 2000/10/19 18:29:26 aaron Exp $
+.\" $OpenBSD: csh.1,v 1.38 2000/10/30 17:16:44 millert Exp $
.\" $NetBSD: csh.1,v 1.10 1995/03/21 09:02:35 cgd Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
@@ -2677,7 +2677,7 @@ read by login shell, at logout
.It Pa /bin/sh
standard shell, for shell scripts not starting with a
.Ql #
-.It Pa /tmp/sh*
+.It Pa /tmp/sh.*
temporary file for
.Ql <<
.It Pa /etc/passwd
diff --git a/bin/csh/csh.c b/bin/csh/csh.c
index 557c6d38a7a..0066c6a314d 100644
--- a/bin/csh/csh.c
+++ b/bin/csh/csh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: csh.c,v 1.12 2000/09/04 19:33:58 mickey Exp $ */
+/* $OpenBSD: csh.c,v 1.13 2000/10/30 17:16:45 millert Exp $ */
/* $NetBSD: csh.c,v 1.14 1995/04/29 23:21:28 mycroft Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
#else
-static char rcsid[] = "$OpenBSD: csh.c,v 1.12 2000/09/04 19:33:58 mickey Exp $";
+static char rcsid[] = "$OpenBSD: csh.c,v 1.13 2000/10/30 17:16:45 millert Exp $";
#endif
#endif /* not lint */
@@ -266,7 +266,6 @@ main(argc, argv)
set(STRshell, Strsave(STR_SHELLPATH));
doldol = putn((int) getpid()); /* For $$ */
- shtemp = Strspl(STRtmpsh, doldol); /* For << */
/*
* Record the interrupt states from the parent process. If the parent is
diff --git a/bin/csh/csh.h b/bin/csh/csh.h
index eca754f2a10..fcb4e8b92cd 100644
--- a/bin/csh/csh.h
+++ b/bin/csh/csh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: csh.h,v 1.6 2000/08/30 01:46:34 mickey Exp $ */
+/* $OpenBSD: csh.h,v 1.7 2000/10/30 17:16:46 millert Exp $ */
/* $NetBSD: csh.h,v 1.9 1995/03/21 09:02:40 cgd Exp $ */
/*-
@@ -139,7 +139,6 @@ int onelflg; /* 2 -> need line for -t, 1 -> exit on read */
Char *ffile; /* Name of shell file for $0 */
char *seterr; /* Error message from scanner/parser */
-Char *shtemp; /* Temp name for << shell files in /tmp */
#include <sys/types.h>
#include <sys/time.h>
diff --git a/bin/csh/dol.c b/bin/csh/dol.c
index a50f634d98d..6dd48a109bd 100644
--- a/bin/csh/dol.c
+++ b/bin/csh/dol.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dol.c,v 1.4 1997/07/25 18:58:01 mickey Exp $ */
+/* $OpenBSD: dol.c,v 1.5 2000/10/30 17:16:46 millert Exp $ */
/* $NetBSD: dol.c,v 1.8 1995/09/27 00:38:38 jtc Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)dol.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: dol.c,v 1.4 1997/07/25 18:58:01 mickey Exp $";
+static char rcsid[] = "$OpenBSD: dol.c,v 1.5 2000/10/30 17:16:46 millert Exp $";
#endif
#endif /* not lint */
@@ -851,10 +851,9 @@ heredoc(term)
register Char *lbp, *obp, *mbp;
Char **vp;
bool quoted;
- char *tmp;
+ char tmp[] = "/tmp/sh.XXXXXXXX";
- tmp = short2str(shtemp);
- if (open(tmp, O_RDWR | O_CREAT | O_TRUNC, 0600) < 0)
+ if (mkstemp(tmp) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
(void) unlink(tmp); /* 0 0 inode! */
Dv[0] = term;