Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2008-03-30 16:33:50 +0200
committerArthur de Jong <arthur@arthurdejong.org>2008-03-30 16:33:50 +0200
commit6d37c3fd4e51d632512fe2ce9587594ff6b41d8e (patch)
tree4effcd8e82f38c842aecab27ad6ccfbbf22d273a
parent799dd39d431189aaf0f836866c6c3c28dee75bf4 (diff)
only define and use do_sasl_interact() if we have a sasl library
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@648 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--configure.ac3
-rw-r--r--nslcd/myldap.c17
2 files changed, 16 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 930834d..7966aaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -249,6 +249,9 @@ AC_CHECK_TYPE(struct ucred,
#include <sys/un.h>
#include <sys/types.h>])
+AC_CHECK_TYPE(sasl_interact_t,
+ AC_DEFINE(HAVE_SASL_INTERACT_T,1,[Define to 1 if you have a `sasl_interact_t` definition.]))
+
# checks for LDAP library
save_LIBS="$LIBS"
LIBS="$nslcd_LIBS"
diff --git a/nslcd/myldap.c b/nslcd/myldap.c
index c5a1bff..eb2e70d 100644
--- a/nslcd/myldap.c
+++ b/nslcd/myldap.c
@@ -297,6 +297,7 @@ PURE static inline int is_valid_entry(MYLDAP_ENTRY *entry)
return (entry!=NULL)&&is_valid_search(entry->search)&&(entry->search->msg!=NULL);
}
+#ifdef HAVE_SASL_INTERACT_T
/* this is registered with ldap_sasl_interactive_bind_s() in do_bind() */
static int do_sasl_interact(LDAP UNUSED(*ld),unsigned UNUSED(flags),void *defaults,void *_interact)
{
@@ -325,6 +326,7 @@ static int do_sasl_interact(LDAP UNUSED(*ld),unsigned UNUSED(flags),void *defaul
}
return LDAP_SUCCESS;
}
+#endif /* HAVE_SASL_INTERACT_T */
#define LDAP_SET_OPTION(ld,option,invalue) \
rc=ldap_set_option(ld,option,invalue); \
@@ -341,6 +343,9 @@ static int do_bind(MYLDAP_SESSION *session,const char *uri)
int rc;
char *binddn,*bindarg;
int usesasl;
+#ifndef HAVE_SASL_INTERACT_T
+ struct berval cred;
+#endif /* not HAVE_SASL_INTERACT_T */
/* check if StartTLS is requested */
if (nslcd_cfg->ldc_ssl_on==SSL_START_TLS)
{
@@ -375,8 +380,7 @@ static int do_bind(MYLDAP_SESSION *session,const char *uri)
log_log(LOG_DEBUG,"simple bind to %s as %s",uri,binddn);
else
log_log(LOG_DEBUG,"simple anonymous bind to %s",uri);
- rc=ldap_simple_bind_s(session->ld,binddn,bindarg);
- return rc;
+ return ldap_simple_bind_s(session->ld,binddn,bindarg);
}
else
{
@@ -386,10 +390,15 @@ static int do_bind(MYLDAP_SESSION *session,const char *uri)
{
LDAP_SET_OPTION(session->ld,LDAP_OPT_X_SASL_SECPROPS,(void *)nslcd_cfg->ldc_sasl_secprops);
}
- rc=ldap_sasl_interactive_bind_s(session->ld,binddn,"GSSAPI",NULL,NULL,
+#ifdef HAVE_SASL_INTERACT_T
+ return ldap_sasl_interactive_bind_s(session->ld,binddn,"GSSAPI",NULL,NULL,
LDAP_SASL_QUIET,
do_sasl_interact,(void *)bindarg);
- return rc;
+#else /* HAVE_SASL_INTERACT_T */
+ cred.bv_val=bindarg;
+ cred.bv_len=strlen(bindarg);
+ return ldap_sasl_bind_s(session->ld,binddn,"GSSAPI",&cred,NULL,NULL,NULL);
+#endif /* not HAVE_SASL_INTERACT_T */
}
}