]> git.sur5r.net Git - openldap/commitdiff
add command line option (-S) to enable SLP registration (ITS#3132)
authorKurt Zeilenga <kurt@openldap.org>
Mon, 24 May 2004 23:28:52 +0000 (23:28 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 24 May 2004 23:28:52 +0000 (23:28 +0000)
off by default.  Option assignment is temporary, should be replaced
with "-o slp=<ON|off>".
Based upon patch submitted by Ralf Haferkamp (SuSE).

servers/slapd/daemon.c
servers/slapd/main.c
servers/slapd/proto-slap.h

index d7257eaffc29940f69a12ac82d958a11b05cd9ae..7e05ee928c7f651a7d0af6ec4d4c797b9464cd2a 100644 (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;
index 0fdef6bc8702a406b0c7d725b848d8f71a4d4421..4cd12fde9c2184fe6f5f96bb0ab1230eaae4d9d9 100644 (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
 
index 826f71f73a30c5a5f2261f393b33166f73c0665a..2c8a865e1f775ff0ae8443d74b3926b0d1b64a71 100644 (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