diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-17 09:06:30 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-17 09:06:30 +0000 |
commit | ccb6860367246380243bb414f644853b908a31ee (patch) | |
tree | 3827f895a19cfe450bc12629477a6cb2f2eef2cd /sbin/restore/dirs.c | |
parent | df1b0a5d93b83bf318a7669ab80f477a8a8c9eb6 (diff) |
updated patch from lukem@supp.cpr.itg.telecom.com.au to also make -r and -R work again
Diffstat (limited to 'sbin/restore/dirs.c')
-rw-r--r-- | sbin/restore/dirs.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 377f1f983ca..94138339be2 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -151,12 +151,15 @@ extractdirs(genmode) struct direct nulldir; vprintf(stdout, "Extract directories from tape\n"); - (void) sprintf(dirfile, "%s/rstdir%d-XXXXXX", _PATH_TMP, dumpdate); - if (mktemp(dirfile) == NULL) { - fprintf(stderr, - "restore: %s - cannot generate directory temporary\n", - dirfile); - exit(1); + (void) sprintf(dirfile, "%s/rstdir%d", _PATH_TMP, dumpdate); + if (command != 'r' && command != 'R') { + (void *) strcat(dirfile, "-XXXXXX"); + if (mktemp(dirfile) == NULL) { + fprintf(stderr, + "restore: %s - cannot mktemp directory temporary\n", + dirfile); + exit(1); + } } df = fopen(dirfile, "w"); if (df == NULL) { @@ -167,13 +170,15 @@ extractdirs(genmode) exit(1); } if (genmode != 0) { - (void) sprintf(modefile, "%s/rstmode%d-XXXXXX", _PATH_TMP, - dumpdate); - if (mktemp(modefile) == NULL) { - fprintf(stderr, - "restore: %s - cannot generate modefile\n", - modefile); - exit(1); + (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate); + if (command != 'r' && command != 'R') { + (void *) strcat(modefile, "-XXXXXX"); + if (mktemp(modefile) == NULL) { + fprintf(stderr, + "restore: %s - cannot mktemp modefile\n", + modefile); + exit(1); + } } mf = fopen(modefile, "w"); if (mf == NULL) { @@ -604,7 +609,13 @@ setdirmodes(flags) char *cp; vprintf(stdout, "Set directory mode, owner, and times.\n"); - (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate); + if (command == 'r' || command == 'R') + (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate); + if (modefile[0] == '#') { + panic("modefile not defined\n"); + fprintf(stderr, "directory mode, owner, and times not set\n"); + return; + } mf = fopen(modefile, "r"); if (mf == NULL) { fprintf(stderr, "fopen: %s\n", strerror(errno)); |