diff options
author | sobomax <sobomax@FreeBSD.org> | 2001-08-13 09:20:15 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2001-08-13 09:20:15 +0000 |
commit | d94655dace7abaec2d57925e578ebdf89d778ec8 (patch) | |
tree | bccd94d3c73454564dff1c173a5d4fff6ff8e525 | |
parent | 91054a15a01c58988d11094d93f2bc02adc96001 (diff) | |
download | FreeBSD-src-d94655dace7abaec2d57925e578ebdf89d778ec8.zip FreeBSD-src-d94655dace7abaec2d57925e578ebdf89d778ec8.tar.gz |
Honour `TMPDIR' environment variable.
Reviewed by: ru
Approved by: ru
MFC after: 2 weeks
-rw-r--r-- | sbin/restore/dirs.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 53743a8..c61737a 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"); |