openldap/servers/slapd/back-sock/config.c

113 lines
2.7 KiB
C
Raw Normal View History

/* config.c - sock backend configuration file routine */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
2008-01-08 08:19:56 +08:00
* Copyright 2007-2008 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
2007-09-07 20:20:24 +08:00
/* ACKNOWLEDGEMENTS:
* This work was initially developed by Brian Candler for inclusion
2007-12-24 13:18:25 +08:00
* in OpenLDAP Software. Dynamic config support by Howard Chu.
2007-09-07 20:20:24 +08:00
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
2007-12-24 13:18:25 +08:00
#include "config.h"
#include "back-sock.h"
2007-12-24 13:18:25 +08:00
static ConfigDriver bs_cf_gen;
2007-12-24 13:18:25 +08:00
enum {
BS_EXT = 1
};
2007-12-24 13:18:25 +08:00
static ConfigTable bscfg[] = {
{ "socketpath", "pathname", 2, 2, 0, ARG_STRING|ARG_OFFSET,
(void *)offsetof(struct sockinfo, si_sockpath),
"( OLcfgDbAt:7.1 NAME 'olcDbSocketPath' "
"DESC 'Pathname for Unix domain socket' "
"EQUALITY caseExactMatch "
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ "extensions", "ext", 2, 0, 0, ARG_MAGIC|BS_EXT,
bs_cf_gen, "( OLcfgDbAt:7.2 NAME 'olcDbSocketExtensions' "
"DESC 'binddn, peername, or ssf' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString )", NULL, NULL },
{ NULL, NULL }
};
static ConfigOCs bsocs[] = {
{ "( OLcfgDbOc:7.1 "
"NAME 'olcDbSocketConfig' "
"DESC 'Socket backend configuration' "
"SUP olcDatabaseConfig "
"MUST olcDbSocketPath "
"MAY olcDbSocketExtensions )",
Cft_Database, bscfg },
{ NULL, 0, NULL }
};
static slap_verbmasks bs_exts[] = {
{ BER_BVC("binddn"), SOCK_EXT_BINDDN },
{ BER_BVC("peername"), SOCK_EXT_PEERNAME },
{ BER_BVC("ssf"), SOCK_EXT_SSF },
{ BER_BVNULL, 0 }
};
static int
bs_cf_gen( ConfigArgs *c )
{
struct sockinfo *si = c->be->be_private;
int rc;
2007-12-24 13:18:25 +08:00
if ( c->op == SLAP_CONFIG_EMIT ) {
switch( c->type ) {
case BS_EXT:
return mask_to_verbs( bs_exts, si->si_extensions, &c->rvalue_vals );
}
} else if ( c->op == LDAP_MOD_DELETE ) {
switch( c->type ) {
case BS_EXT:
if ( c->valx < 0 ) {
si->si_extensions = 0;
2007-12-24 13:32:13 +08:00
rc = 0;
2007-12-24 13:18:25 +08:00
} else {
2007-12-24 13:32:13 +08:00
slap_mask_t dels = 0;
rc = verbs_to_mask( c->argc, c->argv, bs_exts, &dels );
if ( rc == 0 )
si->si_extensions ^= dels;
}
2007-12-24 13:32:13 +08:00
return rc;
}
} else {
2007-12-24 13:18:25 +08:00
switch( c->type ) {
case BS_EXT:
return verbs_to_mask( c->argc, c->argv, bs_exts, &si->si_extensions );
}
}
2007-12-24 13:18:25 +08:00
return 1;
}
int
sock_back_init_cf( BackendInfo *bi )
{
bi->bi_cf_ocs = bsocs;
2007-12-24 13:18:25 +08:00
return config_register_schema( bscfg, bsocs );
}