Skip to content

Conversation

@FireBurn
Copy link

@FireBurn FireBurn commented Oct 7, 2025

Authored-by: Mike Lothian mike@fireburn.co.uk

This fixes https://bugs.squid-cache.org/show_bug.cgi?id=5513

And if you're happy with it, get it backported to 7.x too

@squid-anubis

This comment was marked as resolved.

@squid-anubis squid-anubis added M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels labels Oct 7, 2025
@rousskov
Copy link
Contributor

rousskov commented Oct 7, 2025

@FireBurn, do you have an ldap package installed? AFAICT, since 2024 commit 2a849db, our logic for LDAP detection1 is "If pkg-config fails, rely on the user to specify correct libraries/flags/etc. for the features they want to enable (instead of poorly duplicating pgk-config logic/job)".


Bug report: Building Squid 7.1 on RHEL7 and RHEL8 gives:

checking for ldapssl_client_init in -lldap... no
checking for library containing ldap_url_desc2str... no
checking for library containing ldap_url_parse... no
checking for library containing ldap_start_tls_s... no

Where as 6.14 gives:

checking for ldapssl_client_init in -lldap... no
checking for library containing ldap_url_desc2str... -lldap
checking for library containing ldap_url_parse... none required
checking for library containing ldap_start_tls_s... none required

@FireBurn, what output do you get with these changes? Same as for v6.14?

Besides SQUID_CHECK_LDAP_API quoted above, is there output related to the PKG_CHECK_MODULES() call that fails to find ldap? If there is, please include it as well.

Footnotes

  1. Windows-specific hacks aside.

