diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 53743a8424c8..c61737af08a0 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -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");