error from ldap_simple_bind_s reported wrong
Closed, ResolvedPublic

Description

I get error messages like

dirmngr[1234.0]: dirmngr_ldap[2345]: binding to `ldap.example.com:389' failed:
Success

"Success" is certainly wrong.

src/dirmngr_ldap.c starting line 576 contains:

  if (ldap_simple_bind_s (ld, opt.user, opt.pass))
    {
      log_error (_("binding to `%s:%d' failed: %s\n"),
                 host, port, strerror (errno));
      /* FIXME: Need deinit (ld)?  */
      return -1;
    }

The nature of an error from ldap_simple_bind_s() is not reported by errno but by
the return value. Better write:

  rc = ldap_simple_bind_s (ld, opt.user, opt.pass);
  if (rc)
    {
      log_error (_("binding to `%s:%d' failed: %s\n"),
                 host, port, ldap_err2string (rc));
      /* FIXME: Need deinit (ld)?  */
      return -1;
    }

Thank you

Details

Version
1.1.1
perske set Version to 1.1.1.Dec 19 2013, 6:19 PM
perske added projects: dirmngr, Bug Report.
perske added a subscriber: perske.

To also fix Issue1449, enhance my correction this way:

  rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, LDAP_VERSION3);
  if (rc)
    {
      log_error (_("setting LDAPv3 for `%s:%d' failed: %s\n"),
                 host, port, ldap_err2string (rc));
      /* FIXME: Need deinit (ld)?  */
      return -1;
    }
  rc = ldap_simple_bind_s (ld, opt.user, opt.pass);
  if (rc)
    {
      log_error (_("binding to `%s:%d' failed: %s\n"),
                 host, port, ldap_err2string (rc));
      /* FIXME: Need deinit (ld)?  */
      return -1;
    }

And add translations for the new error message.

Thank you

neal closed this task as Resolved.Nov 17 2015, 11:15 PM
neal claimed this task.

This has since been corrected. Thanks.