summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/stdlib.h3
-rw-r--r--lib/libc/gen/getcap.326
-rw-r--r--lib/libc/gen/getcap.c24
-rw-r--r--lib/libc/shlib_version2
-rw-r--r--lib/libc_r/shlib_version2
5 files changed, 49 insertions, 8 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index 51f8a267608..63f491e313f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stdlib.h,v 1.12 2000/04/03 23:23:48 millert Exp $ */
+/* $OpenBSD: stdlib.h,v 1.13 2001/06/18 18:11:12 millert Exp $ */
/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
/*-
@@ -144,6 +144,7 @@ int cgetmatch __P((char *, const char *));
int cgetnext __P((char **, char **));
int cgetnum __P((char *, const char *, long *));
int cgetset __P((const char *));
+int cgetusedb __P((int));
int cgetstr __P((char *, const char *, char **));
int cgetustr __P((char *, const char *, char **));
diff --git a/lib/libc/gen/getcap.3 b/lib/libc/gen/getcap.3
index 75a1af6269d..07b31baf59b 100644
--- a/lib/libc/gen/getcap.3
+++ b/lib/libc/gen/getcap.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: getcap.3,v 1.20 2000/12/24 00:30:47 aaron Exp $
+.\" $OpenBSD: getcap.3,v 1.21 2001/06/18 18:11:14 millert Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -47,7 +47,8 @@
.Nm cgetustr ,
.Nm cgetfirst ,
.Nm cgetnext ,
-.Nm cgetclose
+.Nm cgetclose ,
+.Nm cgetusedb
.Nd capability database access routines
.Sh SYNOPSIS
.Fd #include <stdlib.h>
@@ -71,6 +72,8 @@
.Fn cgetnext "char **buf" "char **db_array"
.Ft int
.Fn cgetclose "void"
+.Ft int
+.Fn cgetusedb "int usedb"
.Sh DESCRIPTION
The
.Fn cgetent
@@ -256,6 +259,25 @@ closes the sequential access and frees any memory and file descriptors
being used.
Note that it does not erase the buffer pushed by a call to
.Fn cgetset .
+.Pp
+.Fn cgetusedb
+allows the user to specify whether use or ignore database files ending in
+.Dq .db .
+If
+.Ar usedb
+is zero, files ending in
+.Dq .db
+will be ignored.
+If
+.Ar usedb
+is non-zero, files ending in
+.Dq .db
+will be used in preference to the text version.
+The default is to process
+.Dq .db
+files.
+.Fn cgetusedb
+returns the previous setting.
.Ss Capability database syntax
Capability databases are normally
.Tn ASCII
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) {
diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version
index 54ef0c4cc0c..72e5894f74e 100644
--- a/lib/libc/shlib_version
+++ b/lib/libc/shlib_version
@@ -1,2 +1,2 @@
major=27
-minor=0
+minor=1
diff --git a/lib/libc_r/shlib_version b/lib/libc_r/shlib_version
index 3066b9771e7..900b4048a96 100644
--- a/lib/libc_r/shlib_version
+++ b/lib/libc_r/shlib_version
@@ -1,2 +1,2 @@
major=5
-minor=0
+minor=1