]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbind: Improve logging in winbindd_getusersids.c
authorPavel Filipenský <pfilipen@redhat.com>
Thu, 5 Aug 2021 13:17:57 +0000 (15:17 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 15 Jul 2022 14:25:38 +0000 (14:25 +0000)
Test scenario:

$ bin/wbinfo --user-sids `bin/wbinfo -n ADDOMAIN/alice | awk '{print $1}'`
S-1-5-21-2018381343-4210792308-1157936888-1107
S-1-5-21-2018381343-4210792308-1157936888-513
S-1-5-32-545

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/winbindd/winbindd_getusersids.c

index c2347473f5f3cf793d5065e0e55f0e37acf2f2f0..6a839ab9c9b26696ca8ce7190578d4dbef945446 100644 (file)
@@ -46,14 +46,16 @@ struct tevent_req *winbindd_getusersids_send(TALLOC_CTX *mem_ctx,
        /* Ensure null termination */
        request->data.sid[sizeof(request->data.sid)-1]='\0';
 
-       DBG_NOTICE("[%s (%u)] getusersids %s\n",
-                  cli->client_name,
-                  (unsigned int)cli->pid,
-                  request->data.sid);
+       D_NOTICE("[%s (%u)] Winbind external command GETUSERSIDS start.\n"
+                "sid=%s\n",
+                cli->client_name,
+                (unsigned int)cli->pid,
+                request->data.sid);
 
        if (!string_to_sid(&state->sid, request->data.sid)) {
-               DEBUG(1, ("Could not get convert sid %s from string\n",
-                         request->data.sid));
+               D_WARNING("Returning NT_STATUS_INVALID_PARAMETER.\n"
+                         "Could not get convert sid %s from string\n",
+                         request->data.sid);
                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return tevent_req_post(req, ev);
        }
@@ -78,6 +80,8 @@ static void winbindd_getusersids_done(struct tevent_req *subreq)
                                  &state->sids);
        TALLOC_FREE(subreq);
        if (tevent_req_nterror(req, status)) {
+               D_WARNING("wb_gettoken_recv failed with %s.\n",
+                         nt_errstr(status));
                return;
        }
        tevent_req_done(req);
@@ -90,13 +94,13 @@ NTSTATUS winbindd_getusersids_recv(struct tevent_req *req,
                req, struct winbindd_getusersids_state);
        struct dom_sid_buf sidbuf;
        NTSTATUS status;
-       int i;
+       uint32_t i;
        char *result;
 
        if (tevent_req_is_nterror(req, &status)) {
-               DEBUG(5, ("Could not convert sid %s: %s\n",
+               D_WARNING("Could not convert sid %s: %s\n",
                          dom_sid_str_buf(&state->sid, &sidbuf),
-                         nt_errstr(status)));
+                         nt_errstr(status));
                return status;
        }
 
@@ -105,14 +109,16 @@ NTSTATUS winbindd_getusersids_recv(struct tevent_req *req,
                return NT_STATUS_NO_MEMORY;
        }
 
+       D_NOTICE("Winbind external command GETUSERSIDS end.\n"
+                "Got %u SID(s).\n", state->num_sids);
        for (i=0; i<state->num_sids; i++) {
+               D_NOTICE("%u: %s\n", i, dom_sid_str_buf(&state->sids[i], &sidbuf));
                talloc_asprintf_addbuf(
                        &result,
                        "%s\n",
                        dom_sid_str_buf(&state->sids[i], &sidbuf));
        }
 
-
        response->data.num_entries = state->num_sids;
        response->extra_data.data = result;
        response->length += talloc_get_size(result);