diff options
Diffstat (limited to 'sbin/restore/main.c')
-rw-r--r-- | sbin/restore/main.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/sbin/restore/main.c b/sbin/restore/main.c index 57620fe..c2c804f 100644 --- a/sbin/restore/main.c +++ b/sbin/restore/main.c @@ -38,14 +38,14 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95"; +static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/7/94"; #endif /* not lint */ #include <sys/param.h> #include <sys/time.h> -#include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> +#include <ufs/ufs/dinode.h> #include <protocols/dumprestore.h> #include <err.h> @@ -54,7 +54,6 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95"; #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include "pathnames.h" #include "restore.h" @@ -67,7 +66,7 @@ long dumpnum = 1; long volno = 0; long ntrec; char *dumpmap; -char *usedinomap; +char *clrimap; ino_t maxino; time_t dumptime; time_t dumpdate; @@ -83,13 +82,18 @@ main(argc, argv) { int ch; ino_t ino; - char *inputdev = _PATH_DEFTAPE; + char *inputdev; char *symtbl = "./restoresymtable"; char *p, name[MAXPATHLEN]; + /* Temp files should *not* be readable. We set permissions later. */ + (void) umask(077); + if (argc < 2) usage(); + if ((inputdev = getenv("TAPE")) == NULL) + inputdev = _PATH_DEFTAPE; obsolete(&argc, &argv); while ((ch = getopt(argc, argv, "b:cdf:himNRrs:tvxy")) != EOF) switch(ch) { @@ -235,7 +239,7 @@ main(argc, argv) extractdirs(0); initsymtable((char *)0); while (argc--) { - canon(*argv++, name); + canon(*argv++, name, sizeof(name)); ino = dirlookup(name); if (ino == 0) continue; @@ -250,7 +254,7 @@ main(argc, argv) extractdirs(1); initsymtable((char *)0); while (argc--) { - canon(*argv++, name); + canon(*argv++, name, sizeof(name)); ino = dirlookup(name); if (ino == 0) continue; @@ -272,12 +276,12 @@ main(argc, argv) static void usage() { - (void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n", - "restore -i [-chmvy] [-b blocksize] [-f file] [-s fileno]", - "restore -r [-cvy] [-b blocksize] [-f file] [-s fileno]", - "restore -R [-cvy] [-b blocksize] [-f file] [-s fileno]", - "restore -x [-chmvy] [-b blocksize] [-f file] [-s fileno] [file ...]", - "restore -t [-chvy] [-b blocksize] [-f file] [-s fileno] [file ...]"); + (void)fprintf(stderr, "usage:\t%s%s%s%s%s", + "restore tfhsvy [file ...]\n", + "\trestore xfhmsvy [file ...]\n", + "\trestore ifhmsvy\n", + "\trestore rfsvy\n", + "\trestore Rfsvy\n"); done(1); } @@ -309,23 +313,22 @@ obsolete(argcp, argvp) err(1, NULL); *nargv++ = *argv; - argv += 2; + argv += 2, argc -= 2; for (flags = 0; *ap; ++ap) { - switch (*ap) { + switch(*ap) { case 'b': case 'f': case 's': - if (*argv == NULL) { - warnx("option requires an argument -- %c", *ap); - usage(); - } + if (argc < 1) + usage(); if ((nargv[0] = malloc(strlen(*argv) + 2 + 1)) == NULL) err(1, NULL); nargv[0][0] = '-'; nargv[0][1] = *ap; (void)strcpy(&nargv[0][2], *argv); - ++argv; + if (*argv != NULL) + ++argv; ++nargv; break; default: @@ -346,7 +349,4 @@ obsolete(argcp, argvp) /* Copy remaining arguments. */ while (*nargv++ = *argv++); - - /* Update argument count. */ - *argcp = nargv - *argvp - 1; } |