From 6e17b60648d45c029492234a3f44898497db3596 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 24 May 2004 23:28:52 +0000 Subject: [PATCH] add command line option (-S) to enable SLP registration (ITS#3132) off by default. Option assignment is temporary, should be replaced with "-o slp=". Based upon patch submitted by Ralf Haferkamp (SuSE). --- servers/slapd/daemon.c | 13 +++++++++---- servers/slapd/main.c | 31 +++++++++++++++++++------------ servers/slapd/proto-slap.h | 1 + 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index d7257eaffc..7e05ee928c 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -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; diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 0fdef6bc87..4cd12fde9c 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -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 diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 826f71f73a..2c8a865e1f 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 -- 2.39.5