diff options
Diffstat (limited to 'source3/nsswitch/wbinfo.c')
| -rw-r--r-- | source3/nsswitch/wbinfo.c | 198 | 
1 files changed, 78 insertions, 120 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index ba358bd1dd..8aa4e5f15f 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -297,52 +297,42 @@ static bool wbinfo_get_userdomgroups(const char *user_sid_str)  /* Convert NetBIOS name to IP */ -static bool wbinfo_wins_byname(char *name) +static bool wbinfo_wins_byname(const char *name)  { -	struct winbindd_request request; -	struct winbindd_response response; - -	ZERO_STRUCT(request); -	ZERO_STRUCT(response); - -	/* Send request */ - -	fstrcpy(request.data.winsreq, name); +	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; +	char *ip = NULL; -	if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) != -	    NSS_STATUS_SUCCESS) { +	wbc_status = wbcResolveWinsByName(name, &ip); +	if (!WBC_ERROR_IS_OK(wbc_status)) {  		return false;  	}  	/* Display response */ -	d_printf("%s\n", response.data.winsresp); +	d_printf("%s\n", ip); + +	wbcFreeMemory(ip);  	return true;  }  /* Convert IP to NetBIOS name */ -static bool wbinfo_wins_byip(char *ip) +static bool wbinfo_wins_byip(const char *ip)  { -	struct winbindd_request request; -	struct winbindd_response response; - -	ZERO_STRUCT(request); -	ZERO_STRUCT(response); - -	/* Send request */ - -	fstrcpy(request.data.winsreq, ip); +	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; +	char *name = NULL; -	if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) != -	    NSS_STATUS_SUCCESS) { +	wbc_status = wbcResolveWinsByIP(ip, &name); +	if (!WBC_ERROR_IS_OK(wbc_status)) {  		return false;  	}  	/* Display response */ -	d_printf("%s\n", response.data.winsresp); +	d_printf("%s\n", name); + +	wbcFreeMemory(name);  	return true;  } @@ -351,101 +341,67 @@ static bool wbinfo_wins_byip(char *ip)  static bool wbinfo_list_domains(bool list_all_domains, bool verbose)  { -	struct winbindd_request request; -	struct winbindd_response response; - +	struct wbcDomainInfo *domain_list = NULL; +	size_t num_domains; +	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;  	bool print_all = !list_all_domains && verbose; +	int i; -	ZERO_STRUCT(request); -	ZERO_STRUCT(response); - -	/* Send request */ - -	request.data.list_all_domains = list_all_domains; - -	if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, &request, &response) != -	    NSS_STATUS_SUCCESS) +	wbc_status = wbcListTrusts(&domain_list, &num_domains); +	if (!WBC_ERROR_IS_OK(wbc_status)) {  		return false; +	} -	/* Display response */ +	if (print_all) { +		d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",  +			 "Domain Name", "DNS Domain", "Trust Type",  +			 "Transitive", "In", "Out"); +	} -	if (response.extra_data.data) { -		const char *extra_data = (char *)response.extra_data.data; -		char *name; -		char *beg, *end; -		TALLOC_CTX *frame = talloc_stackframe(); +	for (i=0; i<num_domains; i++) { +		d_printf("%-16s", domain_list[i].short_name); -		if (print_all) { -			d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",  -				 "Domain Name", "DNS Domain", "Trust Type",  -				 "Transitive", "In", "Out"); +		if (!print_all) { +			d_printf("\n");	 +			continue;  		} -		while(next_token_talloc(frame,&extra_data,&name,"\n")) { -			/* Print Domain Name */ -			if ((beg = strchr(name, '\\')) == NULL) -				goto error; -			*beg = 0; -			beg++; -			if ((end = strchr(beg, '\\')) == NULL) -				goto error; -			*end = 0; - -			/* Print short name */ +		d_printf("%-24s", domain_list[i].dns_name); -			d_printf("%-16s", name); - -			if (!print_all) { -				d_printf("\n");	 -				continue; -			} +		switch(domain_list[i].trust_type) { +		case WBC_DOMINFO_TRUSTTYPE_NONE: +			d_printf("None        "); +			break; +		case WBC_DOMINFO_TRUSTTYPE_FOREST:		 +			d_printf("Forest      "); +			break; +		case WBC_DOMINFO_TRUSTTYPE_EXTERNAL:		 +			d_printf("External    "); +			break; +		case WBC_DOMINFO_TRUSTTYPE_IN_FOREST: +			d_printf("In-Forest   "); +			break; +		} -			/* Print DNS domain */ +		if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_TRANSITIVE) { +			d_printf("Yes         "); +		} else { +			d_printf("No          "); +		} -			if (beg) { -				d_printf("%-24s", beg); -			} +		if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_INCOMING) { +			d_printf("Yes  "); +		} else { +			d_printf("No   "); +		} -			/* Skip SID */ -			beg = ++end; -			if ((end = strchr(beg, '\\')) == NULL) -				goto error; - -			/* Print Trust Type */ -			beg = ++end; -			if ((end = strchr(beg, '\\')) == NULL) -				goto error; -			*end = 0; -			d_printf("%-12s", beg); - -			/* Print Transitive */ -			beg = ++end; -			if ((end = strchr(beg, '\\')) == NULL) -				goto error; -			*end = 0; -			d_printf("%-12s", beg); - -			/* Print Incoming */ -			beg = ++end; -			if ((end = strchr(beg, '\\')) == NULL) -				goto error; -			*end = 0; -			d_printf("%-5s", beg); - -			/* Print Outgoing */ -			beg = ++end; -			d_printf("%-5s\n", beg); +		if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_OUTGOING) { +			d_printf("Yes  "); +		} else { +			d_printf("No   ");  		} -		goto out; -error: -		d_fprintf(stderr, "Got invalid response: %s\n", extra_data); -		TALLOC_FREE(frame); -		SAFE_FREE(response.extra_data.data); -		return false; -out: -		TALLOC_FREE(frame); -		SAFE_FREE(response.extra_data.data); +		d_printf("\n");  	}  	return true; @@ -529,12 +485,12 @@ static bool wbinfo_domain_info(const char *domain)  	d_printf("SID               : %s\n", sid_str);  	d_printf("Active Directory  : %s\n", -		 (dinfo->flags & WBC_DOMINFO_AD) ? "Yes" : "No"); +		 (dinfo->domain_flags & WBC_DOMINFO_AD) ? "Yes" : "No");  	d_printf("Native            : %s\n", -		 (dinfo->flags & WBC_DOMINFO_NATIVE) ? "Yes" : "No"); +		 (dinfo->domain_flags & WBC_DOMINFO_NATIVE) ? "Yes" : "No");  	d_printf("Primary           : %s\n", -		 (dinfo->flags & WBC_DOMINFO_PRIMARY) ? "Yes" : "No"); +		 (dinfo->domain_flags & WBC_DOMINFO_PRIMARY) ? "Yes" : "No");  	wbcFreeMemory(sid_str);  	wbcFreeMemory(dinfo); @@ -601,22 +557,24 @@ static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)  static bool wbinfo_check_secret(void)  { -	struct winbindd_response response; -	NSS_STATUS result; - -	ZERO_STRUCT(response); +	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; +	struct wbcAuthErrorInfo *error = NULL; -	result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response); +	wbc_status = wbcCheckTrustCredentials(NULL, &error);  	d_printf("checking the trust secret via RPC calls %s\n", -		 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); +		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed"); -	if (result != NSS_STATUS_SUCCESS) +	if (wbc_status == WBC_ERR_AUTH_ERROR) {  		d_fprintf(stderr, "error code was %s (0x%x)\n", -		 	 response.data.auth.nt_status_string, -		 	 response.data.auth.nt_status); +			  error->nt_string, error->nt_status); +		wbcFreeMemory(error); +	} +	if (!WBC_ERROR_IS_OK(wbc_status)) { +		return false; +	} -	return result == NSS_STATUS_SUCCESS;	 +	return true;  }  /* Convert uid to sid */  | 
