diff --git a/usr.bin/error/pathnames.h b/usr.bin/error/pathnames.h index 42ca04ebb335..961a5383ad22 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 e4b85e1fe903..bc146f79b7f0 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 +#include #include #include #include @@ -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) {