summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-05-23 21:04:54 +0200
committerKarolin Seeger <kseeger@samba.org>2009-06-02 12:41:56 +0200
commit73bbe44bb5afff41576d5412625da60bc67aa5b4 (patch)
tree8ef7464cc920218716d762b788a8b4788f6548e0
parenta89c969d86ccf6eb74c413dfaa608a99200a86ff (diff)
downloadsamba-73bbe44bb5afff41576d5412625da60bc67aa5b4.tar.gz
samba-73bbe44bb5afff41576d5412625da60bc67aa5b4.tar.xz
samba-73bbe44bb5afff41576d5412625da60bc67aa5b4.zip
s3/groupmapping: Groupdb mapping fix (bug #6386).
(cherry picked from commit fad2741ec79a34f25577d0a5d3c35a6455d3ce24)
-rw-r--r--source/groupdb/mapping_ldb.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/source/groupdb/mapping_ldb.c b/source/groupdb/mapping_ldb.c
index 68e5b4cd5e9..a69d3064057 100644
--- a/source/groupdb/mapping_ldb.c
+++ b/source/groupdb/mapping_ldb.c
@@ -222,8 +222,11 @@ static bool get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map)
if (dn == NULL) goto failed;
ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res);
+ if (ret != LDB_SUCCESS) {
+ goto failed;
+ }
talloc_steal(dn, res);
- if (ret != LDB_SUCCESS || res->count != 1) {
+ if (res->count != 1) {
goto failed;
}
@@ -251,8 +254,13 @@ static bool get_group_map_from_gid(gid_t gid, GROUP_MAP *map)
if (expr == NULL) goto failed;
ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res);
+ if (ret != LDB_SUCCESS) {
+ goto failed;
+ }
talloc_steal(expr, res);
- if (ret != LDB_SUCCESS || res->count != 1) goto failed;
+ if (res->count != 1) {
+ goto failed;
+ }
if (!msg_to_group_map(res->msgs[0], map)) goto failed;
@@ -277,8 +285,13 @@ static bool get_group_map_from_ntname(const char *name, GROUP_MAP *map)
if (expr == NULL) goto failed;
ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res);
+ if (ret != LDB_SUCCESS) {
+ goto failed;
+ }
talloc_steal(expr, res);
- if (ret != LDB_SUCCESS || res->count != 1) goto failed;
+ if (res->count != 1) {
+ goto failed;
+ }
if (!msg_to_group_map(res->msgs[0], map)) goto failed;
@@ -342,8 +355,8 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_
}
ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, NULL, &res);
- talloc_steal(tmp_ctx, res);
if (ret != LDB_SUCCESS) goto failed;
+ talloc_steal(tmp_ctx, res);
(*pp_rmap) = NULL;
*p_num_entries = 0;
@@ -395,10 +408,10 @@ static NTSTATUS one_alias_membership(const DOM_SID *member,
if (expr == NULL) goto failed;
ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, attrs, &res);
- talloc_steal(expr, res);
if (ret != LDB_SUCCESS) {
goto failed;
}
+ talloc_steal(expr, res);
for (i=0;i<res->count;i++) {
struct ldb_message_element *el;
@@ -516,8 +529,8 @@ static NTSTATUS enum_aliasmem(const DOM_SID *alias, DOM_SID **sids, size_t *num)
}
ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, attrs, &res);
- talloc_steal(dn, res);
if (ret == LDB_SUCCESS && res->count == 0) {
+ talloc_free(res);
talloc_free(dn);
return NT_STATUS_OK;
}
@@ -525,6 +538,7 @@ static NTSTATUS enum_aliasmem(const DOM_SID *alias, DOM_SID **sids, size_t *num)
talloc_free(dn);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
+ talloc_steal(dn, res);
el = ldb_msg_find_element(res->msgs[0], "member");
if (el == NULL) {