From 3bb5b158017d5bad82bfb4a9e29187549e665446 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 8 Aug 2006 15:33:09 +0000 Subject: r17459: As by Jerry's word commit this without his review. This patch add some missing async functions to solve UID/GID -> SID requests not just out of the cache, but down the remote idmap if necessary. This patch solves the problem of servers not showing users/groups names for allocated UID/GIDs when joined to a group of servers that share a prepopulated idmap backend. Also correctly resolve UID/GIDs to SIDs when looking ACLs from the windows security tab on teh same situation. Simo. (This used to be commit b8578bfab6a04fcd65a2e65f507067459e326077) --- source3/nsswitch/winbindd_user.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'source3/nsswitch/winbindd_user.c') diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c index 8a0ebbafa5..f08efa044f 100644 --- a/source3/nsswitch/winbindd_user.c +++ b/source3/nsswitch/winbindd_user.c @@ -380,15 +380,32 @@ static void getpwnam_name2sid_recv(void *private_data, BOOL success, winbindd_getpwsid(state, sid); } -/* Return a password structure given a uid number */ +static void getpwuid_recv(void *private_data, BOOL success, const char *sid) +{ + struct winbindd_cli_state *state = private_data; + DOM_SID user_sid; + + if (!success) { + DEBUG(10,("uid2sid_recv: uid [%lu] to sid mapping failed\n.", + (unsigned long)(state->request.data.uid))); + request_error(state); + return; + } + + DEBUG(10,("uid2sid_recv: uid %lu has sid %s\n", + (unsigned long)(state->request.data.uid), sid)); + string_to_sid(&user_sid, sid); + winbindd_getpwsid(state, &user_sid); +} + +/* Return a password structure given a uid number */ void winbindd_getpwuid(struct winbindd_cli_state *state) { DOM_SID user_sid; NTSTATUS status; /* Bug out if the uid isn't in the winbind range */ - if ((state->request.data.uid < server_state.uid_low ) || (state->request.data.uid > server_state.uid_high)) { request_error(state); @@ -401,14 +418,15 @@ void winbindd_getpwuid(struct winbindd_cli_state *state) status = idmap_uid_to_sid(&user_sid, state->request.data.uid, IDMAP_FLAG_QUERY_ONLY | IDMAP_FLAG_CACHE_ONLY); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(5, ("Could not find SID for uid %lu\n", - (unsigned long)state->request.data.uid)); - request_error(state); + if (NT_STATUS_IS_OK(status)) { + winbindd_getpwsid(state, &user_sid); return; } - winbindd_getpwsid(state, &user_sid); + DEBUG(10,("Could not find SID for uid %lu in the cache. Querying idmap backend\n", + (unsigned long)state->request.data.uid)); + + winbindd_uid2sid_async(state->mem_ctx, state->request.data.uid, getpwuid_recv, state); } /* -- cgit