@rousskov rousskov changed the title Fix OpenLDAP detection Bug 5513: Fix OpenLDAP detection Oct 7, 2025
@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Oct 7, 2025
SQUID_AUTO_LIB(ldap,[LDAP],[LIBLDAP])
SQUID_CHECK_LIB_WORKS(ldap,[
PKG_CHECK_MODULES([LIBLDAP],[ldap],[:],[:])
SQUID_STATE_SAVE(squid_ldap_state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State preservation is done by the *_LIB_WORKS macro.

Suggested change
SQUID_STATE_SAVE(squid_ldap_state)

AC_CHECK_HEADERS(ldap.h lber.h)
AC_CHECK_HEADERS(mozldap/ldap.h)
SQUID_CHECK_LDAP_API
SQUID_STATE_ROLLBACK(squid_ldap_state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State preservation is done by the *_LIB_WORKS macro.

Suggested change
SQUID_STATE_ROLLBACK(squid_ldap_state)

SQUID_STATE_SAVE(squid_ldap_state)
PKG_CHECK_MODULES([LIBLDAP],[ldap],[:],[
AC_CHECK_LIB(lber, ber_init, [LIBLBER="-llber"])
AC_CHECK_LIB(ldap, ldap_init, [LIBLDAP_LIBS="-lldap $LIBLBER"])
Copy link
Contributor

@rousskov rousskov Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At #2267 (comment): Are you wanting me to just close this and use --with-ldap=/usr/lib64 or something similar?

I am opening a new thread for this important question to avoid hijacking an unrelated change request where that question was asked. My earlier questions were not answered directly, but I assume that #2267 (comment) implies that the following statements are true:

  1. In your build environment, there are no LDAP pkg-config files installed.
  2. In your build environment, using --with-ldap=/usr/lib64 (or similar) works.

If the above statements are true, and there are no known problems with existing pkg-config-based code in Squid, then I believe that the correct answer to your question is "Yes, please close this PR: We do not want to restore or add detection code for libraries that provide working pkg-config files (in some environments) and can be correctly handled using custom ./configure options (in other environments). We need to avoid long-term maintenance overheads associated with such detection code. Wiki pull requests documenting workarounds for older environments are welcome."

Copy link
Contributor

@pdvSNnz pdvSNnz Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For Dists <EL9, there is no LDAP pkg-config (openldap < 2.6)
  2. --with-ldap=/usr/lib64 didn't change anything

Copy link
Contributor

@rousskov rousskov Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For Dists <EL9, there is no LDAP pkg-config (openldap < 2.6)

Noted.

  1. --with-ldap=/usr/lib64 didn't change anything

IMO, we need to focus on addressing that problem (instead of re-affirming that it is possible to hard-code exceptional code that fixes build in a specific environment like EL7 or EL8). "Addressing that problem" may result in fixing --with-ldap=X support (for all/many environments!) or adjusting those workaround instructions for a specific environment like EL7 or EL8. More at #2267 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will admit that it was premature to drop the AC_CHECK_LIB earlier. Adding them back in a way that works with the new design is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For Dists <EL9, there is no LDAP pkg-config (openldap < 2.6)

Noted.

  1. --with-ldap=/usr/lib64 didn't change anything

IMO, we need to focus on addressing that problem

The reason for that is that is the placement of the fallback logic within the PKG_CHECK_MODULES macro parameters. Precisely the failure/bug case my change request was about.

With the current PR patch:

  • --with-ldap should work
  • --with-ldap=/usr/lib64 should work

@kinkie
Copy link
Contributor

kinkie commented Oct 25, 2025

@FireBurn as there is a solution to the issue you highlighted, are you okay with closing this PR?

@FireBurn
Copy link
Author

Sorry, I'll build 7.2 on Monday. If I have issues I'll report back

@FireBurn
Copy link
Author

So with 7.2 with my patch:

checking for LIBLDAP... no
checking for ber_init in -llber... yes
checking for ldap_init in -lldap... yes
checking ldap.h usability... yes
checking ldap.h presence... yes
checking for ldap.h... yes
checking lber.h usability... yes
checking lber.h presence... yes
checking for lber.h... yes
checking mozldap/ldap.h usability... no
checking mozldap/ldap.h presence... no
checking for mozldap/ldap.h... no
checking for LDAP... 1
checking for OpenLDAP... 1
checking for Sun LDAP SDK... 0
checking for Mozilla LDAP SDK... 0
checking for LDAP_OPT_DEBUG_LEVEL... 1
checking for LDAP_SCOPE_DEFAULT... 1
checking for LDAP_REBIND_PROC... 1
checking for LDAP_REBINDPROC_CALLBACK... 0
checking for LDAP_REBIND_FUNCTION... 0
checking for LDAP_URL_LUD_SCHEME... 0
checking for ldapssl_client_init in -lldap... no
checking for library containing ldap_url_desc2str... -lldap
checking for library containing ldap_url_parse... none required
checking for library containing ldap_start_tls_s... none required
configure: Library 'ldap' support: yes -lldap -llber

With 7.3 with passing "--with-ldap=/usr/lib64" I get:

checking for LIBLDAP... no
checking ldap.h usability... yes
checking ldap.h presence... yes
checking for ldap.h... yes
checking lber.h usability... yes
checking lber.h presence... yes
checking for lber.h... yes
checking mozldap/ldap.h usability... no
checking mozldap/ldap.h presence... no
checking for mozldap/ldap.h... no
checking for LDAP... 1
checking for OpenLDAP... 1
checking for Sun LDAP SDK... 0
checking for Mozilla LDAP SDK... 0
checking for LDAP_OPT_DEBUG_LEVEL... 1
checking for LDAP_SCOPE_DEFAULT... 1
checking for LDAP_REBIND_PROC... 1
checking for LDAP_REBINDPROC_CALLBACK... 0
checking for LDAP_REBIND_FUNCTION... 0
checking for LDAP_URL_LUD_SCHEME... 0
checking for ldapssl_client_init in -lldap... no
checking for library containing ldap_url_desc2str... no
checking for library containing ldap_url_parse... no
checking for library containing ldap_start_tls_s... no
configure: error: Required library 'ldap' not found

@rousskov
Copy link
Contributor

Here is a diff-like summary of the previous comment:

-So with 7.2 with my patch:
+With 7.3 with passing "--with-ldap=/usr/lib64" I get:

-checking for ber_init in -llber... yes
-checking for ldap_init in -lldap... yes

-checking for library containing ldap_url_desc2str... -lldap
+checking for library containing ldap_url_desc2str... no

-checking for library containing ldap_url_parse... none required
+checking for library containing ldap_url_parse... no

-checking for library containing ldap_start_tls_s... none required
+checking for library containing ldap_start_tls_s... no

-configure: Library 'ldap' support: yes -lldap -llber
+configure: error: Required library 'ldap' not found

@FireBurn
Copy link
Author

I also tried --with-openldap=/usr/lib64

@rousskov
Copy link
Contributor

rousskov commented Oct 29, 2025

Francesco: @FireBurn as there is a solution to the issue you highlighted, are you okay with closing this PR?

AFAICT, @FireBurn comment is meant to imply that the alternative "solution" discussed earlier does not work and, hence, this PR should be merged instead.

My change request remains unaddressed, but I would like to clarify one aspect to avoid a possible misunderstanding:

Mike: With 7.3 with passing "--with-ldap=/usr/lib64" I get: ... Required library 'ldap' not found

The question is not whether --with-ldap=/usr/lib64 works. The question is whether --with-ldap=/usr/lib64 or some command line options/variables work in the given environment. If the answer is "no, no combination of command line options/variables works in the given environment", then the correct solution is most likely not

  • let's change configure.ac so that no command line options/variables_ are necessary in this environment

Most likely, the correct solution is

  • let's fix configure.ac so that --with-ldap=/usr/lib64 or some command line options/variables work in this environment

Justification for the above reasoning has been provided in my earlier change request.

I hope the diff in the earlier comment shows what command line options/variables are missing or what needs to be fixed in configure.ac. I have not studied the issue enough to suggest what is missing or needs to be fixed.

merging after third-party confirmation that it works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-for-author author action is expected (and usually required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants