/* $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"
#include <ac/ctype.h>
#include <ac/time.h>
+#include <limits.h>
+
#include "ldap-int.h"
#include "ldap_defaults.h"
{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}
};
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;
for(i=0; attrs[i].type != ATTR_NONE; i++) {
void *p;
- if( !userconf && !attrs[i].useronly ) {
+ if( !userconf && attrs[i].useronly ) {
continue;
}
}
break;
}
+ break;
}
}
static void openldap_ldap_init_w_userconf(const char *file)
{
char *home;
- char *path;
+ char *path = NULL;
if (file == NULL) {
/* no file name */
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) {
}
}
-void ldap_int_initialize( void )
+void ldap_int_initialize( int *dbglvl )
{
if ( gopts.ldo_valid == LDAP_INITIALIZED ) {
return;
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;
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;
#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;
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);