X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Fmain.c;h=e1e9790ec9d499c76969e354f8dd49c4b9906d09;hp=6f4098d36941c38157225f372c871be320277640;hb=b45f51d61e911ac8a040bef1efda6afd82261e03;hpb=1227625a12a66e0ded78a1997c2d23f23202a382 diff --git a/restore/main.c b/restore/main.c index 6f4098d..e1e9790 100644 --- a/restore/main.c +++ b/restore/main.c @@ -1,7 +1,8 @@ /* * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit - * Remy Card , 1994, 1995, 1996 + * Remy Card , 1994-1997 + * Stelian Pop , 1999 * */ @@ -39,34 +40,36 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1983, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95"; +#endif +static const char rcsid[] = + "$Id: main.c,v 1.2 1999/10/11 12:53:23 stelian Exp $"; #endif /* not lint */ #include -#include #include +#include #ifdef __linux__ #include #include +#include +#include #else /* __linux__ */ #include -#include #endif /* __linux__ */ #include #include -#include -#include #include #include -#include #include #ifdef __linux__ @@ -80,6 +83,8 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95"; int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0; int hflag = 1, mflag = 1, Nflag = 0; +int uflag = 0; +int dokerberos = 0; char command = '\0'; long dumpnum = 1; long volno = 0; @@ -108,19 +113,29 @@ main(argc, argv) { int ch; ino_t ino; - char *inputdev = _PATH_DEFTAPE; + char *inputdev; char *symtbl = "./restoresymtable"; char *p, name[MAXPATHLEN]; - if (argc < 2) - usage(); + /* Temp files should *not* be readable. We set permissions later. */ + (void) umask(077); #ifdef __linux__ __progname = argv[0]; #endif + if (argc < 2) + usage(); + + if ((inputdev = getenv("TAPE")) == NULL) + inputdev = _PATH_DEFTAPE; obsolete(&argc, &argv); - while ((ch = getopt(argc, argv, "b:CcdD:f:himNRrs:tT:vxy")) != EOF) +#ifdef KERBEROS +#define optlist "b:CcdDf:hikmNRrs:tTuvxy" +#else +#define optlist "b:CcdDf:himNRrs:tTuvxy" +#endif + while ((ch = getopt(argc, argv, optlist)) != -1) switch(ch) { case 'b': /* Change default tape blocksize. */ @@ -149,6 +164,11 @@ main(argc, argv) case 'h': hflag = 0; break; +#ifdef KERBEROS + case 'k': + dokerberos = 1; + break; +#endif case 'C': case 'i': case 'R': @@ -175,6 +195,9 @@ main(argc, argv) if (dumpnum <= 0) errx(1, "dump number must be greater than 0"); break; + case 'u': + uflag = 1; + break; case 'v': vflag = 1; break; @@ -301,7 +324,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; @@ -316,7 +339,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; @@ -333,16 +356,18 @@ main(argc, argv) } done(0); /* NOTREACHED */ + exit(1); /* gcc shut up */ } 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 ...]"); + "restore -i [-chkmuvy] [-b blocksize] [-f file] [-s fileno]", + "restore -r [-ckuvy] [-b blocksize] [-f file] [-s fileno]", + "restore -R [-ckuvy] [-b blocksize] [-f file] [-s fileno]", + "restore -x [-chkmuvy] [-b blocksize] [-f file] [-s fileno] [file ...]", + "restore -t [-chkuvy] [-b blocksize] [-f file] [-s fileno] [file ...]"); done(1); } @@ -357,7 +382,7 @@ obsolete(argcp, argvp) char **argvp[]; { int argc, flags; - char *ap, **argv, *flagsp, **nargv, *p; + char *ap, **argv, *flagsp=NULL, **nargv, *p=NULL; /* Setup. */ argv = *argvp; @@ -374,7 +399,7 @@ obsolete(argcp, argvp) err(1, NULL); *nargv++ = *argv; - argv += 2; + argv += 2, argc -= 2; for (flags = 0; *ap; ++ap) { switch (*ap) { @@ -410,7 +435,7 @@ obsolete(argcp, argvp) } /* Copy remaining arguments. */ - while (*nargv++ = *argv++); + while ((*nargv++ = *argv++)); /* Update argument count. */ *argcp = nargv - *argvp - 1;