For temporary files' pathnames, check $TMPDIR before falling back to _PATH_TMP.
This commit is contained in:
parent
1447a4671d
commit
513b25c0e9
|
@ -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"
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue