The branch, master has been updated via 1d8d3fd7c3c2e6c46a3e01983dc26a5a650f6f84 (commit) via 5a1240deac89b1821c987c3daed5a6ad597471f5 (commit) via c4a95f900a64649527a0a299eb52c352c51a2ae7 (commit) via 94948f7a401df781ad64090a804a894cf2976a86 (commit) via 2f16bf54452ba6ef5fc2ad1c031b62ec8454a26b (commit) via f3d71d3e8c1e9c98df38ef5f8c547ff2780e9cfb (commit) via 3532c8b9d831c8122de871db62d17608ff24f409 (commit) from 3f0c8772f15517134ef2c5805119f197aa1f69ed (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 1d8d3fd7c3c2e6c46a3e01983dc26a5a650f6f84 Author: Volker Lendecke <v...@samba.org> Date: Thu Aug 27 14:55:41 2009 +0200 s3:winbind: Convert WINBINDD_GETUSERSIDS to the new API commit 5a1240deac89b1821c987c3daed5a6ad597471f5 Author: Volker Lendecke <v...@samba.org> Date: Thu Aug 27 14:34:59 2009 +0200 s3:winbind: Fix a typo commit c4a95f900a64649527a0a299eb52c352c51a2ae7 Author: Volker Lendecke <v...@samba.org> Date: Thu Aug 27 14:16:22 2009 +0200 s3:winbind: Remove the manual caching for the async wb_ functions The generic NDR-based cache in winbindd_dual_ndr.c replaces this. commit 94948f7a401df781ad64090a804a894cf2976a86 Author: Volker Lendecke <v...@samba.org> Date: Tue Aug 25 12:25:12 2009 +0200 s3:winbind: Some calls are not cacheable commit 2f16bf54452ba6ef5fc2ad1c031b62ec8454a26b Author: Volker Lendecke <v...@samba.org> Date: Tue Aug 25 11:26:14 2009 +0200 s3:winbind: Factor out wcache_store_seqnum() commit f3d71d3e8c1e9c98df38ef5f8c547ff2780e9cfb Author: Volker Lendecke <v...@samba.org> Date: Mon Aug 24 00:13:02 2009 +0200 s3:winbind: Add a generic cache for NDR based parent-child requests commit 3532c8b9d831c8122de871db62d17608ff24f409 Author: Volker Lendecke <v...@samba.org> Date: Mon Aug 24 00:08:14 2009 +0200 s3:winbind: Factor out wcache_fetch_seqnum ----------------------------------------------------------------------- Summary of changes: source3/Makefile.in | 1 + source3/winbindd/wb_group_members.c | 31 --- source3/winbindd/wb_lookupname.c | 28 ++- source3/winbindd/wb_lookupsid.c | 11 - source3/winbindd/wb_lookupuseraliases.c | 9 - source3/winbindd/wb_lookupusergroups.c | 9 - source3/winbindd/wb_queryuser.c | 7 - source3/winbindd/winbindd.c | 4 +- source3/winbindd/winbindd_async.c | 165 -------------- source3/winbindd/winbindd_cache.c | 235 +++++++++++++++++--- source3/winbindd/winbindd_domain.c | 2 +- source3/winbindd/winbindd_dual.c | 4 +- source3/winbindd/winbindd_dual_ndr.c | 49 +++-- ...d_getuserdomgroups.c => winbindd_getusersids.c} | 78 ++++---- source3/winbindd/winbindd_group.c | 84 ------- source3/winbindd/winbindd_idmap.c | 2 +- source3/winbindd/winbindd_locator.c | 2 +- source3/winbindd/winbindd_lookupname.c | 2 +- source3/winbindd/winbindd_proto.h | 20 ++- 19 files changed, 313 insertions(+), 430 deletions(-) copy source3/winbindd/{winbindd_getuserdomgroups.c => winbindd_getusersids.c} (51%) Changeset truncated at 500 lines: diff --git a/source3/Makefile.in b/source3/Makefile.in index f1fac93..e53dcb9 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1184,6 +1184,7 @@ WINBINDD_OBJ1 = \ winbindd/winbindd_show_sequence.o \ winbindd/winbindd_getgrgid.o \ winbindd/winbindd_getgrnam.o \ + winbindd/winbindd_getusersids.o \ auth/token_util.o \ ../nsswitch/libwbclient/wb_reqtrans.o \ smbd/connection.o diff --git a/source3/winbindd/wb_group_members.c b/source3/winbindd/wb_group_members.c index 5de4d51..f37641b 100644 --- a/source3/winbindd/wb_group_members.c +++ b/source3/winbindd/wb_group_members.c @@ -52,11 +52,6 @@ static struct tevent_req *wb_lookupgroupmem_send(TALLOC_CTX *mem_ctx, struct tevent_req *req, *subreq; struct wb_lookupgroupmem_state *state; struct winbindd_domain *domain; - uint32_t num_names; - struct dom_sid *sid_mem; - char **names; - uint32_t *name_types; - NTSTATUS status; req = tevent_req_create(mem_ctx, &state, struct wb_lookupgroupmem_state); @@ -71,32 +66,6 @@ static struct tevent_req *wb_lookupgroupmem_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - status = wcache_lookup_groupmem(domain, state, &state->sid, &num_names, - &sid_mem, &names, &name_types); - if (NT_STATUS_IS_OK(status)) { - int i; - state->members.members = talloc_array( - state, struct wbint_GroupMember, num_names); - if (tevent_req_nomem(state->members.members, req)) { - return tevent_req_post(req, ev); - } - state->members.num_members = num_names; - for (i=0; i<num_names; i++) { - struct wbint_GroupMember *m; - const char *name; - m = &state->members.members[i]; - sid_copy(&m->sid, &sid_mem[i]); - name = names[i]; - m->name = talloc_move(state->members.members, &name); - m->type = (enum lsa_SidType)name_types[i]; - } - TALLOC_FREE(sid_mem); - TALLOC_FREE(names); - TALLOC_FREE(name_types); - tevent_req_done(req); - return tevent_req_post(req, ev); - } - subreq = rpccli_wbint_LookupGroupMembers_send( state, ev, domain->child.rpccli, &state->sid, type, &state->members); diff --git a/source3/winbindd/wb_lookupname.c b/source3/winbindd/wb_lookupname.c index 12e1bab..6251d03 100644 --- a/source3/winbindd/wb_lookupname.c +++ b/source3/winbindd/wb_lookupname.c @@ -41,34 +41,36 @@ struct tevent_req *wb_lookupname_send(TALLOC_CTX *mem_ctx, struct tevent_req *req, *subreq; struct wb_lookupname_state *state; struct winbindd_domain *domain; - NTSTATUS status; req = tevent_req_create(mem_ctx, &state, struct wb_lookupname_state); if (req == NULL) { return NULL; } state->ev = ev; - state->dom_name = dom_name; - state->name = name; state->flags = flags; - domain = find_lookup_domain_from_name(dom_name); - if (domain == NULL) { - DEBUG(5, ("Could not find domain for %s\n", dom_name)); - tevent_req_nterror(req, NT_STATUS_NONE_MAPPED); + /* + * Uppercase domain and name so that we become cache-friendly + */ + state->dom_name = talloc_strdup_upper(state, dom_name); + if (tevent_req_nomem(state->dom_name, req)) { + return tevent_req_post(req, ev); + } + state->name = talloc_strdup_upper(state, name); + if (tevent_req_nomem(state->name, req)) { return tevent_req_post(req, ev); } - status = wcache_name_to_sid(domain, dom_name, name, - &state->sid, &state->type); - if (NT_STATUS_IS_OK(status)) { - tevent_req_done(req); + domain = find_lookup_domain_from_name(state->dom_name); + if (domain == NULL) { + DEBUG(5, ("Could not find domain for %s\n", state->dom_name)); + tevent_req_nterror(req, NT_STATUS_NONE_MAPPED); return tevent_req_post(req, ev); } subreq = rpccli_wbint_LookupName_send( - state, ev, domain->child.rpccli, dom_name, name, flags, - &state->type, &state->sid); + state, ev, domain->child.rpccli, state->dom_name, state->name, + flags, &state->type, &state->sid); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } diff --git a/source3/winbindd/wb_lookupsid.c b/source3/winbindd/wb_lookupsid.c index f258828..80e0b80 100644 --- a/source3/winbindd/wb_lookupsid.c +++ b/source3/winbindd/wb_lookupsid.c @@ -38,8 +38,6 @@ struct tevent_req *wb_lookupsid_send(TALLOC_CTX *mem_ctx, { struct tevent_req *req, *subreq; struct wb_lookupsid_state *state; - char *dom_name, *name; - NTSTATUS status; req = tevent_req_create(mem_ctx, &state, struct wb_lookupsid_state); if (req == NULL) { @@ -56,15 +54,6 @@ struct tevent_req *wb_lookupsid_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - status = wcache_sid_to_name(state->lookup_domain, sid, state, - &dom_name, &name, &state->type); - if (NT_STATUS_IS_OK(status)) { - state->domname = dom_name; - state->name = name; - tevent_req_done(req); - return tevent_req_post(req, ev); - } - subreq = rpccli_wbint_LookupSid_send( state, ev, state->lookup_domain->child.rpccli, &state->sid, &state->type, &state->domname, &state->name); diff --git a/source3/winbindd/wb_lookupuseraliases.c b/source3/winbindd/wb_lookupuseraliases.c index e2e5e2d..138eca9 100644 --- a/source3/winbindd/wb_lookupuseraliases.c +++ b/source3/winbindd/wb_lookupuseraliases.c @@ -37,7 +37,6 @@ struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx, { struct tevent_req *req, *subreq; struct wb_lookupuseraliases_state *state; - NTSTATUS status; req = tevent_req_create(mem_ctx, &state, struct wb_lookupuseraliases_state); @@ -47,14 +46,6 @@ struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx, state->sids.num_sids = num_sids; state->sids.sids = CONST_DISCARD(struct dom_sid *, sids); - status = wcache_lookup_useraliases(domain, state, num_sids, sids, - &state->rids.num_rids, - &state->rids.rids); - if (NT_STATUS_IS_OK(status)) { - tevent_req_done(req); - return tevent_req_post(req, ev); - } - subreq = rpccli_wbint_LookupUserAliases_send( state, ev, domain->child.rpccli, &state->sids, &state->rids); if (tevent_req_nomem(subreq, req)) { diff --git a/source3/winbindd/wb_lookupusergroups.c b/source3/winbindd/wb_lookupusergroups.c index 4e96b45..99c75b6 100644 --- a/source3/winbindd/wb_lookupusergroups.c +++ b/source3/winbindd/wb_lookupusergroups.c @@ -36,7 +36,6 @@ struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx, { struct tevent_req *req, *subreq; struct wb_lookupusergroups_state *state; - NTSTATUS status; req = tevent_req_create(mem_ctx, &state, struct wb_lookupusergroups_state); @@ -45,14 +44,6 @@ struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx, } sid_copy(&state->sid, sid); - status = wcache_lookup_usergroups(domain, state, sid, - &state->sids.num_sids, - &state->sids.sids); - if (NT_STATUS_IS_OK(status)) { - tevent_req_done(req); - return tevent_req_post(req, ev); - } - subreq = rpccli_wbint_LookupUserGroups_send( state, ev, domain->child.rpccli, &state->sid, &state->sids); if (tevent_req_nomem(subreq, req)) { diff --git a/source3/winbindd/wb_queryuser.c b/source3/winbindd/wb_queryuser.c index 7a2f1de..d85af78 100644 --- a/source3/winbindd/wb_queryuser.c +++ b/source3/winbindd/wb_queryuser.c @@ -35,7 +35,6 @@ struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx, struct tevent_req *req, *subreq; struct wb_queryuser_state *state; struct winbindd_domain *domain; - NTSTATUS status; req = tevent_req_create(mem_ctx, &state, struct wb_queryuser_state); if (req == NULL) { @@ -54,12 +53,6 @@ struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - status = wcache_query_user(domain, state, &state->sid, state->info); - if (NT_STATUS_IS_OK(status)) { - tevent_req_done(req); - return tevent_req_post(req, ev); - } - subreq = rpccli_wbint_QueryUser_send(state, ev, domain->child.rpccli, &state->sid, state->info); if (tevent_req_nomem(subreq, req)) { diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 1a76f87..5c2ed96 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -431,8 +431,6 @@ static struct winbindd_dispatch_table { { WINBINDD_ENDPWENT, winbindd_endpwent, "ENDPWENT" }, { WINBINDD_GETPWENT, winbindd_getpwent, "GETPWENT" }, - { WINBINDD_GETUSERSIDS, winbindd_getusersids, "GETUSERSIDS" }, - /* Group functions */ { WINBINDD_SETGRENT, winbindd_setgrent, "SETGRENT" }, @@ -538,6 +536,8 @@ static struct winbindd_async_dispatch_table async_nonpriv_table[] = { winbindd_getgrgid_send, winbindd_getgrgid_recv }, { WINBINDD_GETGRNAM, "GETGRNAM", winbindd_getgrnam_send, winbindd_getgrnam_recv }, + { WINBINDD_GETUSERSIDS, "GETUSERSIDS", + winbindd_getusersids_send, winbindd_getusersids_recv }, { 0, NULL, NULL, NULL } }; diff --git a/source3/winbindd/winbindd_async.c b/source3/winbindd/winbindd_async.c index 58080a8..d16a1f8 100644 --- a/source3/winbindd/winbindd_async.c +++ b/source3/winbindd/winbindd_async.c @@ -824,171 +824,6 @@ void winbindd_getsidaliases_async(struct winbindd_domain *domain, (void *)cont, private_data); } -struct gettoken_state { - TALLOC_CTX *mem_ctx; - DOM_SID user_sid; - struct winbindd_domain *alias_domain; - struct winbindd_domain *local_alias_domain; - struct winbindd_domain *builtin_domain; - DOM_SID *sids; - size_t num_sids; - void (*cont)(void *private_data, bool success, DOM_SID *sids, size_t num_sids); - void *private_data; -}; - -static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success, - struct winbindd_response *response, - void *c, void *private_data); -static void gettoken_recvaliases(void *private_data, bool success, - const DOM_SID *aliases, - size_t num_aliases); - - -void winbindd_gettoken_async(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - void (*cont)(void *private_data, bool success, - DOM_SID *sids, size_t num_sids), - void *private_data) -{ - struct winbindd_domain *domain; - struct winbindd_request request; - struct gettoken_state *state; - - state = TALLOC_ZERO_P(mem_ctx, struct gettoken_state); - if (state == NULL) { - DEBUG(0, ("talloc failed\n")); - cont(private_data, False, NULL, 0); - return; - } - - state->mem_ctx = mem_ctx; - sid_copy(&state->user_sid, user_sid); - state->alias_domain = find_our_domain(); - state->local_alias_domain = find_domain_from_name( get_global_sam_name() ); - state->builtin_domain = find_builtin_domain(); - state->cont = cont; - state->private_data = private_data; - - domain = find_domain_from_sid_noinit(user_sid); - if (domain == NULL) { - DEBUG(5, ("Could not find domain from SID %s\n", - sid_string_dbg(user_sid))); - cont(private_data, False, NULL, 0); - return; - } - - ZERO_STRUCT(request); - request.cmd = WINBINDD_GETUSERDOMGROUPS; - sid_to_fstring(request.data.sid, user_sid); - - do_async_domain(mem_ctx, domain, &request, gettoken_recvdomgroups, - NULL, state); -} - -static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success, - struct winbindd_response *response, - void *c, void *private_data) -{ - struct gettoken_state *state = - talloc_get_type_abort(private_data, struct gettoken_state); - char *sids_str; - - if (!success) { - DEBUG(10, ("Could not get domain groups\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - sids_str = (char *)response->extra_data.data; - - if (sids_str == NULL) { - /* This could be normal if we are dealing with a - local user and local groups */ - - if ( !sid_check_is_in_our_domain( &state->user_sid ) ) { - DEBUG(10, ("Received no domain groups\n")); - state->cont(state->private_data, True, NULL, 0); - return; - } - } - - state->sids = NULL; - state->num_sids = 0; - - if (!NT_STATUS_IS_OK(add_sid_to_array(mem_ctx, &state->user_sid, - &state->sids, &state->num_sids))) - { - DEBUG(0, ("Out of memory\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - if (sids_str && !parse_sidlist(mem_ctx, sids_str, &state->sids, - &state->num_sids)) { - DEBUG(0, ("Could not parse sids\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - if (state->alias_domain == NULL) { - DEBUG(10, ("Don't expand domain local groups\n")); - state->cont(state->private_data, True, state->sids, - state->num_sids); - return; - } - - winbindd_getsidaliases_async(state->alias_domain, mem_ctx, - state->sids, state->num_sids, - gettoken_recvaliases, state); -} - -static void gettoken_recvaliases(void *private_data, bool success, - const DOM_SID *aliases, - size_t num_aliases) -{ - struct gettoken_state *state = (struct gettoken_state *)private_data; - size_t i; - - if (!success) { - DEBUG(10, ("Could not receive domain local groups\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - for (i=0; i<num_aliases; i++) { - if (!NT_STATUS_IS_OK(add_sid_to_array(state->mem_ctx, - &aliases[i], - &state->sids, - &state->num_sids))) - { - DEBUG(0, ("Out of memory\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - } - - if (state->local_alias_domain != NULL) { - struct winbindd_domain *local_domain = state->local_alias_domain; - DEBUG(10, ("Expanding our own local groups\n")); - state->local_alias_domain = NULL; - winbindd_getsidaliases_async(local_domain, state->mem_ctx, - state->sids, state->num_sids, - gettoken_recvaliases, state); - return; - } - - if (state->builtin_domain != NULL) { - struct winbindd_domain *builtin_domain = state->builtin_domain; - DEBUG(10, ("Expanding our own BUILTIN groups\n")); - state->builtin_domain = NULL; - winbindd_getsidaliases_async(builtin_domain, state->mem_ctx, - state->sids, state->num_sids, - gettoken_recvaliases, state); - return; - } - - state->cont(state->private_data, True, state->sids, state->num_sids); -} - static void query_user_recv(TALLOC_CTX *mem_ctx, bool success, struct winbindd_response *response, void *c, void *private_data) diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index c947254..d1aeba9 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -27,6 +27,7 @@ #include "winbindd.h" #include "tdb_validate.h" #include "../libcli/auth/libcli_auth.h" +#include "../librpc/gen_ndr/ndr_wbint.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND @@ -392,30 +393,55 @@ static bool wcache_server_down(struct winbindd_domain *domain) return ret; } -static NTSTATUS fetch_cache_seqnum( struct winbindd_domain *domain, time_t now ) +static bool wcache_fetch_seqnum(const char *domain_name, uint32_t *seqnum, + uint32_t *last_seq_check) { + char *key; TDB_DATA data; - fstring key; - uint32 time_diff; - if (!wcache->tdb) { - DEBUG(10,("fetch_cache_seqnum: tdb == NULL\n")); - return NT_STATUS_UNSUCCESSFUL; + if (wcache->tdb == NULL) { + DEBUG(10,("wcache_fetch_seqnum: tdb == NULL\n")); + return false; } - fstr_sprintf( key, "SEQNUM/%s", domain->name ); - - data = tdb_fetch_bystring( wcache->tdb, key ); - if ( !data.dptr || data.dsize!=8 ) { - DEBUG(10,("fetch_cache_seqnum: invalid data size key [%s]\n", key )); - return NT_STATUS_UNSUCCESSFUL; + key = talloc_asprintf(talloc_tos(), "SEQNUM/%s", domain_name); + if (key == NULL) { + DEBUG(10, ("talloc failed\n")); + return false; } - domain->sequence_number = IVAL(data.dptr, 0); - domain->last_seq_check = IVAL(data.dptr, 4); + data = tdb_fetch_bystring(wcache->tdb, key); + TALLOC_FREE(key); + if (data.dptr == NULL) { + DEBUG(10, ("wcache_fetch_seqnum: %s not found\n", + domain_name)); + return false; + } + if (data.dsize != 8) { + DEBUG(10, ("wcache_fetch_seqnum: invalid data size %d\n", + (int)data.dsize)); + SAFE_FREE(data.dptr); + return false; + } + + *seqnum = IVAL(data.dptr, 0); + *last_seq_check = IVAL(data.dptr, 4); SAFE_FREE(data.dptr); + return true; +} + +static NTSTATUS fetch_cache_seqnum( struct winbindd_domain *domain, time_t now ) +{ + uint32 last_check, time_diff; + + if (!wcache_fetch_seqnum(domain->name, &domain->sequence_number, + &last_check)) { + return NT_STATUS_UNSUCCESSFUL; + } + domain->last_seq_check = last_check; + -- Samba Shared Repository