Add support and documentation for "ldapi://" URI scheme #177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The existing LDAP code allows an administrator to select the URI scheme used to connect to the LDAP server: either "ldap://" or "ldaps://". However there exists an additional scheme "ldapi://" which was created by the authors of OpenLDAP (See Here). This allows a URI to be constructed that specifies a Unix domain socket to connect to on the filesystem.
Coincidentally, the LDAP client library which pure-ftpd uses is libldap which is part of the OpenLDAP project. The existing pure-ftpd LDAP code simply constructs an LDAP URI string and passes it directly to this library. This almost allows pure-ftpd servers to use the ldapi scheme as-is, but the existing code always appends a port number to the URI and ldapi URIs cannot have port numbers.
This trivial patch simply checks the provided LDAPScheme to see if it is "ldapi" and then omits the port number from the generated URI string. It also adds some documentation to indicate that ldapi URIs will work.
I have been using this patch for a while now and thought it might be worth giving back. Since ldapi URIs are a bit odd, I will provide the first two lines of my actual pure-ftpd.d/ldap.conf file as an example: