1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s3: libads: Add utility function ads_zero_ldap().

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>
This commit is contained in:
Jeremy Allison 2020-08-07 20:18:50 -07:00 committed by Andreas Schneider
parent 8bb6a6607d
commit 0535a265f9
2 changed files with 20 additions and 0 deletions

View 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,

View File

@ -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