pkgsrc/security/tripwire/patches/patch-af
rillig b71a1d488b Fixed pkglint warnings. The warnings are mostly quoting issues, for
example MAKE_ENV+=FOO=${BAR} is changed to MAKE_ENV+=FOO=${BAR:Q}. Some
other changes are outlined in

    http://mail-index.netbsd.org/tech-pkg/2005/12/02/0034.html
2005-12-05 20:49:47 +00:00

81 lines
3 KiB
Text

$NetBSD: patch-af,v 1.3 2005/12/05 20:50:58 rillig Exp $
--- src/dbase.build.c.orig 1994-07-25 08:24:09.000000000 -0700
+++ src/dbase.build.c
@@ -66,7 +66,6 @@
int files_scanned_num = 0;
/* prototypes */
-char *mktemp();
static void database_record_write();
char backupfile[MAXPATHLEN+256];
@@ -92,6 +91,7 @@ database_build (pp_list, mode, pp_entry_
{
struct list_elem *p_fileentry;
struct list_elem *p_configentry;
+ int fdw;
FILE *fpw;
char database[MAXPATHLEN+256];
int entrynum,
@@ -130,11 +130,12 @@ database_build (pp_list, mode, pp_entry_
die_with_err("malloc() failed in database_build", (char *) NULL);
(void) strcpy(tmpfilename, TEMPFILE_TEMPLATE);
- if ((char *) mktemp(tmpfilename) == NULL)
- die_with_err("database_build: mktemp()", (char *) NULL);
+ fdw = mkstemp(tmpfilename);
+ if (fdw == -1)
+ die_with_err("database_build: mkstemp()", (char *) NULL);
+ unlink(tmpfilename);
- (void) strcpy(tempdatabase_file, tmpfilename);
- (void) strcpy(database, tempdatabase_file);
+ (void) strcpy(database, tmpfilename);
free(tmpfilename);
} /* end if temporary database */
else if (mode == DBASE_UPDATE) {
@@ -224,6 +225,11 @@ printf("database_build(): ---> olddataba
}
/* rebuild the database */
+ if (mode == DBASE_TEMPORARY) {
+ fpw = fdopen(fdw, "w+");
+ if (fpw == NULL)
+ die_with_err("call fdopen() failed.", NULL);
+ } else
if ((fpw = fopen(database, "w")) == NULL)
die_with_err("Hint: Maybe the database directory '%s' doesn't exist? fopen()", database);
@@ -367,10 +373,10 @@ printf("--(contents)-->%s\n", entry);
die_with_err("database_build: list_close() failed!\n", (char *) NULL);
}
- /* we don't want to allow anyone to spoof the temporary file in /tmp */
+ /* If the database was temporary, the file was unlink()ed, and is
+ "hidden" from other processes. */
if (mode == DBASE_TEMPORARY) {
- if ((fptempdbase = freopen(database, "r", fpw)) == NULL)
- die_with_err("temporary database file disappeared?!?", database);
+ fptempdbase = fpw;
rewind(fptempdbase);
} else {
fclose(fpw);
@@ -413,7 +419,7 @@ database_record_write (fpw, filename, fl
/* filename, entrynum, ignore, mode, inode, nlinks, uid, gid, size,
* access, modify, ctime, {sig0, sig1, ..., sig9}
*/
- static char *format = "%s %ld %s %lo %ld %ld %ld %ld %ld %s %s %s %s\n";
+ static char *format = "%s %d %s %o %u %u %u %u %lld %s %s %s %s\n";
/* initialize our temporary file */
if (fdsymlink == -1) {
@@ -541,7 +547,7 @@ SKIPPED_SIGS:
fprintf(fpw, format, filename_escape(filename), (int32)entrynum, ignorevec,
(int32)statbuf->st_mode, (int32)statbuf->st_ino,
(int32)statbuf->st_nlink, (int32)statbuf->st_uid,
- (int32)statbuf->st_gid, (int32)statbuf->st_size,
+ (int32)statbuf->st_gid, (long long)statbuf->st_size,
pltob64((uint32 *) &va, (char *) vec64_a, 1),
pltob64((uint32 *) &vm, (char *) vec64_m, 1),
pltob64((uint32 *) &vc, (char *) vec64_c, 1),