summaryrefslogtreecommitdiff
path: root/source3/libsmb/netlogon_unigrp.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb/netlogon_unigrp.c')
-rw-r--r--source3/libsmb/netlogon_unigrp.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/source3/libsmb/netlogon_unigrp.c b/source3/libsmb/netlogon_unigrp.c
index 466410d800..fa2fe32f35 100644
--- a/source3/libsmb/netlogon_unigrp.c
+++ b/source3/libsmb/netlogon_unigrp.c
@@ -22,7 +22,6 @@
*/
#include "includes.h"
-#define UNIGROUP_PREFIX "UNIGROUP"
/*
Handle for netlogon_unigrp.tdb database. It is used internally
@@ -51,22 +50,17 @@ BOOL uni_group_cache_init(void)
BOOL uni_group_cache_store_netlogon(TALLOC_CTX *mem_ctx, NET_USER_INFO_3 *user)
{
TDB_DATA key,data;
- fstring keystr, sid_string;
- DOM_SID user_sid;
- unsigned int i;
+ fstring keystr;
+ int i;
if (!uni_group_cache_init()) {
DEBUG(0,("uni_group_cache_store_netlogon: cannot open netlogon_unigrp.tdb for write!\n"));
return False;
}
- sid_copy(&user_sid, &user->dom_sid.sid);
- sid_append_rid(&user_sid, user->user_rid);
-
- /* Prepare key as USER-SID string */
- slprintf(keystr, sizeof(keystr), "%s/%s",
- UNIGROUP_PREFIX,
- sid_to_string(sid_string, &user_sid));
+ /* Prepare key as DOMAIN-SID/USER-RID string */
+ slprintf(keystr, sizeof(keystr), "%s/%d",
+ sid_string_static(&user->dom_sid.sid), user->user_rid);
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
@@ -96,15 +90,14 @@ BOOL uni_group_cache_store_netlogon(TALLOC_CTX *mem_ctx, NET_USER_INFO_3 *user)
and elements are array[0] ... array[num_elements-1]
*/
-DOM_SID **uni_group_cache_fetch(DOM_SID *domain, DOM_SID *user_sid,
+uint32* uni_group_cache_fetch(DOM_SID *domain, uint32 user_rid,
TALLOC_CTX *mem_ctx, uint32 *num_groups)
{
TDB_DATA key,data;
fstring keystr;
- DOM_SID **groups;
+ uint32 *groups;
uint32 i;
uint32 group_count;
- fstring sid_string;
if (!domain) {
DEBUG(1,("uni_group_cache_fetch: expected non-null domain sid\n"));
@@ -130,9 +123,8 @@ DOM_SID **uni_group_cache_fetch(DOM_SID *domain, DOM_SID *user_sid,
*num_groups = 0;
/* Fetch universal groups */
- slprintf(keystr, sizeof(keystr), "%s/%s",
- UNIGROUP_PREFIX,
- sid_to_string(sid_string, user_sid));
+ slprintf(keystr, sizeof(keystr), "%s/%d",
+ sid_string_static(domain), user_rid);
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
data = tdb_fetch(netlogon_unigrp_tdb, key);
@@ -144,17 +136,12 @@ DOM_SID **uni_group_cache_fetch(DOM_SID *domain, DOM_SID *user_sid,
/* Transfer data to receiver's memory context */
group_count = IVAL(&((uint32*)data.dptr)[0],0);
- groups = talloc(mem_ctx, (group_count)*sizeof(*groups));
+ groups = talloc(mem_ctx, (group_count)*sizeof(uint32));
if (groups) {
for(i=0; i<group_count; i++) {
- groups[i] = talloc(mem_ctx, sizeof(**groups));
- if (!groups[i]) {
- DEBUG(1,("uni_group_cache_fetch: cannot allocate uni groups in receiver's memory context\n"));
- return NULL;
- }
- sid_copy(groups[i], domain);
- sid_append_rid(groups[i], IVAL(&((uint32*)data.dptr)[i+1],0));
+ groups[i] = IVAL(&((uint32*)data.dptr)[i+1],0);
}
+
} else {
DEBUG(1,("uni_group_cache_fetch: cannot allocate uni groups in receiver's memory context\n"));
}