nsswitch/wbinfo: use wbcRequestResponse() instead of winbindd_request_response()
authorStefan Metzmacher <metze@samba.org>
Mon, 22 Nov 2021 16:59:48 +0000 (17:59 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 30 Nov 2021 15:53:34 +0000 (15:53 +0000)
We should try to route everything through libwbclient.so, because we'll
soon don't have a single library providing winbindd_request_response().

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
nsswitch/wbinfo.c

index 1656f02f0e68e73afb331b625796ed7001480e6c..55b9e268c395807e34378d4a9163c615e81479cd 100644 (file)
@@ -22,8 +22,9 @@
 */
 
 #include "includes.h"
-#include "winbind_client.h"
 #include "libwbclient/wbclient.h"
+#include "winbind_struct_protocol.h"
+#include "libwbclient/wbclient_internal.h"
 #include "../libcli/auth/libcli_auth.h"
 #include "lib/cmdline/cmdline.h"
 #include "lib/afs/afs_settoken.h"
@@ -697,6 +698,7 @@ static bool wbinfo_domain_info(const char *domain)
 /* Get a foreign DC's name */
 static bool wbinfo_getdcname(const char *domain_name)
 {
+       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
        struct winbindd_request request;
        struct winbindd_response response;
 
@@ -707,8 +709,9 @@ static bool wbinfo_getdcname(const char *domain_name)
 
        /* Send request */
 
-       if (winbindd_request_response(NULL, WINBINDD_GETDCNAME, &request,
-                                     &response) != NSS_STATUS_SUCCESS) {
+       wbc_status = wbcRequestResponse(NULL, WINBINDD_GETDCNAME,
+                                       &request, &response);
+       if (!WBC_ERROR_IS_OK(wbc_status)) {
                d_fprintf(stderr, "Could not get dc name for %s\n",domain_name);
                return false;
        }
@@ -2054,9 +2057,9 @@ static bool wbinfo_ccache_save(char *username)
 
 static bool wbinfo_klog(char *username)
 {
+       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
        struct winbindd_request request;
        struct winbindd_response response;
-       NSS_STATUS result;
        char *p;
 
        /* Send off request */
@@ -2081,13 +2084,13 @@ static bool wbinfo_klog(char *username)
 
        request.flags |= WBFLAG_PAM_AFS_TOKEN;
 
-       result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH, &request,
-                                          &response);
+       wbc_status = wbcRequestResponse(NULL, WINBINDD_PAM_AUTH,
+                                       &request, &response);
 
        /* Display response */
 
        d_printf("plaintext password authentication %s\n",
-                (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
+                WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
 
        if (response.data.auth.nt_status)
                d_fprintf(stderr,
@@ -2096,7 +2099,7 @@ static bool wbinfo_klog(char *username)
                         response.data.auth.nt_status,
                         response.data.auth.error_string);
 
-       if (result != NSS_STATUS_SUCCESS)
+       if (!WBC_ERROR_IS_OK(wbc_status))
                return false;
 
        if (response.extra_data.data == NULL) {
@@ -2105,10 +2108,12 @@ static bool wbinfo_klog(char *username)
        }
 
        if (!afs_settoken_str((char *)response.extra_data.data)) {
+               winbindd_free_response(&response);
                d_fprintf(stderr, "Could not set token\n");
                return false;
        }
 
+       winbindd_free_response(&response);
        d_printf("Successfully created AFS token\n");
        return true;
 }