From 3b84f11d259fa3266c9af3185452940d1462bc8f Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Mon, 31 Jan 2005 00:15:45 +0000 Subject: [PATCH] honor SLAP_GLUE_INSTANCE() flag; allow to advertize subordinate databases --- doc/man/man5/slapo-glue.5 | 8 +++++--- servers/slapd/back-dnssrv/referral.c | 3 --- servers/slapd/back-dnssrv/search.c | 8 +++----- servers/slapd/overlays/glue.c | 24 +++++++++++++++++------- servers/slapd/root_dse.c | 2 +- servers/slapd/slap.h | 7 +++++-- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/doc/man/man5/slapo-glue.5 b/doc/man/man5/slapo-glue.5 index 4d106695da..9e8524518c 100644 --- a/doc/man/man5/slapo-glue.5 +++ b/doc/man/man5/slapo-glue.5 @@ -30,11 +30,13 @@ directive and before any subsequent .B database directive. .TP -.B glue-sub [async] +.B glue-sub [async] [advertize] Specify the suffix of a database to attach as a subordinate to the root database. The specified database must have already been configured. If the -optional "async" keyword is supplied, searches against this database may -be spawned in a separate thread to run concurrently with other operations. +optional \fBasync\fP keyword is supplied, searches against this database may +be spawned in a separate thread to run concurrently with other operations +(currently not implemented). If the optional \fBadvertize\fI flag +is supplied, the naming context is advertized in the rootDSE. .SH FILES .TP ETCDIR/slapd.conf diff --git a/servers/slapd/back-dnssrv/referral.c b/servers/slapd/back-dnssrv/referral.c index 2a95d94a8c..77cd3fcc3f 100644 --- a/servers/slapd/back-dnssrv/referral.c +++ b/servers/slapd/back-dnssrv/referral.c @@ -43,14 +43,11 @@ dnssrv_back_referrals( if ( BER_BVISEMPTY( &op->o_req_dn ) ) { #ifdef LDAP_DEVEL -#if 0 /* FIXME: need some means to determine whether the database * is a glue instance */ if ( SLAP_GLUE_INSTANCE( op->o_bd ) ) { return LDAP_SUCCESS; } -#endif - return LDAP_SUCCESS; #endif /* LDAP_DEVEL */ rs->sr_text = "DNS SRV operation upon null (empty) DN disallowed"; diff --git a/servers/slapd/back-dnssrv/search.c b/servers/slapd/back-dnssrv/search.c index 521162889a..26fc1a32cd 100644 --- a/servers/slapd/back-dnssrv/search.c +++ b/servers/slapd/back-dnssrv/search.c @@ -49,16 +49,14 @@ dnssrv_back_search( if ( BER_BVISEMPTY( &op->o_req_ndn ) ) { #ifdef LDAP_DEVEL -#if 0 /* FIXME: need some means to determine whether the database * is a glue instance; if we got here with empty DN, then * we passed this same test in dnssrv_back_referrals() */ if ( !SLAP_GLUE_INSTANCE( op->o_bd ) ) { rs->sr_err = LDAP_UNWILLING_TO_PERFORM; - rs->sr_err = "DNS SRV operation upon null (empty) DN disallowed"; - } else -#endif - { + rs->sr_text = "DNS SRV operation upon null (empty) DN disallowed"; + + } else { rs->sr_err = LDAP_SUCCESS; } goto done; diff --git a/servers/slapd/overlays/glue.c b/servers/slapd/overlays/glue.c index 03c7a306c6..43802abbd5 100644 --- a/servers/slapd/overlays/glue.c +++ b/servers/slapd/overlays/glue.c @@ -761,23 +761,30 @@ glue_db_config( slap_overinst *on = (slap_overinst *)be->bd_info; glueinfo *gi = (glueinfo *)on->on_bi.bi_private; + /* redundant; could be applied just once */ + SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE; + if ( strcasecmp( argv[0], "glue-sub" ) == 0 ) { - int async = 0; + int i, async = 0, advertize = 0; BackendDB *b2; struct berval bv, dn; gluenode *gn; if ( argc < 2 ) { fprintf( stderr, "%s: line %d: too few arguments in " - "\"glue-sub [async]\"\n", fname, lineno ); + "\"glue-sub [async] [advertize]\"\n", fname, lineno ); return -1; } - if ( argc == 3 ) { - if ( strcasecmp( argv[2], "async" )) { - fprintf( stderr, "%s: line %d: unrecognized option " - "\"%s\" ignored.\n", fname, lineno, argv[2] ); - } else { + for ( i = 2; i < argc; i++ ) { + if ( strcasecmp( argv[i], "async" ) == 0 ) { async = 1; + + } else if ( strcasecmp( argv[i], "advertize" ) == 0 ) { + advertize = 1; + + } else { + fprintf( stderr, "%s: line %d: unrecognized option " + "\"%s\" ignored.\n", fname, lineno, argv[i] ); } } ber_str2bv( argv[1], 0, 0, &bv ); @@ -792,6 +799,9 @@ glue_db_config( return -1; } SLAP_DBFLAGS(b2) |= SLAP_DBFLAG_GLUE_SUBORDINATE; + if ( advertize ) { + SLAP_DBFLAGS(b2) |= SLAP_DBFLAG_GLUE_ADVERTIZE; + } gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) + gi->gi_nodes * sizeof(gluenode)); gi->gi_n[gi->gi_nodes].gn_bx = b2 - backendDB; diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 46e77968ce..ce68caa191 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -128,7 +128,7 @@ root_dse_info( } continue; } - if ( SLAP_GLUE_SUBORDINATE( &backends[i] ) ) { + if ( SLAP_GLUE_SUBORDINATE( &backends[i] ) && !SLAP_GLUE_ADVERTIZE( &backends[i] ) ) { continue; } for ( j = 0; backends[i].be_suffix[j].bv_val != NULL; j++ ) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 34cbec20a6..1193b875d1 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1597,8 +1597,9 @@ struct slap_backend_db { #define SLAP_DBFLAG_GLUE_INSTANCE 0x0010U /* a glue backend */ #define SLAP_DBFLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */ #define SLAP_DBFLAG_GLUE_LINKED 0x0040U /* child is connected to parent */ -#define SLAP_DBFLAG_OVERLAY 0x0080U /* this db struct is an overlay */ -#define SLAP_DBFLAG_GLOBAL_OVERLAY 0x0100U /* this db struct is a global overlay */ +#define SLAP_DBFLAG_GLUE_ADVERTIZE 0x0080U /* advertize in rootDSE */ +#define SLAP_DBFLAG_OVERLAY 0x0100U /* this db struct is an overlay */ +#define SLAP_DBFLAG_GLOBAL_OVERLAY 0x0200U /* this db struct is a global overlay */ #define SLAP_DBFLAG_SHADOW 0x8000U /* a shadow */ #define SLAP_DBFLAG_SYNC_SHADOW 0x1000U /* a sync shadow */ #define SLAP_DBFLAG_SLURP_SHADOW 0x2000U /* a slurp shadow */ @@ -1615,6 +1616,8 @@ struct slap_backend_db { (SLAP_DBFLAGS(be) & SLAP_DBFLAG_GLUE_SUBORDINATE) #define SLAP_GLUE_LINKED(be) \ (SLAP_DBFLAGS(be) & SLAP_DBFLAG_GLUE_LINKED) +#define SLAP_GLUE_ADVERTIZE(be) \ + (SLAP_DBFLAGS(be) & SLAP_DBFLAG_GLUE_ADVERTIZE) #define SLAP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SHADOW) #define SLAP_SYNC_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SYNC_SHADOW) #define SLAP_SLURP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SLURP_SHADOW) -- 2.39.5