From 360227a0feb443fbbcc420295d5666da5823685a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 1 Aug 2009 10:20:13 -0400 Subject: s3:winbind: Make wcache_query_user externally visible --- source3/winbindd/winbindd_cache.c | 65 ++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 22 deletions(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 87594542cf..270b9f310d 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -1939,38 +1939,46 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain, return result; } -/* Lookup user information from a rid */ -static NTSTATUS query_user(struct winbindd_domain *domain, - TALLOC_CTX *mem_ctx, - const DOM_SID *user_sid, - WINBIND_USERINFO *info) +NTSTATUS wcache_query_user(struct winbindd_domain *domain, + TALLOC_CTX *mem_ctx, + const struct dom_sid *user_sid, + struct winbind_userinfo *info) { struct winbind_cache *cache = get_cache(domain); struct cache_entry *centry = NULL; NTSTATUS status; - fstring tmp; + char *sid_string; - if (!cache->tdb) - goto do_query; + if (cache->tdb == NULL) { + return NT_STATUS_NOT_FOUND; + } - centry = wcache_fetch(cache, domain, "U/%s", - sid_to_fstring(tmp, user_sid)); + sid_string = sid_string_tos(user_sid); + if (sid_string == NULL) { + return NT_STATUS_NO_MEMORY; + } - /* If we have an access denied cache entry and a cached info3 in the - samlogon cache then do a query. This will force the rpc back end - to return the info3 data. */ + centry = wcache_fetch(cache, domain, "U/%s", sid_string); + TALLOC_FREE(sid_string); + if (centry == NULL) { + return NT_STATUS_NOT_FOUND; + } - if (NT_STATUS_V(domain->last_status) == NT_STATUS_V(NT_STATUS_ACCESS_DENIED) && + /* + * If we have an access denied cache entry and a cached info3 + * in the samlogon cache then do a query. This will force the + * rpc back end to return the info3 data. + */ + + if (NT_STATUS_EQUAL(domain->last_status, NT_STATUS_ACCESS_DENIED) && netsamlogon_cache_have(user_sid)) { - DEBUG(10, ("query_user: cached access denied and have cached info3\n")); + DEBUG(10, ("query_user: cached access denied and have cached " + "info3\n")); domain->last_status = NT_STATUS_OK; centry_free(centry); - goto do_query; + return NT_STATUS_NOT_FOUND; } - if (!centry) - goto do_query; - /* if status is not ok then this is a negative hit and the rest of the data doesn't matter */ status = centry->status; @@ -1984,13 +1992,26 @@ static NTSTATUS query_user(struct winbindd_domain *domain, centry_sid(centry, &info->group_sid); } - DEBUG(10,("query_user: [Cached] - cached info for domain %s status: %s\n", - domain->name, nt_errstr(status) )); + DEBUG(10,("query_user: [Cached] - cached info for domain %s status: " + "%s\n", domain->name, nt_errstr(status) )); centry_free(centry); return status; +} + +/* Lookup user information from a rid */ +static NTSTATUS query_user(struct winbindd_domain *domain, + TALLOC_CTX *mem_ctx, + const DOM_SID *user_sid, + WINBIND_USERINFO *info) +{ + NTSTATUS status; + + status = wcache_query_user(domain, mem_ctx, user_sid, info); + if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { + return status; + } -do_query: ZERO_STRUCTP(info); /* Return status value returned by seq number check */ -- cgit