add command line option (-S) to enable SLP registration (ITS#3132)

off by default.  Option assignment is temporary, should be replaced
with "-o slp=<ON|off>".
Based upon patch submitted by Ralf Haferkamp (SuSE).
This commit is contained in:
Kurt Zeilenga 2004-05-24 23:28:52 +00:00
parent 5a7f9858fe
commit 6e17b60648
3 changed files with 29 additions and 16 deletions

View File

@ -114,6 +114,7 @@ static struct slap_daemon {
#define LDAPS_SRVTYPE_PREFIX "service:ldaps://"
static char** slapd_srvurls = NULL;
static SLPHandle slapd_hslp = 0;
int slapd_register_slp = 0;
void slapd_slp_init( const char* urls ) {
int i;
@ -1107,8 +1108,10 @@ int slapd_daemon_init( const char *urls )
#endif
#ifdef HAVE_SLP
slapd_slp_init( urls );
slapd_slp_reg();
if( slapd_register_slp ) {
slapd_slp_init( urls );
slapd_slp_reg();
}
#endif
ldap_charray_free( u );
@ -1126,8 +1129,10 @@ slapd_daemon_destroy(void)
sockdestroy();
#ifdef HAVE_SLP
slapd_slp_dereg();
slapd_slp_deinit();
if( slapd_register_slp ) {
slapd_slp_dereg();
slapd_slp_deinit();
}
#endif
return 0;

View File

@ -159,6 +159,9 @@ usage( char *name )
"\t-r directory\tSandbox directory to chroot to\n"
#endif
"\t-s level\tSyslog level\n"
#ifdef HAVE_SLP
"\t-S enable SLP registration\n"
#endif
#if defined(HAVE_SETUID) && defined(HAVE_SETGID)
"\t-u user\t\tUser (id or name) to run as\n"
"\t-V\t\tprint version info (-VV only)\n"
@ -237,8 +240,7 @@ int main( int argc, char **argv )
}
i = (int*)lutil_getRegParam( regService, "DebugLevel" );
if ( i != NULL )
{
if ( i != NULL ) {
slap_debug = *i;
#ifdef NEW_LOGGING
lutil_log_initialize( argc, argv );
@ -246,13 +248,13 @@ int main( int argc, char **argv )
"main: new debug level from registry is: %d\n",
slap_debug, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY, "new debug level from registry is: %d\n", slap_debug, 0, 0 );
Debug( LDAP_DEBUG_ANY,
"new debug level from registry is: %d\n", slap_debug, 0, 0 );
#endif
}
newUrls = (char *) lutil_getRegParam(regService, "Urls");
if (newUrls)
{
if (newUrls) {
if (urls)
ch_free(urls);
@ -262,14 +264,12 @@ int main( int argc, char **argv )
"main: new urls from registry: %s\n", urls, 0, 0 );
#else
Debug(LDAP_DEBUG_ANY, "new urls from registry: %s\n",
urls, 0, 0);
urls, 0, 0);
#endif
}
newConfigFile = (char*)lutil_getRegParam( regService, "ConfigFile" );
if ( newConfigFile != NULL )
{
if ( newConfigFile != NULL ) {
configfile = newConfigFile;
#ifdef NEW_LOGGING
LDAP_LOG( SLAPD, INFO,
@ -277,13 +277,12 @@ int main( int argc, char **argv )
#else
Debug ( LDAP_DEBUG_ANY, "new config file from registry is: %s\n", configfile, 0, 0 );
#endif
}
}
#endif
while ( (i = getopt( argc, argv,
"c:d:f:h:s:n:tT:V"
"c:d:f:h:s:n:StT:V"
#if LDAP_PF_INET6
"46"
#endif
@ -356,10 +355,18 @@ int main( int argc, char **argv )
ldap_syslog = atoi( optarg );
break;
case 'S': /* enable SLP */
#ifdef HAVE_SLP
slapd_register_slp++;
#else
fputs( "slapd: SLP support is not available\n", stderr );
#endif
break;
#ifdef LOG_LOCAL4
case 'l': /* set syslog local user */
syslogUser = cnvt_str2int( optarg,
syslog_types, DEFAULT_SYSLOG_USER );
syslog_types, DEFAULT_SYSLOG_USER );
break;
#endif

View File

@ -430,6 +430,7 @@ LDAP_SLAPD_F (void) 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;
/*
* dn.c