]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libads: Add utility function ads_zero_ldap().
authorJeremy Allison <jra@samba.org>
Sat, 8 Aug 2020 03:18:50 +0000 (20:18 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 18 Aug 2020 08:25:39 +0000 (08:25 +0000)
When initializing or re-initializing the ldap part of the ADS_STRUCT,
we should call this to ensure that ads->ldap.ss is correctly recognized
as a zero IPaddr by is_zero_addr(). It zeros out the ads->ldap but
then adds zero_sockaddr() to initialize as AF_INET. Otherwise it's
left by accident as AF_UNSPEC (0).

Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libads/ads_proto.h
source3/libads/ldap.c

index 6cdde0cf6ebb25adb69b4974efb4451683a35b73..5701a5d79d4190de7b13b3d0986c447423910f50 100644 (file)
@@ -81,6 +81,7 @@ bool ads_sitename_match(ADS_STRUCT *ads);
 bool ads_closest_dc(ADS_STRUCT *ads);
 ADS_STATUS ads_connect(ADS_STRUCT *ads);
 ADS_STATUS ads_connect_user_creds(ADS_STRUCT *ads);
+void ads_zero_ldap(ADS_STRUCT *ads);
 void ads_disconnect(ADS_STRUCT *ads);
 ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
                                int scope, const char *expr, const char **attrs,
index ee4628a09a27ee637bf361fabfe1f254f248fc3e..18e2b86fb8e06607ffe2dec8b2c8f831f26f5ee1 100755 (executable)
@@ -749,6 +749,25 @@ ADS_STATUS ads_connect_user_creds(ADS_STRUCT *ads)
        return ads_connect(ads);
 }
 
+/**
+ * Zero out the internal ads->ldap struct and initialize the address to zero IP.
+ * @param ads Pointer to an existing ADS_STRUCT
+ *
+ * Sets the ads->ldap.ss to a valid
+ * zero ip address that can be detected by
+ * our is_zero_addr() function. Otherwise
+ * it is left as AF_UNSPEC (0).
+ **/
+void ads_zero_ldap(ADS_STRUCT *ads)
+{
+       ZERO_STRUCT(ads->ldap);
+       /*
+        * Initialize the sockaddr_storage so we can use
+        * sockaddr test functions against it.
+        */
+       zero_sockaddr(&ads->ldap.ss);
+}
+
 /**
  * Disconnect the LDAP server
  * @param ads Pointer to an existing ADS_STRUCT