]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/init.c
Remove lint
[openldap] / libraries / libldap / init.c
index 0373d3226039eafe49ed78094472442209bafb0c..820c951e9597f44991f19bd3fc9f4ec4fcf41818 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 #include "portable.h"
@@ -13,6 +13,8 @@
 #include <ac/ctype.h>
 #include <ac/time.h>
 
+#include <limits.h>
+
 #include "ldap-int.h"
 #include "ldap_defaults.h"
 
@@ -75,6 +77,12 @@ static const struct ol_attribute {
        {0, ATTR_TLS,           "TLS_CACERT",   NULL,   LDAP_OPT_X_TLS_CACERTFILE},
        {0, ATTR_TLS,           "TLS_CACERTDIR",NULL,   LDAP_OPT_X_TLS_CACERTDIR},
        {0, ATTR_TLS,           "TLS_REQCERT",  NULL,   LDAP_OPT_X_TLS_REQUIRE_CERT},
+#ifdef HAVE_CYRUS_SASL
+       {0, ATTR_INT,           "SASL_MINSSF",  NULL,
+               offsetof(struct ldapoptions, ldo_sasl_minssf)},
+       {0, ATTR_INT,           "SASL_MAXSSF",  NULL,
+               offsetof(struct ldapoptions, ldo_sasl_maxssf)},
+#endif
        {0, ATTR_NONE,          NULL,           NULL,   0}
 };
 
@@ -95,12 +103,16 @@ static void openldap_ldap_init_w_conf(
                return;
        }
 
+       Debug(LDAP_DEBUG_TRACE, "ldap_init: trying %s\n", file, 0, 0);
+
        fp = fopen(file, "r");
        if(fp == NULL) {
                /* could not open file */
                return;
        }
 
+       Debug(LDAP_DEBUG_TRACE, "ldap_init: using %s\n", file, 0, 0);
+
        while((start = fgets(linebuf, sizeof(linebuf), fp)) != NULL) {
                /* skip lines starting with '#' */
                if(*start == '#') continue;
@@ -140,7 +152,7 @@ static void openldap_ldap_init_w_conf(
                for(i=0; attrs[i].type != ATTR_NONE; i++) {
                        void *p;
 
-                       if( !userconf && !attrs[i].useronly ) {
+                       if( !userconf && attrs[i].useronly ) {
                                continue;
                        }
 
@@ -200,6 +212,7 @@ static void openldap_ldap_init_w_conf(
                                }
                                break;
                        }
+                       break;
                }
        }
 
@@ -214,7 +227,7 @@ static void openldap_ldap_init_w_sysconf(const char *file)
 static void openldap_ldap_init_w_userconf(const char *file)
 {
        char *home;
-       char *path;
+       char *path = NULL;
 
        if (file == NULL) {
                /* no file name */
@@ -224,9 +237,12 @@ static void openldap_ldap_init_w_userconf(const char *file)
        home = getenv("HOME");
 
        if (home != NULL) {
+               Debug(LDAP_DEBUG_TRACE, "ldap_init: HOME env is %s\n",
+                     home, 0, 0);
                path = LDAP_MALLOC(strlen(home) + strlen(file) + 3);
        } else {
-               path = LDAP_MALLOC(strlen(file) + 3);
+               Debug(LDAP_DEBUG_TRACE, "ldap_init: HOME env is NULL\n",
+                     0, 0, 0);
        }
 
        if(home != NULL && path != NULL) {
@@ -331,7 +347,7 @@ static void openldap_ldap_init_w_env(const char *prefix)
        }
 }
 
-void ldap_int_initialize( void )
+void ldap_int_initialize( int *dbglvl )
 {
        if ( gopts.ldo_valid == LDAP_INITIALIZED ) {
                return;
@@ -350,6 +366,9 @@ void ldap_int_initialize( void )
        if ( ldap_int_tblsize == 0 )
                ldap_int_ip_init();
 
+       if (dbglvl)
+           gopts.ldo_debug = *dbglvl;
+       else
        gopts.ldo_debug = 0;
 
        gopts.ldo_version =     LDAP_VERSION2;
@@ -360,6 +379,9 @@ void ldap_int_initialize( void )
        gopts.ldo_tm_api = (struct timeval *)NULL;
        gopts.ldo_tm_net = (struct timeval *)NULL;
 
+       /* ldo_defludp is leaked, we should have an at_exit() handler
+        * to free this and whatever else needs to cleaned up. 
+        */
        ldap_url_parselist(&gopts.ldo_defludp, "ldap://localhost/");
        gopts.ldo_defport = LDAP_PORT;
 
@@ -372,6 +394,10 @@ void ldap_int_initialize( void )
 #ifdef HAVE_TLS
        gopts.ldo_tls_ctx = NULL;
 #endif
+#ifdef HAVE_CYRUS_SASL
+       gopts.ldo_sasl_minssf = 0;
+       gopts.ldo_sasl_maxssf = INT_MAX;
+#endif
 
        gopts.ldo_valid = LDAP_INITIALIZED;
 
@@ -386,16 +412,26 @@ void ldap_int_initialize( void )
                char *altfile = getenv(LDAP_ENV_PREFIX "CONF");
 
                if( altfile != NULL ) {
+                       Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is %s\n",
+                             LDAP_ENV_PREFIX "CONF", altfile, 0);
                        openldap_ldap_init_w_sysconf( altfile );
                }
+               else
+                       Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is NULL\n",
+                             LDAP_ENV_PREFIX "CONF", 0, 0);
        }
 
        {
                char *altfile = getenv(LDAP_ENV_PREFIX "RC");
 
                if( altfile != NULL ) {
+                       Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is %s\n",
+                             LDAP_ENV_PREFIX "RC", altfile, 0);
                        openldap_ldap_init_w_userconf( altfile );
                }
+               else
+                       Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is NULL\n",
+                             LDAP_ENV_PREFIX "RC", 0, 0);
        }
 
        openldap_ldap_init_w_env(NULL);