Code

Merge branch 'collectd-5.5'
authorMarc Fournier <marc.fournier@camptocamp.com>
Wed, 17 Jun 2015 13:03:18 +0000 (15:03 +0200)
committerMarc Fournier <marc.fournier@camptocamp.com>
Wed, 17 Jun 2015 13:03:18 +0000 (15:03 +0200)
1  2 
src/openldap.c

diff --combined src/openldap.c
index d11855a1e4cda556342568c887e096f638163214,8667058ed049b164d7e496f37917253e55adcf14..ffcdb94e8049000961cd19bc65a167387532f9c0
@@@ -38,8 -38,6 +38,8 @@@ struct cldap_s /* {{{ *
  {
        char *name;
  
 +      char *binddn;
 +      char *password;
        char *cacert;
        char *host;
        int   state;
@@@ -58,8 -56,6 +58,8 @@@ static void cldap_free (cldap_t *st) /
        if (st == NULL)
                return;
  
 +      sfree (st->binddn);
 +      sfree (st->password);
        sfree (st->cacert);
        sfree (st->host);
        sfree (st->name);
@@@ -114,19 -110,10 +114,19 @@@ static int cldap_init_host (cldap_t *st
        }
  
        struct berval cred;
 -      cred.bv_val = "";
 -      cred.bv_len = 0;
 +      if (st->password != NULL)
 +      {
 +              cred.bv_val = st->password;
 +              cred.bv_len = strlen (st->password);
 +      }
 +      else
 +      {
 +              cred.bv_val = "";
 +              cred.bv_len = 0;
 +      }
  
 -      rc = ldap_sasl_bind_s (st->ld, NULL, NULL, &cred, NULL, NULL, NULL);
 +      rc = ldap_sasl_bind_s (st->ld, st->binddn, LDAP_SASL_SIMPLE, &cred, 
 +                      NULL, NULL, NULL);
        if (rc != LDAP_SUCCESS)
        {
                ERROR ("openldap plugin: Failed to bind to %s: %s",
@@@ -572,11 -559,7 +572,11 @@@ static int cldap_config_add (oconfig_it
        {
                oconfig_item_t *child = ci->children + i;
  
 -              if (strcasecmp ("CACert", child->key) == 0)
 +              if (strcasecmp ("BindDN", child->key) == 0)
 +                      status = cf_util_get_string (child, &st->binddn);
 +              else if (strcasecmp ("Password", child->key) == 0)
 +                      status = cf_util_get_string (child, &st->password);
 +              else if (strcasecmp ("CACert", child->key) == 0)
                        status = cf_util_get_string (child, &st->cacert);
                else if (strcasecmp ("StartTLS", child->key) == 0)
                        status = cf_util_get_boolean (child, &st->starttls);
                                st->name, st->url);
                        status = -1;
                }
-               else
+               if ((status == 0) && (ludpp->lud_host != NULL))
                {
                        st->host = strdup (ludpp->lud_host);
                }
                status = plugin_register_complex_read (/* group = */ NULL,
                                /* name      = */ callback_name,
                                /* callback  = */ cldap_read_host,
 -                              /* interval  = */ NULL,
 +                              /* interval  = */ 0,
                                /* user_data = */ &ud);
        }