[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#5295) option to allow slapd bind to any available port



Full_Name: Chitra Vemkatramani
Version: 2.3.27
OS: Redhat
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (162.83.178.28)


For a project that we are using openldap in, we would like to allow multiple
users to start up ldap servers on the same machine. We would like an option on
the slapd command line asking the server to pick any available port to bind to.
We can then do  netstat, find the port and pass that on to the client. Here is
the patch we put in, to allow us to specify -1 for the port, so that the server
will pick any available port. Can you please consider adding this to the server
options ?

--- openldap-2.3.27/libraries/libldap/url.c     2006-04-03 15:49:55.000000000
-0400
+++ /homes/hny1/chitrav/bindport0/url.c 2007-04-19 12:26:47.407806503 -0400
@@ -833,7 +833,7 @@

        ludp->lud_next = NULL;
        ludp->lud_host = NULL;
-       ludp->lud_port = 0;
+       ludp->lud_port = -1;
        ludp->lud_dn = NULL;
        ludp->lud_attrs = NULL;
        ludp->lud_scope = LDAP_SCOPE_DEFAULT;
@@ -1118,7 +1118,7 @@
                (*ludpp)->lud_host = NULL;
        }

-       if ((*ludpp)->lud_port == 0) {
+       if ((*ludpp)->lud_port == -1) {
                if( strcmp((*ludpp)->lud_scheme, "ldap") == 0 ) {
                        (*ludpp)->lud_port = LDAP_PORT;
 #ifdef LDAP_CONNECTIONLESS


--- openldap-2.3.27/servers/slapd/daemon.c      2006-05-11 14:33:31.000000000
-0400
+++ /homes/hny1/chitrav/bindport0/daemon.c      2007-04-19 12:35:25.814156154
-0400
@@ -683,7 +683,7 @@
        struct sockaddr **sap;

 #ifdef LDAP_PF_LOCAL
-       if ( port == 0 ) {
+       if ( port == -1 ) {
                *sal = ch_malloc(2 * sizeof(void *));
                if (*sal == NULL) return -1;

@@ -866,12 +866,12 @@
                return -1;
        }

-       if(! lud->lud_port ) lud->lud_port = LDAP_PORT;
+       if( lud->lud_port == -1 ) lud->lud_port = LDAP_PORT;

 #else
        l.sl_is_tls = ldap_pvt_url_scheme2tls( lud->lud_scheme );

-       if(! lud->lud_port ) {
+       if( lud->lud_port == -1 ) {
                lud->lud_port = l.sl_is_tls ? LDAPS_PORT : LDAP_PORT;
        }
 #endif