lib-util: rename memdup to smb_memdup and fix all callers
[nivanova/samba-autobuild/.git] / source3 / lib / smbldap.c
index 81276936e6885b9412e43df6fadb9bd06b48e2c8..f2d58a54d19a8f38d154af3451dee3b665437492 100644 (file)
@@ -26,6 +26,7 @@
 #include "smbldap.h"
 #include "../libcli/security/security.h"
 #include <tevent.h>
+#include "lib/param/loadparm.h"
 
 /* Try not to hit the up or down server forever */
 
        return 0;
 }
 
- void talloc_autofree_ldapmsg(TALLOC_CTX *mem_ctx, LDAPMessage *result)
+ void smbldap_talloc_autofree_ldapmsg(TALLOC_CTX *mem_ctx, LDAPMessage *result)
 {
        LDAPMessage **handle;
 
        return 0;
 }
 
- void talloc_autofree_ldapmod(TALLOC_CTX *mem_ctx, LDAPMod **mod)
+ void smbldap_talloc_autofree_ldapmod(TALLOC_CTX *mem_ctx, LDAPMod **mod)
 {
        LDAPMod ***handle;
 
@@ -352,7 +353,7 @@ static void smbldap_set_mod_internal(LDAPMod *** modlist, int modop, const char
                mods[i]->mod_bvalues[j] = SMB_MALLOC_P(struct berval);
                SMB_ASSERT(mods[i]->mod_bvalues[j] != NULL);
 
-               mods[i]->mod_bvalues[j]->bv_val = (char *)memdup(blob->data, blob->length);
+               mods[i]->mod_bvalues[j]->bv_val = (char *)smb_memdup(blob->data, blob->length);
                SMB_ASSERT(mods[i]->mod_bvalues[j]->bv_val != NULL);
                mods[i]->mod_bvalues[j]->bv_len = blob->length;
 
@@ -553,7 +554,7 @@ static void smbldap_store_state(LDAP *ld, struct smbldap_state *smbldap_state)
  start TLS on an existing LDAP connection
 *******************************************************************/
 
-int smb_ldap_start_tls(LDAP *ldap_struct, int version)
+int smbldap_start_tls(LDAP *ldap_struct, int version)
 { 
 #ifdef LDAP_OPT_X_TLS
        int rc;
@@ -724,7 +725,7 @@ static int smb_ldap_upgrade_conn(LDAP *ldap_struct, int *new_version)
  open a connection to the ldap server (just until the bind)
  ******************************************************************/
 
-int smb_ldap_setup_full_conn(LDAP **ldap_struct, const char *uri)
+int smbldap_setup_full_conn(LDAP **ldap_struct, const char *uri)
 {
        int rc, version;
 
@@ -738,7 +739,7 @@ int smb_ldap_setup_full_conn(LDAP **ldap_struct, const char *uri)
                return rc;
        }
 
-       rc = smb_ldap_start_tls(*ldap_struct, version);
+       rc = smbldap_start_tls(*ldap_struct, version);
        if (rc) {
                return rc;
        }
@@ -775,7 +776,7 @@ static int smbldap_open_connection (struct smbldap_state *ldap_state)
 
        /* Start TLS if required */
 
-       rc = smb_ldap_start_tls(*ldap_struct, version);
+       rc = smbldap_start_tls(*ldap_struct, version);
        if (rc) {
                return rc;
        }
@@ -869,7 +870,7 @@ static int rebindproc_connect_with_state (LDAP *ldap_struct,
         * our credentials. At least *try* to secure the connection - Guenther */
 
        smb_ldap_upgrade_conn(ldap_struct, &version);
-       smb_ldap_start_tls(ldap_struct, version);
+       smbldap_start_tls(ldap_struct, version);
 
        /** @TODO Should we be doing something to check what servers we rebind to?
            Could we get a referral to a machine that we don't want to give our
@@ -1021,7 +1022,7 @@ done:
 }
 
 static void smbldap_idle_fn(struct tevent_context *tevent_ctx,
-                           struct timed_event *te,
+                           struct tevent_timer *te,
                            struct timeval now_abs,
                            void *private_data);
 
@@ -1626,12 +1627,13 @@ int smbldap_search_suffix (struct smbldap_state *ldap_state,
                           const char *filter, const char **search_attr,
                           LDAPMessage ** result)
 {
-       return smbldap_search(ldap_state, lp_ldap_suffix(), LDAP_SCOPE_SUBTREE,
+       return smbldap_search(ldap_state, lp_ldap_suffix(talloc_tos()),
+                             LDAP_SCOPE_SUBTREE,
                              filter, search_attr, 0, result);
 }
 
 static void smbldap_idle_fn(struct tevent_context *tevent_ctx,
-                           struct timed_event *te,
+                           struct tevent_timer *te,
                            struct timeval now_abs,
                            void *private_data)
 {