version 1.2, 2007/09/07 10:20:24
|
version 1.3, 2007/12/24 04:18:26
|
Line 1
|
Line 1
|
/* config.c - sock backend configuration file routine */ |
/* config.c - sock backend configuration file routine */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/back-sock/config.c,v 1.1 2007/09/07 10:04:55 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/back-sock/config.c,v 1.2 2007/09/07 10:20:24 hyc Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2007 The OpenLDAP Foundation. |
* Copyright 2007 The OpenLDAP Foundation. |
Line 15
|
Line 15
|
*/ |
*/ |
/* ACKNOWLEDGEMENTS: |
/* ACKNOWLEDGEMENTS: |
* This work was initially developed by Brian Candler for inclusion |
* This work was initially developed by Brian Candler for inclusion |
* in OpenLDAP Software. |
* in OpenLDAP Software. Dynamic config support by Howard Chu. |
*/ |
*/ |
|
|
#include "portable.h" |
#include "portable.h" |
Line 26
|
Line 26
|
#include <ac/socket.h> |
#include <ac/socket.h> |
|
|
#include "slap.h" |
#include "slap.h" |
|
#include "config.h" |
#include "back-sock.h" |
#include "back-sock.h" |
|
|
int |
static ConfigDriver bs_cf_gen; |
sock_back_db_config( |
|
BackendDB *be, |
|
const char *fname, |
|
int lineno, |
|
int argc, |
|
char **argv |
|
) |
|
{ |
|
struct sockinfo *si = (struct sockinfo *) be->be_private; |
|
|
|
if ( si == NULL ) { |
enum { |
fprintf( stderr, "%s: line %d: sock backend info is null!\n", |
BS_EXT = 1 |
fname, lineno ); |
}; |
return( 1 ); |
|
} |
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 } |
|
}; |
|
|
/* socketpath */ |
static int |
if ( strcasecmp( argv[0], "socketpath" ) == 0 ) { |
bs_cf_gen( ConfigArgs *c ) |
if ( argc != 2 ) { |
{ |
fprintf( stderr, |
struct sockinfo *si = c->be->be_private; |
"%s: line %d: exactly one parameter needed for \"socketpath\"\n", |
int rc; |
fname, lineno ); |
|
return( 1 ); |
|
} |
|
si->si_sockpath = ch_strdup( argv[1] ); |
|
|
|
/* extensions */ |
if ( c->op == SLAP_CONFIG_EMIT ) { |
} else if ( strcasecmp( argv[0], "extensions" ) == 0 ) { |
switch( c->type ) { |
int i; |
case BS_EXT: |
for ( i=1; i<argc; i++ ) { |
return mask_to_verbs( bs_exts, si->si_extensions, &c->rvalue_vals ); |
if ( strcasecmp( argv[i], "binddn" ) == 0 ) |
} |
si->si_extensions |= SOCK_EXT_BINDDN; |
} else if ( c->op == LDAP_MOD_DELETE ) { |
else if ( strcasecmp( argv[i], "peername" ) == 0 ) |
switch( c->type ) { |
si->si_extensions |= SOCK_EXT_PEERNAME; |
case BS_EXT: |
else if ( strcasecmp( argv[i], "ssf" ) == 0 ) |
if ( c->valx < 0 ) { |
si->si_extensions |= SOCK_EXT_SSF; |
si->si_extensions = 0; |
else { |
} else { |
fprintf( stderr, |
|
"%s: line %d: unknown extension \"%s\"\n", |
|
fname, lineno, argv[i] ); |
|
return( 1 ); |
|
} |
} |
|
return mask_to_verbs( bs_exts, si->si_extensions, &c->rvalue_vals ); |
} |
} |
|
|
/* anything else */ |
|
} else { |
} else { |
return SLAP_CONF_UNKNOWN; |
switch( c->type ) { |
|
case BS_EXT: |
|
return verbs_to_mask( c->argc, c->argv, bs_exts, &si->si_extensions ); |
|
} |
} |
} |
|
return 1; |
|
} |
|
|
|
int |
|
sock_back_init_cf( BackendInfo *bi ) |
|
{ |
|
bi->bi_cf_ocs = bsocs; |
|
|
return 0; |
return config_register_schema( bscfg, bsocs ); |
} |
} |