Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / security / tripwire / patches / patch-af
blobe4f25409cba296a8d93579a068a3786f5c263ea6
1 $NetBSD: patch-af,v 1.2 2003/12/09 19:17:37 ben Exp $
3 --- src/dbase.build.c.orig      1994-07-25 08:24:09.000000000 -0700
4 +++ src/dbase.build.c
5 @@ -66,7 +66,6 @@
6  int files_scanned_num = 0;
7  
8  /* prototypes */
9 -char *mktemp();
10  static void database_record_write();
12  char backupfile[MAXPATHLEN+256];
13 @@ -92,6 +91,7 @@ database_build (pp_list, mode, pp_entry_
14  {
15      struct list_elem *p_fileentry;
16      struct list_elem *p_configentry;
17 +    int fdw;
18      FILE *fpw;
19      char database[MAXPATHLEN+256];
20      int entrynum,
21 @@ -130,11 +130,12 @@ database_build (pp_list, mode, pp_entry_
22             die_with_err("malloc() failed in database_build", (char *) NULL);
23         (void) strcpy(tmpfilename, TEMPFILE_TEMPLATE);
25 -       if ((char *) mktemp(tmpfilename) == NULL)
26 -           die_with_err("database_build: mktemp()", (char *) NULL);
27 +       fdw = mkstemp(tmpfilename);
28 +       if (fdw == -1)
29 +           die_with_err("database_build: mkstemp()", (char *) NULL);
30 +       unlink(tmpfilename);
32 -       (void) strcpy(tempdatabase_file, tmpfilename);
33 -       (void) strcpy(database, tempdatabase_file);
34 +       (void) strcpy(database, tmpfilename);
35         free(tmpfilename);
36      }                                  /* end if temporary database */
37      else if (mode == DBASE_UPDATE) {
38 @@ -224,6 +225,11 @@ printf("database_build(): ---> olddataba
39      }
41      /* rebuild the database */
42 +    if (mode == DBASE_TEMPORARY) {
43 +       fpw = fdopen(fdw, "w+");
44 +       if (fpw == NULL)
45 +               die_with_err("call fdopen() failed.", NULL);
46 +    } else
47      if ((fpw = fopen(database, "w")) == NULL)
48         die_with_err("Hint: Maybe the database directory '%s' doesn't exist?  fopen()", database);
50 @@ -367,10 +373,10 @@ printf("--(contents)-->%s\n", entry); 
51           die_with_err("database_build: list_close() failed!\n", (char *) NULL);
52      }
54 -    /* we don't want to allow anyone to spoof the temporary file in /tmp */
55 +    /* If the database was temporary, the file was unlink()ed, and is
56 +       "hidden" from other processes. */
57      if (mode == DBASE_TEMPORARY) {
58 -       if ((fptempdbase = freopen(database, "r", fpw)) == NULL)
59 -           die_with_err("temporary database file disappeared?!?", database);
60 +       fptempdbase = fpw;
61         rewind(fptempdbase);
62      } else {
63         fclose(fpw);
64 @@ -413,7 +419,7 @@ database_record_write (fpw, filename, fl
65      /* filename, entrynum, ignore, mode, inode, nlinks, uid, gid, size,
66       *         access, modify, ctime, {sig0, sig1, ..., sig9}
67       */
68 -    static char *format = "%s %ld %s %lo %ld %ld %ld %ld %ld %s %s %s %s\n";
69 +    static char *format = "%s %d %s %o %u %u %u %u %lld %s %s %s %s\n";
71      /* initialize our temporary file */
72      if (fdsymlink == -1) {
73 @@ -541,7 +547,7 @@ SKIPPED_SIGS:
74         fprintf(fpw, format, filename_escape(filename), (int32)entrynum, ignorevec,
75             (int32)statbuf->st_mode, (int32)statbuf->st_ino,
76             (int32)statbuf->st_nlink, (int32)statbuf->st_uid,
77 -           (int32)statbuf->st_gid, (int32)statbuf->st_size,
78 +           (int32)statbuf->st_gid, (long long)statbuf->st_size,
79             pltob64((uint32 *) &va, (char *) vec64_a, 1),
80             pltob64((uint32 *) &vm, (char *) vec64_m, 1),
81             pltob64((uint32 *) &vc, (char *) vec64_c, 1),