Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / openldap / dist / servers / slapd / back-sock / config.c
blob79889b357052e3a684046d2e40eac8ff531d8e6e
1 /* config.c - sock backend configuration file routine */
2 /* $OpenLDAP: pkg/ldap/servers/slapd/back-sock/config.c,v 1.5.2.1 2008/02/09 00:46:09 quanah Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2007-2008 The OpenLDAP Foundation.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
10 * Public License.
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* ACKNOWLEDGEMENTS:
17 * This work was initially developed by Brian Candler for inclusion
18 * in OpenLDAP Software. Dynamic config support by Howard Chu.
21 #include "portable.h"
23 #include <stdio.h>
25 #include <ac/string.h>
26 #include <ac/socket.h>
28 #include "slap.h"
29 #include "config.h"
30 #include "back-sock.h"
32 static ConfigDriver bs_cf_gen;
34 enum {
35 BS_EXT = 1
38 static ConfigTable bscfg[] = {
39 { "socketpath", "pathname", 2, 2, 0, ARG_STRING|ARG_OFFSET,
40 (void *)offsetof(struct sockinfo, si_sockpath),
41 "( OLcfgDbAt:7.1 NAME 'olcDbSocketPath' "
42 "DESC 'Pathname for Unix domain socket' "
43 "EQUALITY caseExactMatch "
44 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
45 { "extensions", "ext", 2, 0, 0, ARG_MAGIC|BS_EXT,
46 bs_cf_gen, "( OLcfgDbAt:7.2 NAME 'olcDbSocketExtensions' "
47 "DESC 'binddn, peername, or ssf' "
48 "EQUALITY caseIgnoreMatch "
49 "SYNTAX OMsDirectoryString )", NULL, NULL },
50 { NULL, NULL }
53 static ConfigOCs bsocs[] = {
54 { "( OLcfgDbOc:7.1 "
55 "NAME 'olcDbSocketConfig' "
56 "DESC 'Socket backend configuration' "
57 "SUP olcDatabaseConfig "
58 "MUST olcDbSocketPath "
59 "MAY olcDbSocketExtensions )",
60 Cft_Database, bscfg },
61 { NULL, 0, NULL }
64 static slap_verbmasks bs_exts[] = {
65 { BER_BVC("binddn"), SOCK_EXT_BINDDN },
66 { BER_BVC("peername"), SOCK_EXT_PEERNAME },
67 { BER_BVC("ssf"), SOCK_EXT_SSF },
68 { BER_BVNULL, 0 }
71 static int
72 bs_cf_gen( ConfigArgs *c )
74 struct sockinfo *si = c->be->be_private;
75 int rc;
77 if ( c->op == SLAP_CONFIG_EMIT ) {
78 switch( c->type ) {
79 case BS_EXT:
80 return mask_to_verbs( bs_exts, si->si_extensions, &c->rvalue_vals );
82 } else if ( c->op == LDAP_MOD_DELETE ) {
83 switch( c->type ) {
84 case BS_EXT:
85 if ( c->valx < 0 ) {
86 si->si_extensions = 0;
87 rc = 0;
88 } else {
89 slap_mask_t dels = 0;
90 rc = verbs_to_mask( c->argc, c->argv, bs_exts, &dels );
91 if ( rc == 0 )
92 si->si_extensions ^= dels;
94 return rc;
97 } else {
98 switch( c->type ) {
99 case BS_EXT:
100 return verbs_to_mask( c->argc, c->argv, bs_exts, &si->si_extensions );
103 return 1;
107 sock_back_init_cf( BackendInfo *bi )
109 bi->bi_cf_ocs = bsocs;
111 return config_register_schema( bscfg, bsocs );