X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Fmain.c;h=98674e4c8fc4c171cbef59a6489e3b436c4160f9;hp=723a88f00ebf98348fb626b8b7569df99d343faf;hb=83a6b4df0b7b7aecc0d3940549d0d480adff35a6;hpb=a18d599791e977f3e3d26123031e6ed4e64d6d08 diff --git a/restore/main.c b/restore/main.c index 723a88f..98674e4 100644 --- a/restore/main.c +++ b/restore/main.c @@ -18,11 +18,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.41 2002/07/19 14:57:39 stelian Exp $"; + "$Id: main.c,v 1.44 2003/03/30 15:40:38 stelian Exp $"; #endif /* not lint */ #include @@ -90,8 +86,8 @@ char command = '\0'; long dumpnum = 1; long volno = 0; long ntrec; -char *dumpmap; -char *usedinomap; +char *dumpmap = NULL; +char *usedinomap = NULL; dump_ino_t maxino; time_t dumptime; time_t dumpdate; @@ -124,6 +120,8 @@ static void obsolete __P((int *, char **[])); static void usage __P((void)); static void use_stdin __P((const char *)); +#define FORCED_UMASK (077) + int main(int argc, char *argv[]) { @@ -134,6 +132,7 @@ main(int argc, char *argv[]) char *p, name[MAXPATHLEN]; FILE *filelist = NULL; char fname[MAXPATHLEN]; + mode_t orig_umask; #ifdef DEBUG_QFA time_t tistart, tiend, titaken; #endif @@ -143,7 +142,7 @@ main(int argc, char *argv[]) #endif /* USE_QFA */ /* Temp files should *not* be readable. We set permissions later. */ - (void) umask(077); + orig_umask = umask(FORCED_UMASK); filesys[0] = '\0'; #if defined(__linux__) || defined(sunos) __progname = argv[0]; @@ -550,8 +549,12 @@ main(int argc, char *argv[]) #endif setup(); msg("writing QFA positions to %s\n", gTapeposfile); - if ((gTapeposfd = open(gTapeposfile, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR)) < 0) + (void) umask(orig_umask); + if ((gTapeposfd = open(gTapeposfile, O_WRONLY|O_CREAT|O_TRUNC, + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP + |S_IROTH|S_IWOTH)) < 0) errx(1, "can't create tapeposfile\n"); + (void) umask(FORCED_UMASK); /* print QFA-file header */ sprintf(gTps, "%s\n%s\n%ld\n\n", QFA_MAGIC, QFA_VERSION,(unsigned long)spcl.c_date); if (write(gTapeposfd, gTps, strlen(gTps)) != (ssize_t)strlen(gTps))