summaryrefslogtreecommitdiff
path: root/usr.bin/error
diff options
context:
space:
mode:
authorkleink <kleink@NetBSD.org>1999-11-06 15:11:46 +0000
committerkleink <kleink@NetBSD.org>1999-11-06 15:11:46 +0000
commit513b25c0e97b90f1cf290aeca3dcaee51d3744ed (patch)
tree22b685501b1a8778c77da52124334fa26cd7c6cf /usr.bin/error
parent1447a4671dde697d4574d6ad624261819ca1c48b (diff)
For temporary files' pathnames, check $TMPDIR before falling back to _PATH_TMP.
Diffstat (limited to 'usr.bin/error')
-rw-r--r--usr.bin/error/pathnames.h5
-rw-r--r--usr.bin/error/touch.c14
2 files changed, 10 insertions, 9 deletions
diff --git a/usr.bin/error/pathnames.h b/usr.bin/error/pathnames.h
index 42ca04ebb33..961a5383ad2 100644
--- a/usr.bin/error/pathnames.h
+++ b/usr.bin/error/pathnames.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pathnames.h,v 1.3 1995/09/02 06:15:40 jtc Exp $ */
+/* $NetBSD: pathnames.h,v 1.4 1999/11/06 15:11:46 kleink Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -41,5 +41,4 @@
#define IG_FILE2 "llib-port"
#define IG_FILE3 "/usr/lib/llib-lc"
#define IG_FILE4 "/usr/lib/llib-port"
-#undef _PATH_TMP
-#define _PATH_TMP "/tmp/ErrorXXXXXX"
+#define TMPFILE "ErrorXXXXXX"
diff --git a/usr.bin/error/touch.c b/usr.bin/error/touch.c
index e4b85e1fe90..bc146f79b7f 100644
--- a/usr.bin/error/touch.c
+++ b/usr.bin/error/touch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: touch.c,v 1.8 1998/03/30 02:19:45 mrg Exp $ */
+/* $NetBSD: touch.c,v 1.9 1999/11/06 15:11:46 kleink Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,10 +38,10 @@
#if 0
static char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: touch.c,v 1.8 1998/03/30 02:19:45 mrg Exp $");
+__RCSID("$NetBSD: touch.c,v 1.9 1999/11/06 15:11:46 kleink Exp $");
#endif /* not lint */
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
#include <signal.h>
@@ -539,8 +539,7 @@ execvarg(n_pissed_on, r_argc, r_argv)
FILE *o_touchedfile; /* the old file */
FILE *n_touchedfile; /* the new file */
char *o_name;
-char n_name[64];
-char *canon_name = _PATH_TMP;
+char n_name[MAXPATHLEN];
int o_lineno;
int n_lineno;
boolean tempfileopen = FALSE;
@@ -553,6 +552,7 @@ edit(name)
char *name;
{
int fd;
+ const char *tmpdir;
o_name = name;
if ( (o_touchedfile = fopen(name, "r")) == NULL){
@@ -560,7 +560,9 @@ edit(name)
processname, name);
return(TRUE);
}
- (void)strcpy(n_name, canon_name);
+ if ((tmpdir = getenv("TMPDIR")) == NULL)
+ tmpdir = _PATH_TMP;
+ (void)snprintf(n_name, sizeof (n_name), "%s/%s", tmpdir, TMPFILE);
fd = -1;
if ((fd = mkstemp(n_name)) == -1 ||
(n_touchedfile = fdopen(fd, "w")) == NULL) {