mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-31 12:09:35 -05:00
ITS#4414: SLP attributes support from Peter Marschall
This commit is contained in:
parent
2f04f61dc7
commit
153e81817f
4 changed files with 61 additions and 10 deletions
|
|
@ -13,6 +13,7 @@ slapd \- Stand-alone LDAP Daemon
|
|||
.B [\-F slapd\-config\-directory]
|
||||
.B [\-h URLs]
|
||||
.B [\-n service\-name] [\-s syslog\-level] [\-l syslog\-local\-user]
|
||||
.B [\-o option[=value]]
|
||||
.B [\-r directory]
|
||||
.B [\-u user] [\-g group]
|
||||
.B [\-c cookie]
|
||||
|
|
@ -236,6 +237,30 @@ must be provided in order for any other specified values to be used.
|
|||
is the commit sequence number received by a previous synchronization
|
||||
and represents the state of the consumer replica content which the
|
||||
syncrepl engine will synchronize to the current provider content.
|
||||
.TP
|
||||
.BI \-o " option[=value]"
|
||||
This option provides a generic means to specify options without the need to reserve
|
||||
a separate letter for them.
|
||||
|
||||
It supports the following options:
|
||||
.RS
|
||||
.TP
|
||||
slp={\fBon\fP|\fBoff\fP|\fIslp\-attrs\fP}
|
||||
When SLP support is compiled into slapd, disable it (
|
||||
.B off
|
||||
), enable it by registering at SLP DAs without specific SLP attributes (
|
||||
.B on
|
||||
), or with specific SLP attributes
|
||||
.I slp\-attrs
|
||||
that must be an SLP attribute list definition according to the SLP standard.
|
||||
|
||||
For example, "-o slp=(tree=production),(server-type=OpenLDAP),(server-version=2.3.20)"
|
||||
registers at SLP DAs with the three SLP attributes tree, server-type and server-version
|
||||
that have the values given above.
|
||||
This allows to specifically query the SLP DAs for LDAP servers holding the
|
||||
.I production
|
||||
tree in case multiple trees are availabe.
|
||||
.RE
|
||||
.SH EXAMPLES
|
||||
To start
|
||||
.I slapd
|
||||
|
|
|
|||
|
|
@ -339,9 +339,13 @@ static struct slap_daemon {
|
|||
static char** slapd_srvurls = NULL;
|
||||
static SLPHandle slapd_hslp = 0;
|
||||
int slapd_register_slp = 0;
|
||||
char *slapd_slp_attrs = NULL;
|
||||
|
||||
static SLPError slapd_slp_cookie;
|
||||
|
||||
void slapd_slp_init( const char* urls ) {
|
||||
int i;
|
||||
SLPError err;
|
||||
|
||||
slapd_srvurls = ldap_str2charray( urls, " " );
|
||||
|
||||
|
|
@ -376,7 +380,12 @@ void slapd_slp_init( const char* urls ) {
|
|||
}
|
||||
|
||||
/* open the SLP handle */
|
||||
SLPOpen( "en", 0, &slapd_hslp );
|
||||
err = SLPOpen( "en", 0, &slapd_hslp );
|
||||
|
||||
if (err != SLP_OK) {
|
||||
Debug( LDAP_DEBUG_CONNS, "daemon: SLPOpen() failed with %ld\n",
|
||||
(long)err, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void slapd_slp_deinit() {
|
||||
|
|
@ -394,11 +403,13 @@ void slapd_slp_regreport(
|
|||
SLPError errcode,
|
||||
void* cookie )
|
||||
{
|
||||
/* empty report */
|
||||
/* return the error code in the cookie */
|
||||
*(SLPError*)cookie = errcode;
|
||||
}
|
||||
|
||||
void slapd_slp_reg() {
|
||||
int i;
|
||||
SLPError err;
|
||||
|
||||
if( slapd_srvurls == NULL ) return;
|
||||
|
||||
|
|
@ -408,28 +419,41 @@ void slapd_slp_reg() {
|
|||
strncmp( slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX,
|
||||
sizeof( LDAPS_SRVTYPE_PREFIX ) - 1 ) == 0 )
|
||||
{
|
||||
SLPReg( slapd_hslp,
|
||||
err = SLPReg( slapd_hslp,
|
||||
slapd_srvurls[i],
|
||||
SLP_LIFETIME_MAXIMUM,
|
||||
"ldap",
|
||||
"",
|
||||
1,
|
||||
(slapd_slp_attrs) ? slapd_slp_attrs : "",
|
||||
SLP_TRUE,
|
||||
slapd_slp_regreport,
|
||||
NULL );
|
||||
&slapd_slp_cookie );
|
||||
|
||||
if (err != SLP_OK || slapd_slp_cookie != SLP_OK) {
|
||||
Debug( LDAP_DEBUG_CONNS,
|
||||
"daemon: SLPReg(%s) failed with %ld, cookie = %ld\n",
|
||||
slapd_srvurls[i], (long)err, (long)slapd_slp_cookie );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void slapd_slp_dereg() {
|
||||
int i;
|
||||
SLPError err;
|
||||
|
||||
if( slapd_srvurls == NULL ) return;
|
||||
|
||||
for( i=0; slapd_srvurls[i] != NULL; i++ ) {
|
||||
SLPDereg( slapd_hslp,
|
||||
err = SLPDereg( slapd_hslp,
|
||||
slapd_srvurls[i],
|
||||
slapd_slp_regreport,
|
||||
NULL );
|
||||
&slapd_slp_cookie );
|
||||
|
||||
if (err != SLP_OK || slapd_slp_cookie != SLP_OK) {
|
||||
Debug( LDAP_DEBUG_CONNS,
|
||||
"daemon: SLPDereg(%s) failed with %ld, cookie = %ld\n",
|
||||
slapd_srvurls[i], (long)err, (long)slapd_slp_cookie );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_SLP */
|
||||
|
|
|
|||
|
|
@ -115,8 +115,9 @@ slapd_opt_slp( const char *val, void *arg )
|
|||
{
|
||||
#ifdef HAVE_SLP
|
||||
/* NULL is default */
|
||||
if ( val == NULL || strcasecmp( val, "on" ) == 0 ) {
|
||||
if ( val == NULL || *val == '(' || strcasecmp( val, "on" ) == 0 ) {
|
||||
slapd_register_slp = 1;
|
||||
slapd_slp_attrs = (val != NULL && *val == '(') ? val : NULL;
|
||||
|
||||
} else if ( strcasecmp( val, "off" ) == 0 ) {
|
||||
slapd_register_slp = 0;
|
||||
|
|
@ -155,7 +156,7 @@ struct option_helper {
|
|||
void *oh_arg;
|
||||
const char *oh_usage;
|
||||
} option_helpers[] = {
|
||||
{ BER_BVC("slp"), slapd_opt_slp, NULL, "slp[={on|off}] enable/disable SLP" },
|
||||
{ BER_BVC("slp"), slapd_opt_slp, NULL, "slp[={on|off|(attrs)}] enable/disable SLP using (attrs)" },
|
||||
{ BER_BVNULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -727,6 +727,7 @@ LDAP_SLAPD_F (int) slapd_clr_read LDAP_P((ber_socket_t s, int wake));
|
|||
LDAP_SLAPD_V (volatile sig_atomic_t) slapd_abrupt_shutdown;
|
||||
LDAP_SLAPD_V (volatile sig_atomic_t) slapd_shutdown;
|
||||
LDAP_SLAPD_V (int) slapd_register_slp;
|
||||
LDAP_SLAPD_V (char *) slapd_slp_attrs;
|
||||
LDAP_SLAPD_V (slap_ssf_t) local_ssf;
|
||||
LDAP_SLAPD_V (struct runqueue_s) slapd_rq;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue