Honour `TMPDIR' environment variable.

Reviewed by:	ru
Approved by:	ru
MFC after:	2 weeks
This commit is contained in:
Maxim Sobolev 2001-08-13 09:20:15 +00:00
parent 0ce18d0354
commit 4afde8553d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81579

View File

@ -146,9 +146,12 @@ extractdirs(genmode)
struct inotab *itp;
struct direct nulldir;
int fd;
const char *tmpdir;
vprintf(stdout, "Extract directories from tape\n");
(void) sprintf(dirfile, "%srstdir%d", _PATH_TMP, dumpdate);
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0')
tmpdir = _PATH_TMP;
(void) sprintf(dirfile, "%s/rstdir%d", tmpdir, dumpdate);
if (command != 'r' && command != 'R') {
(void *) strcat(dirfile, "-XXXXXX");
fd = mkstemp(dirfile);
@ -161,7 +164,7 @@ extractdirs(genmode)
done(1);
}
if (genmode != 0) {
(void) sprintf(modefile, "%srstmode%d", _PATH_TMP, dumpdate);
(void) sprintf(modefile, "%s/rstmode%d", tmpdir, dumpdate);
if (command != 'r' && command != 'R') {
(void *) strcat(modefile, "-XXXXXX");
fd = mkstemp(modefile);
@ -593,10 +596,13 @@ setdirmodes(flags)
struct modeinfo node;
struct entry *ep;
char *cp;
const char *tmpdir;
vprintf(stdout, "Set directory mode, owner, and times.\n");
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0')
tmpdir = _PATH_TMP;
if (command == 'r' || command == 'R')
(void) sprintf(modefile, "%srstmode%d", _PATH_TMP, dumpdate);
(void) sprintf(modefile, "%s/rstmode%d", tmpdir, dumpdate);
if (modefile[0] == '#') {
panic("modefile not defined\n");
fprintf(stderr, "directory mode, owner, and times not set\n");