summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-08 16:24:29 +0200
committerVolker Lendecke <vl@samba.org>2009-08-16 12:38:19 +0200
commit3d46eaf4110b22b9328466009436f1d3fa9d88e5 (patch)
tree6cb0a81c0d20cf3677047ab47fc94a54d7c8f436 /source3
parent1a22baa817291f5d067dccfb9e4b754781d2fb6f (diff)
downloadsamba-3d46eaf4110b22b9328466009436f1d3fa9d88e5.tar.gz
samba-3d46eaf4110b22b9328466009436f1d3fa9d88e5.tar.bz2
samba-3d46eaf4110b22b9328466009436f1d3fa9d88e5.zip
s3:winbind: Make wcache_lookup_groupmem available publically
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/winbindd_cache.c78
-rw-r--r--source3/winbindd/winbindd_proto.h6
2 files changed, 60 insertions, 24 deletions
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index 3def0159a5..a46aa0af3e 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -2272,38 +2272,52 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
return status;
}
-
-static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
+NTSTATUS wcache_lookup_groupmem(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- const DOM_SID *group_sid, uint32 *num_names,
- DOM_SID **sid_mem, char ***names,
- uint32 **name_types)
+ const struct dom_sid *group_sid,
+ uint32_t *num_names,
+ struct dom_sid **sid_mem, char ***names,
+ uint32_t **name_types)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
NTSTATUS status;
unsigned int i;
- fstring sid_string;
+ char *sid_string;
- if (!cache->tdb)
- goto do_query;
+ if (cache->tdb == NULL) {
+ return NT_STATUS_NOT_FOUND;
+ }
- centry = wcache_fetch(cache, domain, "GM/%s",
- sid_to_fstring(sid_string, group_sid));
- if (!centry)
- goto do_query;
+ sid_string = sid_string_tos(group_sid);
+ if (sid_string == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
- *num_names = centry_uint32(centry);
+ centry = wcache_fetch(cache, domain, "GM/%s", sid_string);
+ TALLOC_FREE(sid_string);
+ if (centry == NULL) {
+ return NT_STATUS_NOT_FOUND;
+ }
- if (*num_names == 0)
- goto do_cached;
+ *sid_mem = NULL;
+ *names = NULL;
+ *name_types = NULL;
- (*sid_mem) = TALLOC_ARRAY(mem_ctx, DOM_SID, *num_names);
- (*names) = TALLOC_ARRAY(mem_ctx, char *, *num_names);
- (*name_types) = TALLOC_ARRAY(mem_ctx, uint32, *num_names);
+ *num_names = centry_uint32(centry);
+ if (*num_names == 0) {
+ return NT_STATUS_OK;
+ }
- if (! (*sid_mem) || ! (*names) || ! (*name_types)) {
- smb_panic_fn("lookup_groupmem out of memory");
+ *sid_mem = talloc_array(mem_ctx, DOM_SID, *num_names);
+ *names = talloc_array(mem_ctx, char *, *num_names);
+ *name_types = talloc_array(mem_ctx, uint32, *num_names);
+
+ if ((*sid_mem == NULL) || (*names == NULL) || (*name_types == NULL)) {
+ TALLOC_FREE(*sid_mem);
+ TALLOC_FREE(*names);
+ TALLOC_FREE(*name_types);
+ return NT_STATUS_NO_MEMORY;
}
for (i=0; i<(*num_names); i++) {
@@ -2312,16 +2326,32 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
(*name_types)[i] = centry_uint32(centry);
}
-do_cached:
status = centry->status;
- DEBUG(10,("lookup_groupmem: [Cached] - cached info for domain %s status: %s\n",
- domain->name, nt_errstr(status)));
+ DEBUG(10,("lookup_groupmem: [Cached] - cached info for domain %s "
+ "status: %s\n", domain->name, nt_errstr(status)));
centry_free(centry);
return status;
+}
+
+static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const DOM_SID *group_sid, uint32 *num_names,
+ DOM_SID **sid_mem, char ***names,
+ uint32 **name_types)
+{
+ struct cache_entry *centry = NULL;
+ NTSTATUS status;
+ unsigned int i;
+ fstring sid_string;
+
+ status = wcache_lookup_groupmem(domain, mem_ctx, group_sid, num_names,
+ sid_mem, names, name_types);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
+ return status;
+ }
-do_query:
(*num_names) = 0;
(*sid_mem) = NULL;
(*names) = NULL;
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index e0ac48e070..0fea00d7f0 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -155,6 +155,12 @@ NTSTATUS wcache_sid_to_name(struct winbindd_domain *domain,
char **domain_name,
char **name,
enum lsa_SidType *type);
+NTSTATUS wcache_lookup_groupmem(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *group_sid,
+ uint32_t *num_names,
+ struct dom_sid **sid_mem, char ***names,
+ uint32_t **name_types);
bool lookup_cached_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
char **domain_name, char **name,
enum lsa_SidType *type);