Skip to content

Commit

Permalink
apr_ldap: Explicitly detect the case where OpenLDAP has been
Browse files Browse the repository at this point in the history
installed with SASL support, but the SASL headers are missing.


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1920267 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
minfrin committed Aug 29, 2024
1 parent df96b37 commit 0b10ac3
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes for APR 2.0.0

*) apr_ldap: Explicitly detect the case where OpenLDAP has been
installed with SASL support, but the SASL headers are missing.
[Graham Leggett]

*) testmmap: Avoid a crash after test_file_open() fails. [Graham
Leggett]

Expand Down
3 changes: 3 additions & 0 deletions build/ldap.m4
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ AC_DEFUN([APU_FIND_LDAPLIB], [
AC_CHECK_LIB(${ldaplib}, ldap_init,
[
LDADD_ldap_found="-l${ldaplib} ${extralib}"
AC_CHECK_LIB(${ldaplib}, ldap_sasl_interactive_bind, apu_have_ldap_sasl_interactive_bind="1", , ${extralib})
apu_have_ldap="1";
], , ${extralib})
fi
Expand All @@ -106,6 +107,7 @@ AC_DEFUN([APU_FIND_LDAP], [
echo $ac_n "${nl}checking for ldap support..."
apu_have_ldap_sasl_interactive_bind="0"
apu_have_ldap="0";
apu_have_ldap_openldap="0"
apu_have_ldap_microsoft="0"
Expand Down Expand Up @@ -224,6 +226,7 @@ AC_CHECK_HEADERS([sasl.h sasl/sasl.h])
AC_SUBST(ldap_h)
AC_SUBST(lber_h)
AC_SUBST(apu_have_ldap_sasl_interactive_bind)
AC_SUBST(apu_have_ldap)
AC_SUBST(apu_have_ldap_openldap)
AC_SUBST(apu_have_ldap_solaris)
Expand Down
3 changes: 2 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -3306,7 +3306,8 @@ if test -d $srcdir/test; then
AC_CONFIG_FILES([test/Makefile test/internal/Makefile])
fi

AC_CONFIG_FILES([include/private/apu_select_dbm.h
AC_CONFIG_FILES([include/private/apu_ldap_internal.h
include/private/apu_select_dbm.h
include/apu_want.h])

dir=include/arch/unix
Expand Down
25 changes: 25 additions & 0 deletions include/private/apu_ldap_internal.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef APU_LDAP_INTERNAL_H
#define APU_LDAP_INTERNAL_H

/*
** The following macros control what features APRUTIL will use
*/
#define APR_HAVE_LDAP_SASL_INTERACTIVE_BIND @apu_have_ldap_sasl_interactive_bind@

#endif /* !APU_LDAP_INTERNAL_H */
25 changes: 25 additions & 0 deletions include/private/apu_ldap_internal.hw
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef APU_LDAP_INTERNAL_H
#define APU_LDAP_INTERNAL_H

/*
** The following macros control what features APRUTIL will use
*/
#define APR_HAVE_LDAP_SASL_INTERACTIVE_BIND 0

#endif /* !APU_LDAP_INTERNAL_H */
9 changes: 7 additions & 2 deletions ldap/apr_ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "apr_ldap.h"
#include "apr_ldap_internal.h"
#include "apu_internal.h"
#include "apu_ldap_internal.h"
#include "apr_errno.h"
#include "apr_poll.h"
#include "apr_pools.h"
Expand Down Expand Up @@ -1803,7 +1804,11 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_poll(apr_pool_t *pool,



#if APR_HAS_OPENLDAP_LDAPSDK
#if APR_HAS_OPENLDAP_LDAPSDK && APR_HAVE_LDAP_SASL_INTERACTIVE_BIND

#if !defined(HAVE_SASL_H) && !defined(HAVE_SASL_SASL_H)
#error OpenLDAP was built with SASL support, but the SASL headers are not installed as required.
#endif

typedef struct apr_ldap_bind_ctx_t {
apr_ldap_t *ld;
Expand Down Expand Up @@ -2000,7 +2005,7 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_bind(apr_pool_t *pool, apr_ldap_t *ldap,
}
else {

#if APR_HAS_OPENLDAP_LDAPSDK
#if APR_HAS_OPENLDAP_LDAPSDK && APR_HAVE_LDAP_SASL_INTERACTIVE_BIND

const char *rmech;

Expand Down
51 changes: 51 additions & 0 deletions libapr.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0b10ac3

Please sign in to comment.