summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getcap.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2001-06-18 18:11:12 +0000
committermillert <millert@openbsd.org>2001-06-18 18:11:12 +0000
commit9fcb004c764af8db0c7100d692ccdec12a8e89e3 (patch)
tree50d2c4935c532cb6fdf946371026a87eb07eae91 /lib/libc/gen/getcap.c
parentcompile libc with -Werror since any warnings gcc produces without extra -Wfoo directives is something we care about (diff)
downloadwireguard-openbsd-9fcb004c764af8db0c7100d692ccdec12a8e89e3.tar.xz
wireguard-openbsd-9fcb004c764af8db0c7100d692ccdec12a8e89e3.zip
Add new cgetusedb() function to toggle reading of .db files in getcap(3).
Needed for cap_mkdb to really DRT when given several input files or an output file with a different name from the input file. cvs: ----------------------------------------------------------------------
Diffstat (limited to 'lib/libc/gen/getcap.c')
-rw-r--r--lib/libc/gen/getcap.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index 6cb1ef49370..dbefdb883cc 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getcap.c,v 1.17 2000/11/22 19:12:57 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: getcap.c,v 1.18 2001/06/18 18:11:14 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -68,6 +68,23 @@ static int cdbget __P((DB *, char **, const char *));
static int getent __P((char **, u_int *, char **, int, const char *, int, char *));
static int nfcmp __P((const char *, char *));
+static int usedb = 1;
+
+/*
+ * Cgetusedb() allows the user to specify whether or not to use a .db
+ * version of the database file (if it exists) in preference to the
+ * text version. By default, the getcap(3) routines will use a .db file.
+ */
+int
+cgetusedb(new_usedb)
+ int new_usedb;
+{
+ int old_usedb = usedb;
+
+ usedb = new_usedb;
+ return(old_usedb);
+}
+
/*
* Cgetset() allows the addition of a user specified buffer to be added
* to the database array, in effect "pushing" the buffer on top of the
@@ -253,9 +270,10 @@ getent(cap, len, db_array, fd, name, depth, nfield)
opened++;
} else {
char *dbrecord;
+
(void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p);
- if ((capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0))
- != NULL) {
+ if (usedb &&
+ (capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0))) {
opened++;
retval = cdbget(capdbp, &dbrecord, name);
if (retval < 0) {