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

libwbclient: Make wbcInterfaceDetails not use talloc

This commit is contained in:
Volker Lendecke 2010-04-03 14:59:07 +02:00
parent b62e57cec2
commit 7f454c3078

View File

@ -43,6 +43,14 @@ wbcErr wbcPing(void)
return wbcRequestResponse(WINBINDD_PING, &request, &response); return wbcRequestResponse(WINBINDD_PING, &request, &response);
} }
static void wbcInterfaceDetailsDestructor(void *ptr)
{
struct wbcInterfaceDetails *i = (struct wbcInterfaceDetails *)ptr;
free(i->winbind_version);
free(i->netbios_name);
free(i->netbios_domain);
free(i->dns_domain);
}
/** /**
* @brief Query useful information about the winbind service * @brief Query useful information about the winbind service
@ -65,7 +73,9 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
ZERO_STRUCT(request); ZERO_STRUCT(request);
ZERO_STRUCT(response); ZERO_STRUCT(response);
info = talloc(NULL, struct wbcInterfaceDetails); info = (struct wbcInterfaceDetails *)wbcAllocateMemory(
sizeof(struct wbcInterfaceDetails), 1,
wbcInterfaceDetailsDestructor);
BAIL_ON_PTR_ERROR(info, wbc_status); BAIL_ON_PTR_ERROR(info, wbc_status);
/* first the interface version */ /* first the interface version */
@ -77,8 +87,7 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
wbc_status = wbcRequestResponse(WINBINDD_INFO, NULL, &response); wbc_status = wbcRequestResponse(WINBINDD_INFO, NULL, &response);
BAIL_ON_WBC_ERROR(wbc_status); BAIL_ON_WBC_ERROR(wbc_status);
info->winbind_version = talloc_strdup(info, info->winbind_version = strdup(response.data.info.samba_version);
response.data.info.samba_version);
BAIL_ON_PTR_ERROR(info->winbind_version, wbc_status); BAIL_ON_PTR_ERROR(info->winbind_version, wbc_status);
info->winbind_separator = response.data.info.winbind_separator; info->winbind_separator = response.data.info.winbind_separator;
@ -86,16 +95,14 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
wbc_status = wbcRequestResponse(WINBINDD_NETBIOS_NAME, NULL, &response); wbc_status = wbcRequestResponse(WINBINDD_NETBIOS_NAME, NULL, &response);
BAIL_ON_WBC_ERROR(wbc_status); BAIL_ON_WBC_ERROR(wbc_status);
info->netbios_name = talloc_strdup(info, info->netbios_name = strdup(response.data.netbios_name);
response.data.netbios_name);
BAIL_ON_PTR_ERROR(info->netbios_name, wbc_status); BAIL_ON_PTR_ERROR(info->netbios_name, wbc_status);
/* then the local workgroup name */ /* then the local workgroup name */
wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_NAME, NULL, &response); wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_NAME, NULL, &response);
BAIL_ON_WBC_ERROR(wbc_status); BAIL_ON_WBC_ERROR(wbc_status);
info->netbios_domain = talloc_strdup(info, info->netbios_domain = strdup(response.data.domain_name);
response.data.domain_name);
BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status); BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status);
wbc_status = wbcDomainInfo(info->netbios_domain, &domain); wbc_status = wbcDomainInfo(info->netbios_domain, &domain);
@ -108,8 +115,7 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
} }
if (domain) { if (domain) {
info->dns_domain = talloc_strdup(info, info->dns_domain = strdup(domain->dns_name);
domain->dns_name);
wbcFreeMemory(domain); wbcFreeMemory(domain);
BAIL_ON_PTR_ERROR(info->dns_domain, wbc_status); BAIL_ON_PTR_ERROR(info->dns_domain, wbc_status);
} else { } else {
@ -122,7 +128,7 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
wbc_status = WBC_ERR_SUCCESS; wbc_status = WBC_ERR_SUCCESS;
done: done:
talloc_free(info); wbcFreeMemory(info);
return wbc_status; return wbc_status;
} }