summaryrefslogtreecommitdiff
path: root/nsswitch/libwbclient/wbc_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsswitch/libwbclient/wbc_util.c')
-rw-r--r--nsswitch/libwbclient/wbc_util.c123
1 files changed, 94 insertions, 29 deletions
diff --git a/nsswitch/libwbclient/wbc_util.c b/nsswitch/libwbclient/wbc_util.c
index 4060e2521c1..3dab0a2de1b 100644
--- a/nsswitch/libwbclient/wbc_util.c
+++ b/nsswitch/libwbclient/wbc_util.c
@@ -28,9 +28,11 @@
/** @brief Ping winbindd to see if the daemon is running
*
+ * @param *ctx wbclient Context
+ *
* @return #wbcErr
**/
-wbcErr wbcPing(void)
+wbcErr wbcCtxPing(struct wbcContext *ctx)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -40,7 +42,12 @@ wbcErr wbcPing(void)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- return wbcRequestResponse(WINBINDD_PING, &request, &response);
+ return wbcRequestResponse(ctx, WINBINDD_PING, &request, &response);
+}
+
+wbcErr wbcPing(void)
+{
+ return wbcCtxPing(NULL);
}
static void wbcInterfaceDetailsDestructor(void *ptr)
@@ -60,7 +67,8 @@ static void wbcInterfaceDetailsDestructor(void *ptr)
* @return #wbcErr
*/
-wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
+wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx,
+ struct wbcInterfaceDetails **_details)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcInterfaceDetails *info;
@@ -79,12 +87,13 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
BAIL_ON_PTR_ERROR(info, wbc_status);
/* first the interface version */
- wbc_status = wbcRequestResponse(WINBINDD_INTERFACE_VERSION, NULL, &response);
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_INTERFACE_VERSION,
+ NULL, &response);
BAIL_ON_WBC_ERROR(wbc_status);
info->interface_version = response.data.interface_version;
/* then the samba version and the winbind separator */
- wbc_status = wbcRequestResponse(WINBINDD_INFO, NULL, &response);
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_INFO, NULL, &response);
BAIL_ON_WBC_ERROR(wbc_status);
info->winbind_version = strdup(response.data.info.samba_version);
@@ -92,20 +101,22 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
info->winbind_separator = response.data.info.winbind_separator;
/* then the local netbios name */
- wbc_status = wbcRequestResponse(WINBINDD_NETBIOS_NAME, NULL, &response);
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_NETBIOS_NAME,
+ NULL, &response);
BAIL_ON_WBC_ERROR(wbc_status);
info->netbios_name = strdup(response.data.netbios_name);
BAIL_ON_PTR_ERROR(info->netbios_name, wbc_status);
/* then the local workgroup name */
- wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_NAME, NULL, &response);
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_DOMAIN_NAME,
+ NULL, &response);
BAIL_ON_WBC_ERROR(wbc_status);
info->netbios_domain = strdup(response.data.domain_name);
BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status);
- wbc_status = wbcDomainInfo(info->netbios_domain, &domain);
+ wbc_status = wbcCtxDomainInfo(ctx, info->netbios_domain, &domain);
if (wbc_status == WBC_ERR_DOMAIN_NOT_FOUND) {
/* maybe it's a standalone server */
domain = NULL;
@@ -132,6 +143,11 @@ done:
return wbc_status;
}
+wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
+{
+ return wbcCtxInterfaceDetails(NULL, _details);
+}
+
static void wbcDomainInfoDestructor(void *ptr)
{
struct wbcDomainInfo *i = (struct wbcDomainInfo *)ptr;
@@ -147,7 +163,9 @@ static void wbcDomainInfoDestructor(void *ptr)
* @return #wbcErr
*/
-wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
+wbcErr wbcCtxDomainInfo(struct wbcContext *ctx,
+ const char *domain,
+ struct wbcDomainInfo **dinfo)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -167,7 +185,7 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
strncpy(request.domain_name, domain,
sizeof(request.domain_name)-1);
- wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_INFO,
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_DOMAIN_INFO,
&request,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -203,9 +221,15 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
return wbc_status;
}
+wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
+{
+ return wbcCtxDomainInfo(NULL, domain, dinfo);
+}
+
/* Get the list of current DCs */
-wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
- const char ***dc_names, const char ***dc_ips)
+wbcErr wbcCtxDcInfo(struct wbcContext *ctx,
+ const char *domain, size_t *num_dcs,
+ const char ***dc_names, const char ***dc_ips)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -226,7 +250,7 @@ wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
sizeof(request.domain_name) - 1);
}
- wbc_status = wbcRequestResponse(WINBINDD_DC_INFO,
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_DC_INFO,
&request, &response);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -290,8 +314,15 @@ done:
return wbc_status;
}
+wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
+ const char ***dc_names, const char ***dc_ips)
+{
+ return wbcCtxDcInfo(NULL, domain, num_dcs, dc_names, dc_ips);
+}
+
/* Resolve a NetbiosName via WINS */
-wbcErr wbcResolveWinsByName(const char *name, char **ip)
+wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx,
+ const char *name, char **ip)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -306,7 +337,7 @@ wbcErr wbcResolveWinsByName(const char *name, char **ip)
strncpy(request.data.winsreq, name,
sizeof(request.data.winsreq)-1);
- wbc_status = wbcRequestResponse(WINBINDD_WINS_BYNAME,
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYNAME,
&request,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -323,8 +354,14 @@ wbcErr wbcResolveWinsByName(const char *name, char **ip)
return wbc_status;
}
+wbcErr wbcResolveWinsByName(const char *name, char **ip)
+{
+ return wbcCtxResolveWinsByName(NULL, name, ip);
+}
+
/* Resolve an IP address via WINS into a NetbiosName */
-wbcErr wbcResolveWinsByIP(const char *ip, char **name)
+wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx,
+ const char *ip, char **name)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -339,7 +376,7 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name)
strncpy(request.data.winsreq, ip,
sizeof(request.data.winsreq)-1);
- wbc_status = wbcRequestResponse(WINBINDD_WINS_BYIP,
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYIP,
&request,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -356,6 +393,11 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name)
return wbc_status;
}
+wbcErr wbcResolveWinsByIP(const char *ip, char **name)
+{
+ return wbcCtxResolveWinsByIP(NULL, ip, name);
+}
+
/**
*/
@@ -489,7 +531,8 @@ static void wbcDomainInfoListDestructor(void *ptr)
}
/* Enumerate the domain trusts known by Winbind */
-wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
+wbcErr wbcCtxListTrusts(struct wbcContext *ctx,
+ struct wbcDomainInfo **domains, size_t *num_domains)
{
struct winbindd_response response;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
@@ -505,7 +548,7 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
/* Send request */
- wbc_status = wbcRequestResponse(WINBINDD_LIST_TRUSTDOM,
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_TRUSTDOM,
NULL,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -559,6 +602,11 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
return wbc_status;
}
+wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
+{
+ return wbcCtxListTrusts(NULL, domains, num_domains);
+}
+
static void wbcDomainControllerInfoDestructor(void *ptr)
{
struct wbcDomainControllerInfo *i =
@@ -567,9 +615,9 @@ static void wbcDomainControllerInfoDestructor(void *ptr)
}
/* Enumerate the domain trusts known by Winbind */
-wbcErr wbcLookupDomainController(const char *domain,
- uint32_t flags,
- struct wbcDomainControllerInfo **dc_info)
+wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx,
+ const char *domain, uint32_t flags,
+ struct wbcDomainControllerInfo **dc_info)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct winbindd_request request;
@@ -598,7 +646,7 @@ wbcErr wbcLookupDomainController(const char *domain,
/* Send request */
- wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME,
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_DSGETDCNAME,
&request,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -614,6 +662,12 @@ done:
return wbc_status;
}
+wbcErr wbcLookupDomainController(const char *domain, uint32_t flags,
+ struct wbcDomainControllerInfo **dc_info)
+{
+ return wbcCtxLookupDomainController(NULL, domain, flags, dc_info);
+}
+
static void wbcDomainControllerInfoExDestructor(void *ptr)
{
struct wbcDomainControllerInfoEx *i =
@@ -688,11 +742,12 @@ done:
}
/* Get extended domain controller information */
-wbcErr wbcLookupDomainControllerEx(const char *domain,
- struct wbcGuid *guid,
- const char *site,
- uint32_t flags,
- struct wbcDomainControllerInfoEx **dc_info)
+wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx,
+ const char *domain,
+ struct wbcGuid *guid,
+ const char *site,
+ uint32_t flags,
+ struct wbcDomainControllerInfoEx **dc_info)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct winbindd_request request;
@@ -732,7 +787,7 @@ wbcErr wbcLookupDomainControllerEx(const char *domain,
/* Send request */
- wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME,
+ wbc_status = wbcRequestResponse(ctx, WINBINDD_DSGETDCNAME,
&request,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -748,6 +803,16 @@ done:
return wbc_status;
}
+wbcErr wbcLookupDomainControllerEx(const char *domain,
+ struct wbcGuid *guid,
+ const char *site,
+ uint32_t flags,
+ struct wbcDomainControllerInfoEx **dc_info)
+{
+ return wbcCtxLookupDomainControllerEx(NULL, domain, guid, site,
+ flags, dc_info);
+}
+
static void wbcNamedBlobDestructor(void *ptr)
{
struct wbcNamedBlob *b = (struct wbcNamedBlob *)ptr;