mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-21 14:25:24 -05:00
Added includeFile objects
This commit is contained in:
parent
39906c96e3
commit
367e4915ab
2 changed files with 113 additions and 62 deletions
|
|
@ -32,7 +32,8 @@ typedef struct CfEntryInfo {
|
|||
struct CfEntryInfo *ce_sibs;
|
||||
struct CfEntryInfo *ce_kids;
|
||||
Entry *ce_entry;
|
||||
ConfigTable *ce_table;
|
||||
BackendInfo *ce_bi;
|
||||
BackendDB *ce_be;
|
||||
} CfEntryInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -86,7 +87,7 @@ static struct oc_info {
|
|||
"NAME 'olcDatabaseConfig' "
|
||||
"DESC 'OpenLDAP Database-specific options' "
|
||||
"SUP olcConfig STRUCTURAL "
|
||||
"MAY ( olcDatabase $ olcAccess $ olcLastMod $ olcLimits $ "
|
||||
"MAY ( olcAccess $ olcDatabase $ olcLastMod $ olcLimits $ "
|
||||
"olcMaxDerefDepth $ olcReadOnly $ olcReplica $ olcReplogFile $ "
|
||||
"olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ olcSchemaDN $ "
|
||||
"olcSecurity $ olcSizeLimit $ olcSuffix $ olcSyncrepl $ "
|
||||
|
|
@ -232,16 +233,21 @@ config_alloc_entry( struct berval *pdn, struct berval *rdn )
|
|||
return e;
|
||||
}
|
||||
|
||||
#define NO_TABLE 0
|
||||
#define BI_TABLE 1
|
||||
#define BE_TABLE 2
|
||||
|
||||
static int
|
||||
config_build_entry( Entry *e, void *private, ObjectClass *oc,
|
||||
struct berval *rdn )
|
||||
config_build_entry( ConfigArgs *c, Entry *e, ObjectClass *oc,
|
||||
struct berval *rdn, ConfigTable *ct, int table )
|
||||
{
|
||||
struct berval vals[2];
|
||||
struct berval ad_name;
|
||||
AttributeDescription *ad = NULL;
|
||||
int rc;
|
||||
int rc, i;
|
||||
char *ptr;
|
||||
const char *text;
|
||||
AttributeType **at;
|
||||
|
||||
BER_BVZERO( &vals[1] );
|
||||
|
||||
|
|
@ -257,9 +263,70 @@ config_build_entry( Entry *e, void *private, ObjectClass *oc,
|
|||
vals[0].bv_val = ptr+1;
|
||||
vals[0].bv_len = rdn->bv_len - (vals[0].bv_val - rdn->bv_val);
|
||||
attr_merge(e, ad, vals, NULL );
|
||||
|
||||
for (at=oc->soc_allowed;*at;at++) {
|
||||
/* Skip the naming attr */
|
||||
if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
|
||||
continue;
|
||||
for (i=0;ct[i].name;i++) {
|
||||
if (ct[i].ad == (*at)->sat_ad)
|
||||
break;
|
||||
}
|
||||
rc = config_get_vals(&ct[i], c);
|
||||
if (rc == LDAP_SUCCESS) {
|
||||
attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
|
||||
}
|
||||
}
|
||||
|
||||
if ( table ) {
|
||||
if ( table == BI_TABLE )
|
||||
ct = c->bi->bi_cf_table;
|
||||
else
|
||||
ct = c->be->be_cf_table;
|
||||
for (;ct && ct->name;ct++) {
|
||||
if (!ct->ad) continue;
|
||||
rc = config_get_vals(ct, c);
|
||||
if (rc == LDAP_SUCCESS) {
|
||||
attr_merge(e, ct->ad, c->rvalue_vals, c->rvalue_nvals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CfEntryInfo *
|
||||
config_build_includes( ConfigArgs *c, Entry *parent )
|
||||
{
|
||||
Entry *e;
|
||||
int i;
|
||||
ConfigFile *cf = (ConfigFile *)c->line;
|
||||
CfEntryInfo *ce, *ceparent, *ceprev;
|
||||
|
||||
ceparent = parent->e_private;
|
||||
|
||||
for (i=0; cf; cf=cf->c_sibs, i++) {
|
||||
c->value_dn.bv_val = c->log;
|
||||
c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=include{%d}", i);
|
||||
e = config_alloc_entry( &parent->e_nname, &c->value_dn );
|
||||
c->line = (char *)cf;
|
||||
config_build_entry( c, e, cfOc_include, &c->value_dn,
|
||||
c->bi->bi_cf_table, NO_TABLE );
|
||||
ce = e->e_private;
|
||||
if ( !ceparent->ce_kids ) {
|
||||
ceparent->ce_kids = ce;
|
||||
} else {
|
||||
ceprev->ce_sibs = ce;
|
||||
}
|
||||
ceprev = ce;
|
||||
if ( cf->c_kids ) {
|
||||
c->line = (char *)cf->c_kids;
|
||||
config_build_includes( c, e );
|
||||
}
|
||||
}
|
||||
return ce;
|
||||
}
|
||||
|
||||
static int
|
||||
config_back_db_open( BackendDB *be )
|
||||
{
|
||||
|
|
@ -267,8 +334,7 @@ config_back_db_open( BackendDB *be )
|
|||
struct berval rdn;
|
||||
Entry *e, *parent;
|
||||
CfEntryInfo *ce, *ceparent, *ceprev;
|
||||
int i, rc, buflen = 0, len;
|
||||
char *buf = NULL;
|
||||
int i, rc;
|
||||
BackendInfo *bi;
|
||||
BackendDB *bptr;
|
||||
ConfigArgs c;
|
||||
|
|
@ -278,44 +344,39 @@ config_back_db_open( BackendDB *be )
|
|||
ber_str2bv( CONFIG_DN, STRLENOF( CONFIG_DN ), 0, &rdn );
|
||||
e = config_alloc_entry( NULL, &rdn );
|
||||
ce = e->e_private;
|
||||
ce->ce_table = be->bd_info->bi_cf_table;
|
||||
cfb->cb_root = ce;
|
||||
|
||||
config_build_entry( e, be->be_private, cfOc_global, &rdn );
|
||||
c.be = be;
|
||||
c.bi = be->bd_info;
|
||||
ct = ce->ce_table;
|
||||
for (ct=ce->ce_table; ct->name; ct++) {
|
||||
if (!ct->ad) continue;
|
||||
if (ct->arg_type & ARG_DB) continue;
|
||||
rc = config_get_vals(ct, &c);
|
||||
if (rc == LDAP_SUCCESS) {
|
||||
attr_merge(e, ct->ad, c.rvalue_vals, c.rvalue_nvals);
|
||||
}
|
||||
}
|
||||
c.line = (char *)cfb->cb_config;
|
||||
ct = c.bi->bi_cf_table;
|
||||
config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
|
||||
|
||||
parent = e;
|
||||
ceparent = ce;
|
||||
|
||||
/* Create includeFile nodes... */
|
||||
if ( cfb->cb_config->c_kids ) {
|
||||
c.line = (char *)cfb->cb_config->c_kids;
|
||||
ceprev = config_build_includes( &c, parent );
|
||||
}
|
||||
|
||||
/* Create backend nodes. Skip if they don't provide a cf_table.
|
||||
* There usually aren't any of these.
|
||||
*/
|
||||
|
||||
c.line = 0;
|
||||
bi = backendInfo;
|
||||
for (i=0; i<nBackendInfo; i++, bi++) {
|
||||
if (!bi->bi_cf_table) continue;
|
||||
if (!bi->bi_private) continue;
|
||||
|
||||
len = cfAd_backend->ad_cname.bv_len + 2 + strlen(bi->bi_type);
|
||||
if ( buflen < len ) {
|
||||
buflen = len;
|
||||
buf = realloc(buf, buflen);
|
||||
}
|
||||
rdn.bv_val = buf;
|
||||
rdn.bv_len = sprintf(buf, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
|
||||
rdn.bv_val = c.log;
|
||||
rdn.bv_len = sprintf(rdn.bv_val, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
|
||||
e = config_alloc_entry( &parent->e_nname, &rdn );
|
||||
ce = e->e_private;
|
||||
ce->ce_table = bi->bi_cf_table;
|
||||
config_build_entry( e, bi->bi_private, cfOc_backend, &rdn );
|
||||
ce->ce_bi = bi;
|
||||
c.bi = bi;
|
||||
config_build_entry( &c, e, cfOc_backend, &rdn, ct, BI_TABLE );
|
||||
if ( !ceparent->ce_kids ) {
|
||||
ceparent->ce_kids = ce;
|
||||
} else {
|
||||
|
|
@ -332,31 +393,16 @@ config_back_db_open( BackendDB *be )
|
|||
bptr = &backendDB[i];
|
||||
}
|
||||
bi = bptr->bd_info;
|
||||
len = cfAd_database->ad_cname.bv_len + STRLENOF("{xxxxxxxx}") +
|
||||
strlen( bi->bi_type ) + 2;
|
||||
if ( buflen < len ) {
|
||||
buflen = len;
|
||||
buf = realloc(buf, buflen);
|
||||
}
|
||||
rdn.bv_val = buf;
|
||||
rdn.bv_len = sprintf(buf, "%s={%0x}%s", cfAd_database->ad_cname.bv_val,
|
||||
rdn.bv_val = c.log;
|
||||
rdn.bv_len = sprintf(rdn.bv_val, "%s={%0x}%s", cfAd_database->ad_cname.bv_val,
|
||||
i, bi->bi_type);
|
||||
e = config_alloc_entry( &parent->e_nname, &rdn );
|
||||
ce = e->e_private;
|
||||
ce->ce_table = bptr->be_cf_table;
|
||||
config_build_entry( e, bptr->be_private, cfOc_database, &rdn );
|
||||
c.be = bptr;
|
||||
c.bi = bi;
|
||||
ct = be->bd_info->bi_cf_table;
|
||||
for (; ct->name; ct++) {
|
||||
if (!ct->ad) continue;
|
||||
if (!(ct->arg_type & (ARG_DB|ARG_MAY_DB))) continue;
|
||||
rc = config_get_vals(ct, &c);
|
||||
if (rc == LDAP_SUCCESS) {
|
||||
attr_merge(e, ct->ad, c.rvalue_vals, c.rvalue_nvals);
|
||||
}
|
||||
}
|
||||
|
||||
ce->ce_be = c.be;
|
||||
ce->ce_bi = c.bi;
|
||||
config_build_entry( &c, e, cfOc_database, &rdn, ct, BE_TABLE );
|
||||
if ( !ceparent->ce_kids ) {
|
||||
ceparent->ce_kids = ce;
|
||||
} else {
|
||||
|
|
@ -364,12 +410,7 @@ config_back_db_open( BackendDB *be )
|
|||
}
|
||||
ceprev = ce;
|
||||
/* Iterate through overlays */
|
||||
|
||||
}
|
||||
/* Create includeFile nodes... */
|
||||
|
||||
|
||||
ch_free( buf );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,6 +193,12 @@ static OidRec OidMacros[] = {
|
|||
/* alphabetical ordering */
|
||||
|
||||
static ConfigTable SystemConfiguration[] = {
|
||||
/* This attr is read-only */
|
||||
{ "", "", 0, 0, 0, ARG_MAGIC|ARG_STRING,
|
||||
&config_fname, "( OLcfgAt:78 NAME 'olcConfigFile' "
|
||||
"DESC 'File for slapd configuration directives' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SYNTAX OMsDirectoryString )", NULL, NULL },
|
||||
{ "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
|
||||
&config_generic, "( OLcfgAt:1 NAME 'olcAccess' "
|
||||
"DESC 'Access Control List' "
|
||||
|
|
@ -539,12 +545,6 @@ static ConfigTable SystemConfiguration[] = {
|
|||
{ "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
|
||||
&config_updateref, "( OLcfgAt:77 NAME 'olcUpdateRef' "
|
||||
"SUP labeledURI )", NULL, NULL },
|
||||
/* This attr is read-only */
|
||||
{ "", "", 0, 0, 0, ARG_MAGIC|ARG_STRING,
|
||||
&config_fname, "( OLcfgAt:78 NAME 'olcConfigFile' "
|
||||
"DESC 'File for slapd configuration directives' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SYNTAX OMsDirectoryString )", NULL, NULL },
|
||||
{ NULL, NULL, 0, 0, 0, ARG_IGNORED,
|
||||
NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
|
@ -711,7 +711,6 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
|
|||
c->rvalue_vals = NULL;
|
||||
c->rvalue_nvals = NULL;
|
||||
c->emit = 1;
|
||||
c->line="";
|
||||
c->type = cf->arg_type & ARGS_USERLAND;
|
||||
|
||||
if ( cf->arg_type & ARG_MAGIC ) {
|
||||
|
|
@ -973,8 +972,14 @@ config_generic(ConfigArgs *c) {
|
|||
case CFG_REPLOG:
|
||||
c->value_string = c->be->be_replogfile;
|
||||
break;
|
||||
case CFG_ROOTDSE:
|
||||
c->rvalue_vals = cfn->c_dseFiles;
|
||||
case CFG_ROOTDSE: {
|
||||
ConfigFile *cf = (ConfigFile *)c->line;
|
||||
if ( cf->c_dseFiles ) {
|
||||
c->rvalue_vals = cf->c_dseFiles;
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CFG_LASTMOD:
|
||||
c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
|
||||
|
|
@ -1229,6 +1234,11 @@ config_generic(ConfigArgs *c) {
|
|||
|
||||
static int
|
||||
config_fname(ConfigArgs *c) {
|
||||
if(c->emit && c->line) {
|
||||
ConfigFile *cf = (ConfigFile *)c->line;
|
||||
c->value_string = cf->c_file.bv_val;
|
||||
return 0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue