[PATCH] More cleanups from the attic

Jeremy Allison jra at samba.org
Fri Nov 17 18:51:10 UTC 2017


On Fri, Nov 17, 2017 at 04:04:11PM +0100, Volker Lendecke via samba-technical wrote:
> Hi!
> 
> Review appreciated!

RB+. Really nice job. I especially like the removal
of the direct winbindd calls !

> -- 
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:kontakt at sernet.de

> From f3d4f8034d890f04b8b16dc0d7e51c8dcbddccd2 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Tue, 7 Nov 2017 13:04:21 +0100
> Subject: [PATCH 01/14] libsmb: Fix a typo
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/libsmb/namequery.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
> index e39d76176cc..afc2bc06d3f 100644
> --- a/source3/libsmb/namequery.c
> +++ b/source3/libsmb/namequery.c
> @@ -2556,7 +2556,7 @@ static NTSTATUS resolve_ads(const char *name,
>  				freeaddrinfo(res);
>  			}
>  		} else {
> -			/* use all the IP addresses from the SRV sresponse */
> +			/* use all the IP addresses from the SRV response */
>  			int j;
>  			for (j = 0; j < dcs[i].num_ips; j++) {
>  				(*return_iplist)[*return_count].port = dcs[i].port;
> -- 
> 2.11.0
> 
> 
> From 2b40ecebcae12a241c4f45162ce0bdc29f11c9d2 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 30 Oct 2017 13:51:25 +0100
> Subject: [PATCH 02/14] tevent: Fix typos
> 
> While there, fix comment formatting
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  lib/tevent/tevent.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
> index 728cf6267f1..7284a8559d2 100644
> --- a/lib/tevent/tevent.h
> +++ b/lib/tevent/tevent.h
> @@ -936,8 +936,8 @@ void tevent_req_set_cancel_fn(struct tevent_req *req, tevent_req_cancel_fn fn);
>   *
>   * @param[in]  req      The request to use.
>   *
> - * @return              This function returns true is the request is cancelable,
> - *                      othererwise false is returned.
> + * @return              This function returns true if the request is
> + *                      cancelable, otherwise false is returned.
>   *
>   * @note Even if the function returns true, the caller need to wait
>   *       for the function to complete normally.
> -- 
> 2.11.0
> 
> 
> From 1190cab2bfa76ed27f79d228aa2123168a897b07 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 17 Jul 2017 15:40:11 +0200
> Subject: [PATCH 03/14] nsswitch: Fix a typo
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  nsswitch/winbind_struct_protocol.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/nsswitch/winbind_struct_protocol.h b/nsswitch/winbind_struct_protocol.h
> index a2e7d4c392c..9100dbcf6ea 100644
> --- a/nsswitch/winbind_struct_protocol.h
> +++ b/nsswitch/winbind_struct_protocol.h
> @@ -258,7 +258,7 @@ struct winbindd_request {
>  		gid_t gid;           /* getgrgid, gid_to_sid */
>  		uint32_t ndrcmd;
>  		struct {
> -			/* We deliberatedly don't split into domain/user to
> +			/* We deliberately don't split into domain/user to
>                             avoid having the client know what the separator
>                             character is. */
>  			fstring user;
> -- 
> 2.11.0
> 
> 
> From 91ee499c82c1f0d1965b0a159b02135e24e71c0c Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sun, 6 Aug 2017 18:04:12 +0200
> Subject: [PATCH 04/14] winbindd: Fix some signed/unsigned warnings
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/winbindd/winbindd_cache.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
> index faea764cb5d..502232544c4 100644
> --- a/source3/winbindd/winbindd_cache.c
> +++ b/source3/winbindd/winbindd_cache.c
> @@ -452,7 +452,7 @@ static NTSTATUS fetch_cache_seqnum( struct winbindd_domain *domain, time_t now )
>  	/* have we expired? */
>  
>  	time_diff = now - domain->last_seq_check;
> -	if ( time_diff > lp_winbind_cache_time() ) {
> +	if ((int)time_diff > lp_winbind_cache_time()) {
>  		DEBUG(10,("fetch_cache_seqnum: timeout [%s][%u @ %u]\n",
>  			domain->name, domain->sequence_number,
>  			(uint32_t)domain->last_seq_check));
> @@ -619,7 +619,7 @@ static bool centry_expired(struct winbindd_domain *domain, const char *keystr, s
>  	   current sequence number or it did not timeout then it is OK */
>  	if (wcache_server_down(domain)
>  	    || ((centry->sequence_number == domain->sequence_number)
> -		&& (centry->timeout > time(NULL)))) {
> +		&& ((time_t)centry->timeout > time(NULL)))) {
>  		DEBUG(10,("centry_expired: Key %s for domain %s is good.\n",
>  			keystr, domain->name ));
>  		return false;
> @@ -4802,7 +4802,7 @@ bool wcache_fetch_ndr(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
>  			goto fail;
>  		}
>  		entry_timeout = BVAL(data.dptr, 4);
> -		if (time(NULL) > entry_timeout) {
> +		if (time(NULL) > (time_t)entry_timeout) {
>  			DEBUG(10, ("Entry has timed out\n"));
>  			goto fail;
>  		}
> -- 
> 2.11.0
> 
> 
> From 806a5f3feb2180b97418bbb4cf49291caf33b23b Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 13 Nov 2017 16:15:42 +0100
> Subject: [PATCH 05/14] lib: Avoid a pointless static variable
> 
> Saves a few bytes of .text
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  lib/util/util_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/util/util_net.c b/lib/util/util_net.c
> index cbc836cc54c..b3ed9f262fe 100644
> --- a/lib/util/util_net.c
> +++ b/lib/util/util_net.c
> @@ -44,7 +44,7 @@ void zero_sockaddr(struct sockaddr_storage *pss)
>  static char *normalize_ipv6_literal(const char *str, char *buf, size_t *_len)
>  {
>  #define IPv6_LITERAL_NET ".ipv6-literal.net"
> -	static const size_t llen = sizeof(IPv6_LITERAL_NET) - 1;
> +	const size_t llen = sizeof(IPv6_LITERAL_NET) - 1;
>  	size_t len = *_len;
>  	int cmp;
>  	size_t i;
> -- 
> 2.11.0
> 
> 
> From 0a98feb94329f5476c806eb4eba6eab77e746d21 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 13 Nov 2017 16:54:09 +0100
> Subject: [PATCH 06/14] lib: Simplify is_ipaddress_v6
> 
> Do an early return, avoid an "else", avoid an indentation level
> 
> Review with git show -b
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  lib/util/util_net.c | 107 ++++++++++++++++++++++++++--------------------------
>  1 file changed, 53 insertions(+), 54 deletions(-)
> 
> diff --git a/lib/util/util_net.c b/lib/util/util_net.c
> index b3ed9f262fe..d52d401e4c7 100644
> --- a/lib/util/util_net.c
> +++ b/lib/util/util_net.c
> @@ -490,76 +490,75 @@ bool is_ipaddress_v6(const char *str)
>  #if defined(HAVE_IPV6)
>  	int ret = -1;
>  	char *p = NULL;
> +	char buf[INET6_ADDRSTRLEN] = { 0, };
> +	size_t len;
> +	const char *addr = str;
> +	const char *idxs = NULL;
> +	unsigned int idx = 0;
> +	struct in6_addr ip6;
>  
>  	p = strchr_m(str, ':');
>  	if (p == NULL) {
>  		return is_ipv6_literal(str);
> -	} else {
> -		char buf[INET6_ADDRSTRLEN] = { 0, };
> -		size_t len;
> -		const char *addr = str;
> -		const char *idxs = NULL;
> -		unsigned int idx = 0;
> -		struct in6_addr ip6;
> -
> -		p = strchr_m(str, SCOPE_DELIMITER);
> -		if (p && (p > str)) {
> -			len = PTR_DIFF(p, str);
> -			idxs = p + 1;
> -		} else {
> -			len = strlen(str);
> -		}
> +	}
>  
> -		if (len >= sizeof(buf)) {
> -			return false;
> -		}
> -		if (idxs != NULL) {
> -			strncpy(buf, str, len);
> -			addr = buf;
> -		}
> +	p = strchr_m(str, SCOPE_DELIMITER);
> +	if (p && (p > str)) {
> +		len = PTR_DIFF(p, str);
> +		idxs = p + 1;
> +	} else {
> +		len = strlen(str);
> +	}
>  
> -		/*
> -		 * Cope with link-local.
> -		 * This is IP:v6:addr%ifidx.
> -		 */
> -		if (idxs != NULL) {
> -			char c;
> +	if (len >= sizeof(buf)) {
> +		return false;
> +	}
> +	if (idxs != NULL) {
> +		strncpy(buf, str, len);
> +		addr = buf;
> +	}
>  
> -			ret = sscanf(idxs, "%5u%c", &idx, &c);
> -			if (ret != 1) {
> -				idx = 0;
> -			}
> +	/*
> +	 * Cope with link-local.
> +	 * This is IP:v6:addr%ifidx.
> +	 */
> +	if (idxs != NULL) {
> +		char c;
>  
> -			if (idx > 0 && idx < UINT16_MAX) {
> -				/* a valid index */
> -				idxs = NULL;
> -			}
> +		ret = sscanf(idxs, "%5u%c", &idx, &c);
> +		if (ret != 1) {
> +			idx = 0;
>  		}
>  
> -		/*
> -		 * Cope with link-local.
> -		 * This is IP:v6:addr%ifname.
> -		 */
> -		if (idxs != NULL) {
> -			idx = if_nametoindex(idxs);
> -
> -			if (idx > 0) {
> -				/* a valid index */
> -				idxs = NULL;
> -			}
> +		if (idx > 0 && idx < UINT16_MAX) {
> +			/* a valid index */
> +			idxs = NULL;
>  		}
> +	}
>  
> -		if (idxs != NULL) {
> -			return false;
> -		}
> +	/*
> +	 * Cope with link-local.
> +	 * This is IP:v6:addr%ifname.
> +	 */
> +	if (idxs != NULL) {
> +		idx = if_nametoindex(idxs);
>  
> -		ret = inet_pton(AF_INET6, addr, &ip6);
> -		if (ret <= 0) {
> -			return false;
> +		if (idx > 0) {
> +			/* a valid index */
> +			idxs = NULL;
>  		}
> +	}
>  
> -		return true;
> +	if (idxs != NULL) {
> +		return false;
> +	}
> +
> +	ret = inet_pton(AF_INET6, addr, &ip6);
> +	if (ret <= 0) {
> +		return false;
>  	}
> +
> +	return true;
>  #endif
>  	return false;
>  }
> -- 
> 2.11.0
> 
> 
> From f5277a184303dc5ec84cfb94173c3ba3dd7d38f4 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 13 Nov 2017 16:21:31 +0100
> Subject: [PATCH 07/14] lib: Fix a false/NULL hickup
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  lib/util/util_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/util/util_net.c b/lib/util/util_net.c
> index d52d401e4c7..57db4fae4d8 100644
> --- a/lib/util/util_net.c
> +++ b/lib/util/util_net.c
> @@ -53,7 +53,7 @@ static char *normalize_ipv6_literal(const char *str, char *buf, size_t *_len)
>  	size_t cnt_chars = 0;
>  
>  	if (len <= llen) {
> -		return false;
> +		return NULL;
>  	}
>  
>  	/* ignore a trailing '.' */
> -- 
> 2.11.0
> 
> 
> From 5bd746cf6ebc34ee6682172cf23209164dd7f974 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Wed, 15 Nov 2017 13:12:05 +0100
> Subject: [PATCH 08/14] lib: Save a few bytes of .text
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  lib/util/util_net.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/lib/util/util_net.c b/lib/util/util_net.c
> index 57db4fae4d8..f0a30168342 100644
> --- a/lib/util/util_net.c
> +++ b/lib/util/util_net.c
> @@ -36,9 +36,8 @@
>  
>  void zero_sockaddr(struct sockaddr_storage *pss)
>  {
> -	ZERO_STRUCTP(pss);
>  	/* Ensure we're at least a valid sockaddr-storage. */
> -	pss->ss_family = AF_INET;
> +	*pss = (struct sockaddr_storage) { .ss_family = AF_INET };
>  }
>  
>  static char *normalize_ipv6_literal(const char *str, char *buf, size_t *_len)
> -- 
> 2.11.0
> 
> 
> From d6645859cbd626df512fbf564196c5f3bf24c4c9 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Thu, 13 Jul 2017 15:52:15 +0200
> Subject: [PATCH 09/14] libwbclient: Fix two signed/unsigned hickups
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  nsswitch/libwbclient/wbc_pam.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/nsswitch/libwbclient/wbc_pam.c b/nsswitch/libwbclient/wbc_pam.c
> index cb2d5a0f4c4..c31220ae7eb 100644
> --- a/nsswitch/libwbclient/wbc_pam.c
> +++ b/nsswitch/libwbclient/wbc_pam.c
> @@ -727,7 +727,7 @@ wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx,
>  	struct winbindd_request request;
>  	struct winbindd_response response;
>  	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
> -	int i;
> +	size_t i;
>  
>  	/* validate input */
>  
> @@ -1269,7 +1269,7 @@ wbcErr wbcCtxCredentialCache(struct wbcContext *ctx,
>  	struct winbindd_response response;
>  	struct wbcNamedBlob *initial_blob = NULL;
>  	struct wbcNamedBlob *challenge_blob = NULL;
> -	int i;
> +	size_t i;
>  
>  	ZERO_STRUCT(request);
>  	ZERO_STRUCT(response);
> -- 
> 2.11.0
> 
> 
> From e560858393b32cdf532753efeaae0fe4cc47189a Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 15 Jul 2017 10:52:17 +0200
> Subject: [PATCH 10/14] ntlm_auth: Use libwbclient in winbind_separator()
> 
> Avoid direct winbindd_request_response()
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/utils/ntlm_auth.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
> index 5a10e27719f..faba67c3b29 100644
> --- a/source3/utils/ntlm_auth.c
> +++ b/source3/utils/ntlm_auth.c
> @@ -280,24 +280,24 @@ static void gensec_want_feature_list(struct gensec_security *state, char* featur
>  
>  static char winbind_separator(void)
>  {
> -	struct winbindd_response response;
> +	struct wbcInterfaceDetails *details;
> +	wbcErr ret;
>  	static bool got_sep;
>  	static char sep;
>  
>  	if (got_sep)
>  		return sep;
>  
> -	ZERO_STRUCT(response);
> -
> -	/* Send off request */
> -
> -	if (winbindd_request_response(NULL, WINBINDD_INFO, NULL, &response) !=
> -	    NSS_STATUS_SUCCESS) {
> +	ret = wbcInterfaceDetails(&details);
> +	if (!WBC_ERROR_IS_OK(ret)) {
>  		d_fprintf(stderr, "could not obtain winbind separator!\n");
>  		return *lp_winbind_separator();
>  	}
>  
> -	sep = response.data.info.winbind_separator;
> +	sep = details->winbind_separator;
> +
> +	wbcFreeMemory(details);
> +
>  	got_sep = True;
>  
>  	if (!sep) {
> -- 
> 2.11.0
> 
> 
> From 0a7c6863433530f7d55319883d4fcb200aaaa954 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 15 Jul 2017 10:55:09 +0200
> Subject: [PATCH 11/14] ntlm_auth: Use libwbclient in get_winbind_domain()
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/utils/ntlm_auth.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
> index faba67c3b29..932f91c22ad 100644
> --- a/source3/utils/ntlm_auth.c
> +++ b/source3/utils/ntlm_auth.c
> @@ -310,24 +310,25 @@ static char winbind_separator(void)
>  
>  const char *get_winbind_domain(void)
>  {
> -	struct winbindd_response response;
> +	struct wbcInterfaceDetails *details;
> +	wbcErr ret;
>  
>  	static fstring winbind_domain;
>  	if (*winbind_domain) {
>  		return winbind_domain;
>  	}
>  
> -	ZERO_STRUCT(response);
> -
>  	/* Send off request */
>  
> -	if (winbindd_request_response(NULL, WINBINDD_DOMAIN_NAME, NULL, &response) !=
> -	    NSS_STATUS_SUCCESS) {
> +	ret = wbcInterfaceDetails(&details);
> +	if (!WBC_ERROR_IS_OK(ret)) {
>  		DEBUG(1, ("could not obtain winbind domain name!\n"));
>  		return lp_workgroup();
>  	}
>  
> -	fstrcpy(winbind_domain, response.data.domain_name);
> +	fstrcpy(winbind_domain, details->netbios_domain);
> +
> +	wbcFreeMemory(details);
>  
>  	return winbind_domain;
>  
> -- 
> 2.11.0
> 
> 
> From 92f5862cb2b67995dd020d373e29a16e37f1cf6f Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 15 Jul 2017 11:06:38 +0200
> Subject: [PATCH 12/14] ntlm_auth: Use libwbclient in
>  get_require_membership_sid()
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/utils/ntlm_auth.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
> index 932f91c22ad..c0e1c2a6525 100644
> --- a/source3/utils/ntlm_auth.c
> +++ b/source3/utils/ntlm_auth.c
> @@ -392,8 +392,10 @@ static bool parse_ntlm_auth_domain_user(const char *domuser, fstring domain,
>  }
>  
>  static bool get_require_membership_sid(void) {
> -	struct winbindd_request request;
> -	struct winbindd_response response;
> +	fstring domain, name, sidbuf;
> +	struct wbcDomainSid sid;
> +	enum wbcSidType type;
> +	wbcErr ret;
>  
>  	if (!require_membership_of) {
>  		return True;
> @@ -405,25 +407,23 @@ static bool get_require_membership_sid(void) {
>  
>  	/* Otherwise, ask winbindd for the name->sid request */
>  
> -	ZERO_STRUCT(request);
> -	ZERO_STRUCT(response);
> -
> -	if (!parse_ntlm_auth_domain_user(require_membership_of, 
> -					 request.data.name.dom_name, 
> -					 request.data.name.name)) {
> +	if (!parse_ntlm_auth_domain_user(require_membership_of,
> +					 domain, name)) {
>  		DEBUG(0, ("Could not parse %s into separate domain/name parts!\n",
>  			  require_membership_of));
>  		return False;
>  	}
>  
> -	if (winbindd_request_response(NULL, WINBINDD_LOOKUPNAME, &request, &response) !=
> -	    NSS_STATUS_SUCCESS) {
> +	ret = wbcLookupName(domain, name, &sid, &type);
> +	if (!WBC_ERROR_IS_OK(ret)) {
>  		DEBUG(0, ("Winbindd lookupname failed to resolve %s into a SID!\n", 
>  			  require_membership_of));
>  		return False;
>  	}
>  
> -	require_membership_of_sid = SMB_STRDUP(response.data.sid.sid);
> +	wbcSidToStringBuf(&sid, sidbuf, sizeof(sidbuf));
> +
> +	require_membership_of_sid = SMB_STRDUP(sidbuf);
>  
>  	if (require_membership_of_sid)
>  		return True;
> -- 
> 2.11.0
> 
> 
> From 1629470e6fbbc0cc8ba97cc329ad9b642ec9686b Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 15 Jul 2017 10:56:47 +0200
> Subject: [PATCH 13/14] ntlm_auth: Use libwbclient in
>  get_winbind_netbios_name()
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/utils/ntlm_auth.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
> index c0e1c2a6525..3f544902a24 100644
> --- a/source3/utils/ntlm_auth.c
> +++ b/source3/utils/ntlm_auth.c
> @@ -336,7 +336,8 @@ const char *get_winbind_domain(void)
>  
>  const char *get_winbind_netbios_name(void)
>  {
> -	struct winbindd_response response;
> +	struct wbcInterfaceDetails *details;
> +	wbcErr ret;
>  
>  	static fstring winbind_netbios_name;
>  
> @@ -344,17 +345,17 @@ const char *get_winbind_netbios_name(void)
>  		return winbind_netbios_name;
>  	}
>  
> -	ZERO_STRUCT(response);
> -
>  	/* Send off request */
>  
> -	if (winbindd_request_response(NULL, WINBINDD_NETBIOS_NAME, NULL, &response) !=
> -	    NSS_STATUS_SUCCESS) {
> +	ret = wbcInterfaceDetails(&details);
> +	if (!WBC_ERROR_IS_OK(ret)) {
>  		DEBUG(1, ("could not obtain winbind netbios name!\n"));
>  		return lp_netbios_name();
>  	}
>  
> -	fstrcpy(winbind_netbios_name, response.data.netbios_name);
> +	fstrcpy(winbind_netbios_name, details->netbios_name);
> +
> +	wbcFreeMemory(details);
>  
>  	return winbind_netbios_name;
>  
> -- 
> 2.11.0
> 
> 
> From dc820f02db4649a68f590106b745fe55759b40df Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 15 Jul 2017 11:54:14 +0200
> Subject: [PATCH 14/14] nsswitch: Slightly simplify winbindd_request_response
> 
> We don't need a separate variable, C passes a copy on the stack
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  nsswitch/wb_common.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/nsswitch/wb_common.c b/nsswitch/wb_common.c
> index 262181a3cff..d6746b4f535 100644
> --- a/nsswitch/wb_common.c
> +++ b/nsswitch/wb_common.c
> @@ -719,16 +719,15 @@ NSS_STATUS winbindd_request_response(struct winbindd_context *ctx,
>  				     struct winbindd_response *response)
>  {
>  	NSS_STATUS status = NSS_STATUS_UNAVAIL;
> -	struct winbindd_context *wb_ctx = ctx;
>  
>  	if (ctx == NULL) {
> -		wb_ctx = &wb_global_ctx;
> +		ctx = &wb_global_ctx;
>  	}
>  
> -	status = winbindd_send_request(wb_ctx, req_type, 0, request);
> +	status = winbindd_send_request(ctx, req_type, 0, request);
>  	if (status != NSS_STATUS_SUCCESS)
>  		return (status);
> -	status = winbindd_get_response(wb_ctx, response);
> +	status = winbindd_get_response(ctx, response);
>  
>  	return status;
>  }
> @@ -739,16 +738,15 @@ NSS_STATUS winbindd_priv_request_response(struct winbindd_context *ctx,
>  					  struct winbindd_response *response)
>  {
>  	NSS_STATUS status = NSS_STATUS_UNAVAIL;
> -	struct winbindd_context *wb_ctx = ctx;
>  
>  	if (ctx == NULL) {
> -		wb_ctx = &wb_global_ctx;
> +		ctx = &wb_global_ctx;
>  	}
>  
> -	status = winbindd_send_request(wb_ctx, req_type, 1, request);
> +	status = winbindd_send_request(ctx, req_type, 1, request);
>  	if (status != NSS_STATUS_SUCCESS)
>  		return (status);
> -	status = winbindd_get_response(wb_ctx, response);
> +	status = winbindd_get_response(ctx, response);
>  
>  	return status;
>  }
> -- 
> 2.11.0
> 




More information about the samba-technical mailing list