[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: ldap_url_search fails when URL does not specify host (ldap:///) (ITS#843)
--3V7upXqbjpZ4EhLz
Content-Type: text/plain; charset=us-ascii
On Tue, Oct 17, 2000 at 03:45:33PM -0700, Kurt D. Zeilenga wrote:
> I fixed this in HEAD and OPENLDAP_REL_ENG_2 by having ldap_url_search()
> to ignore the hostport and to use the default session associated with
> the handle. Please test.
This works, and I think it makes sense this way, although it's different to
openldap-1.2.11 (where a hostname in the URL takes precedence over the host
in the ldap connection; it seems to open a second connection)
A couple of other issues:
- The difference in ldap_url_parse still exists. i.e. for an empty hostname
in the URL, openldap-1.2.11 returns a NULL pointer, whilst openldap-2.0.6
returns a pointer to an empty string.
There is existing client code which assumes the NULL behaviour (for example,
exim's ldap client) - but I cannot find any documentation which says what
ldap_parse_url ought to do in that case.
- When ldap_url_search returned, it was leaving LDAP_OPT_ERROR_STRING set to
a null pointer.
In an attempt to test this again, I ran the program below leaving the ldap
server pointing to a non-existent host (10.0.0.1). After 75 seconds it
aborts with a sig11:
$ ./ldaptest
Host: '', Port: 389
Segmentation fault (core dumped)
$ gdb ldaptest -c ldaptest.core
...
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libc.so.4...done.
Reading symbols from /usr/libexec/ld-elf.so.1...done.
#0 0x804ba65 in ldap_alloc_ber_with_options (ld=0x0) at request.c:62
62 if (( ber = ber_alloc_t( ld->ld_lberoptions )) == NULL ) {
(gdb) bt
#0 0x804ba65 in ldap_alloc_ber_with_options (ld=0x0) at request.c:62
#1 0x8051567 in ldap_build_search_req (ld=0x0,
base=0x805e0c0 "o=whatever,c=GB", scope=2,
filter_in=0x805e0d0 "(objectclass=*)", attrs=0x0, attrsonly=0, sctrls=0x0,
cctrls=0x0, timelimit=-1, sizelimit=-1) at search.c:275
#2 0x804ea6b in ldap_url_search (ld=0x0,
url=0x80582e0 "ldap:///o=whatever,c=GB??sub?(objectclass=*)", attrsonly=0)
at url.c:885
#3 0x8049099 in main ()
#4 0x8048f95 in _start ()
(gdb)
Regards,
Brian.
--3V7upXqbjpZ4EhLz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ldaptest.c"
#include <stdio.h>
#ifdef OPENLDAPv1
#include <lber.h>
#endif
#include <ldap.h>
#define HOST "10.0.0.1"
#define URL "ldap:///o=whatever,c=GB??sub?(objectclass=*)"
/* #define URL "ldap://10.0.0.2/o=whatever,c=GB??sub?(objectclass=*)" */
int main(void)
{
LDAP *ld = ldap_open(HOST, 389);
LDAPURLDesc *ludp;
LDAPMessage *result;
int r1, r2;
if (ldap_url_parse(URL, &ludp) != 0) {
fprintf(stderr, "Error in ldap_url_parse\n");
return 1;
}
fprintf(stderr, "Host: '%s', Port: %d\n", ludp->lud_host?ludp->lud_host:"NULL", ludp->lud_port);
r1 = ldap_url_search(ld, URL, 0);
if (r1 == -1) {
#ifdef OPENLDAPv1
char *error = ld->ld_error;
#else
char *error;
int errorno;
ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &errorno);
fprintf(stderr, "Error in ldap_url_search: %d\n", errorno);
ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &error);
#endif
fprintf(stderr, "Error in ldap_url_search: %s\n", error?error:"NULL");
return 1;
}
r2 = ldap_result(ld, LDAP_RES_ANY, 1, NULL, &result);
if (r2 == -1) {
#ifdef OPENLDAPv1
char *error = ld->ld_error;
#else
char *error;
ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &error);
#endif
fprintf(stderr, "Error in ldap_result: %s\n", error?error:"NULL");
return 1;
}
fprintf(stderr, "OK\n");
return 0;
}
--3V7upXqbjpZ4EhLz--