diff options
author | Volker Lendecke <vlendec@samba.org> | 2005-03-27 16:33:04 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:56:20 -0500 |
commit | e84ead0cfdc5e45a577387cc54dceb4c3f32948a (patch) | |
tree | 98d8898697479b516a36e534d3b3c9e3ce8e76c7 /source3/lib | |
parent | 0aa89db9471330fd02db395c2eb387ac2dfef54f (diff) | |
download | samba-e84ead0cfdc5e45a577387cc54dceb4c3f32948a.tar.gz samba-e84ead0cfdc5e45a577387cc54dceb4c3f32948a.tar.bz2 samba-e84ead0cfdc5e45a577387cc54dceb4c3f32948a.zip |
r6080: Port some of the non-critical changes from HEAD to 3_0. The main one is the
change in pdb_enum_alias_memberships to match samr.idl a bit closer.
Volker
(This used to be commit 3a6786516957d9f67af6d53a3167c88aa272972f)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/privileges.c | 2 | ||||
-rw-r--r-- | source3/lib/system_smbd.c | 4 | ||||
-rw-r--r-- | source3/lib/util.c | 10 | ||||
-rw-r--r-- | source3/lib/util_sid.c | 27 | ||||
-rw-r--r-- | source3/lib/util_smbd.c | 4 |
5 files changed, 35 insertions, 12 deletions
diff --git a/source3/lib/privileges.c b/source3/lib/privileges.c index b60832c8d8..e01561de06 100644 --- a/source3/lib/privileges.c +++ b/source3/lib/privileges.c @@ -497,7 +497,7 @@ static int priv_traverse_fn(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void *s return 0; } - add_sid_to_array( &sid, &priv->sids.list, &priv->sids.count ); + add_sid_to_array( NULL, &sid, &priv->sids.list, &priv->sids.count ); return 0; } diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c index c83eecf173..f124983006 100644 --- a/source3/lib/system_smbd.c +++ b/source3/lib/system_smbd.c @@ -178,10 +178,10 @@ BOOL getgroups_user(const char *user, gid_t primary_gid, groups = NULL; /* Add in primary group first */ - add_gid_to_array_unique(primary_gid, &groups, &ngrp); + add_gid_to_array_unique(NULL, primary_gid, &groups, &ngrp); for (i=0; i<max_grp; i++) - add_gid_to_array_unique(temp_groups[i], &groups, &ngrp); + add_gid_to_array_unique(NULL, temp_groups[i], &groups, &ngrp); *ngroups = ngrp; *ret_groups = groups; diff --git a/source3/lib/util.c b/source3/lib/util.c index 8f6a381944..d945bca5a7 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -277,7 +277,8 @@ const char *tmpdir(void) Add a gid to an array of gids if it's not already there. ****************************************************************************/ -void add_gid_to_array_unique(gid_t gid, gid_t **gids, int *num) +void add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid, + gid_t **gids, int *num) { int i; @@ -285,8 +286,11 @@ void add_gid_to_array_unique(gid_t gid, gid_t **gids, int *num) if ((*gids)[i] == gid) return; } - - *gids = SMB_REALLOC_ARRAY(*gids, gid_t, *num+1); + + if (mem_ctx != NULL) + *gids = TALLOC_REALLOC_ARRAY(mem_ctx, *gids, gid_t, *num+1); + else + *gids = SMB_REALLOC_ARRAY(*gids, gid_t, *num+1); if (*gids == NULL) return; diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 0ba774e184..00fb40cd73 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -351,6 +351,19 @@ BOOL string_to_sid(DOM_SID *sidout, const char *sidstr) return True; } +DOM_SID *string_sid_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) +{ + DOM_SID *result = TALLOC_P(mem_ctx, DOM_SID); + + if (result == NULL) + return NULL; + + if (!string_to_sid(result, sidstr)) + return NULL; + + return result; +} + /***************************************************************** Add a rid to the end of a sid *****************************************************************/ @@ -652,9 +665,14 @@ DOM_SID *sid_dup_talloc(TALLOC_CTX *ctx, const DOM_SID *src) Add SID to an array SIDs ********************************************************************/ -void add_sid_to_array(const DOM_SID *sid, DOM_SID **sids, int *num) +void add_sid_to_array(TALLOC_CTX *mem_ctx, const DOM_SID *sid, + DOM_SID **sids, int *num) { - *sids = SMB_REALLOC_ARRAY(*sids, DOM_SID, (*num)+1); + if (mem_ctx != NULL) + *sids = TALLOC_REALLOC_ARRAY(mem_ctx, *sids, DOM_SID, + (*num)+1); + else + *sids = SMB_REALLOC_ARRAY(*sids, DOM_SID, (*num)+1); if (*sids == NULL) return; @@ -670,7 +688,8 @@ void add_sid_to_array(const DOM_SID *sid, DOM_SID **sids, int *num) Add SID to an array SIDs ensuring that it is not already there ********************************************************************/ -void add_sid_to_array_unique(const DOM_SID *sid, DOM_SID **sids, int *num_sids) +void add_sid_to_array_unique(TALLOC_CTX *mem_ctx, const DOM_SID *sid, + DOM_SID **sids, int *num_sids) { int i; @@ -679,7 +698,7 @@ void add_sid_to_array_unique(const DOM_SID *sid, DOM_SID **sids, int *num_sids) return; } - add_sid_to_array(sid, sids, num_sids); + add_sid_to_array(mem_ctx, sid, sids, num_sids); } /******************************************************************** diff --git a/source3/lib/util_smbd.c b/source3/lib/util_smbd.c index 586362c1e4..c6f6bc0a32 100644 --- a/source3/lib/util_smbd.c +++ b/source3/lib/util_smbd.c @@ -73,10 +73,10 @@ BOOL getgroups_user(const char *user, gid_t primary_gid, gid_t **ret_groups, int groups = NULL; /* Add in primary group first */ - add_gid_to_array_unique(primary_gid, &groups, &ngrp); + add_gid_to_array_unique(NULL, primary_gid, &groups, &ngrp); for (i=0; i<max_grp; i++) - add_gid_to_array_unique(temp_groups[i], &groups, &ngrp); + add_gid_to_array_unique(NULL, temp_groups[i], &groups, &ngrp); *ngroups = ngrp; *ret_groups = groups; |