Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/usr.bin/cap_mkdb Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/5c860db88a32
branches:  netbsd-3
changeset: 577468:5c860db88a32
user:      tron <tron%NetBSD.org@localhost>
date:      Wed Nov 09 11:12:56 2005 +0000

description:
Pull up following revision(s) (requested by christos in ticket #943):
        usr.bin/cap_mkdb/cap_mkdb.c: revision 1.22
Write the database file into a temporary file first, because otherwise if
we don't specify an output filename, the database file we create will end
up being used during population as the database file to find entries quickly.

diffstat:

 usr.bin/cap_mkdb/cap_mkdb.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (39 lines):

diff -r 43f559efc05e -r 5c860db88a32 usr.bin/cap_mkdb/cap_mkdb.c
--- a/usr.bin/cap_mkdb/cap_mkdb.c       Tue Nov 08 18:20:13 2005 +0000
+++ b/usr.bin/cap_mkdb/cap_mkdb.c       Wed Nov 09 11:12:56 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cap_mkdb.c,v 1.21 2004/04/23 21:39:33 christos Exp $   */
+/*     $NetBSD: cap_mkdb.c,v 1.21.2.1 2005/11/09 11:12:56 tron Exp $   */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95";
 #endif
-__RCSID("$NetBSD: cap_mkdb.c,v 1.21 2004/04/23 21:39:33 christos Exp $");
+__RCSID("$NetBSD: cap_mkdb.c,v 1.21.2.1 2005/11/09 11:12:56 tron Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -124,7 +124,8 @@
         * The database file is the first argument if no name is specified.
         * Make arrangements to unlink it if exit badly.
         */
-       (void)snprintf(buf, sizeof(buf), "%s.db", capname ? capname : *argv);
+       (void)snprintf(buf, sizeof(buf), "%s.db.tmp",
+           capname ? capname : *argv);
        if ((capname = strdup(buf)) == NULL)
                err(1, "strdup");
        if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR,
@@ -138,6 +139,10 @@
 
        if (capdbp->close(capdbp) < 0)
                err(1, "%s", capname);
+       *strrchr(buf, '.') = '\0';
+       if (rename(capname, buf) == -1)
+               err(1, "rename");
+       free(capname);
        capname = NULL;
        return 0;
 }



Home | Main Index | Thread Index | Old Index