summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-07 20:17:08 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 10:53:01 +0100
commit363ce75bfe2f73198e1ae7feeed97b6009ae24b8 (patch)
treeb97f5dd0bae47f1b369fc8689da6c1a266c3f9a4
parent99c0cfdc5f065ba38f1ee91701d1d27f9e4fdb96 (diff)
downloadsssd-363ce75bfe2f73198e1ae7feeed97b6009ae24b8.tar.gz
sssd-363ce75bfe2f73198e1ae7feeed97b6009ae24b8.tar.bz2
sssd-363ce75bfe2f73198e1ae7feeed97b6009ae24b8.zip
Add domain arg to sysdb group member functions
-rw-r--r--src/db/sysdb.h3
-rw-r--r--src/db/sysdb_ops.c24
-rw-r--r--src/providers/ldap/sdap_async_initgroups.c12
-rw-r--r--src/providers/ldap/sdap_async_initgroups_ad.c4
-rw-r--r--src/tests/sysdb-tests.c16
5 files changed, 37 insertions, 22 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index a3184bee..1edf447f 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -674,16 +674,19 @@ enum sysdb_member_type {
};
int sysdb_add_group_member(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *group,
const char *member,
enum sysdb_member_type type);
int sysdb_remove_group_member(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *group,
const char *member,
enum sysdb_member_type type);
errno_t sysdb_update_members(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *member,
enum sysdb_member_type type,
const char *const *add_groups,
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 6d0d5acf..b8682608 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1877,6 +1877,7 @@ done:
/* =Add-User-to-Group(Native/Legacy)====================================== */
static int
sysdb_group_membership_mod(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *group,
const char *member,
enum sysdb_member_type type,
@@ -1891,9 +1892,9 @@ sysdb_group_membership_mod(struct sysdb_ctx *sysdb,
}
if (type == SYSDB_MEMBER_USER) {
- member_dn = sysdb_user_dn(sysdb, tmp_ctx, sysdb->domain, member);
+ member_dn = sysdb_user_dn(sysdb, tmp_ctx, domain, member);
} else if (type == SYSDB_MEMBER_GROUP) {
- member_dn = sysdb_group_dn(sysdb, tmp_ctx, sysdb->domain, member);
+ member_dn = sysdb_group_dn(sysdb, tmp_ctx, domain, member);
} else {
ret = EINVAL;
goto done;
@@ -1904,7 +1905,7 @@ sysdb_group_membership_mod(struct sysdb_ctx *sysdb,
goto done;
}
- group_dn = sysdb_group_dn(sysdb, tmp_ctx, sysdb->domain, group);
+ group_dn = sysdb_group_dn(sysdb, tmp_ctx, domain, group);
if (!group_dn) {
ret = ENOMEM;
goto done;
@@ -1918,22 +1919,26 @@ done:
}
int sysdb_add_group_member(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *group,
const char *member,
enum sysdb_member_type type)
{
- return sysdb_group_membership_mod(sysdb, group, member, type, SYSDB_MOD_ADD);
+ return sysdb_group_membership_mod(sysdb, domain, group,
+ member, type, SYSDB_MOD_ADD);
}
/* =Remove-member-from-Group(Native/Legacy)=============================== */
int sysdb_remove_group_member(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *group,
const char *member,
enum sysdb_member_type type)
{
- return sysdb_group_membership_mod(sysdb, group, member, type, SYSDB_MOD_DEL);
+ return sysdb_group_membership_mod(sysdb, domain, group,
+ member, type, SYSDB_MOD_DEL);
}
@@ -2983,6 +2988,7 @@ done:
}
errno_t sysdb_update_members(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *member,
enum sysdb_member_type type,
const char *const *add_groups,
@@ -3009,8 +3015,8 @@ errno_t sysdb_update_members(struct sysdb_ctx *sysdb,
if (add_groups) {
/* Add the user to all add_groups */
for (i = 0; add_groups[i]; i++) {
- ret = sysdb_add_group_member(sysdb, add_groups[i], member,
- type);
+ ret = sysdb_add_group_member(sysdb, domain,
+ add_groups[i], member, type);
if (ret != EOK) {
DEBUG(1, ("Could not add member [%s] to group [%s]. "
"Skipping.\n", member, add_groups[i]));
@@ -3022,8 +3028,8 @@ errno_t sysdb_update_members(struct sysdb_ctx *sysdb,
if (del_groups) {
/* Remove the user from all del_groups */
for (i = 0; del_groups[i]; i++) {
- ret = sysdb_remove_group_member(sysdb, del_groups[i], member,
- type);
+ ret = sysdb_remove_group_member(sysdb, domain,
+ del_groups[i], member, type);
if (ret != EOK) {
DEBUG(1, ("Could not remove member [%s] from group [%s]. "
"Skipping\n", member, del_groups[i]));
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index 1667473d..a489ca6d 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -270,7 +270,7 @@ int sdap_initgr_common_store(struct sysdb_ctx *sysdb,
}
DEBUG(8, ("Updating memberships for %s\n", name));
- ret = sysdb_update_members(sysdb, name, type,
+ ret = sysdb_update_members(sysdb, domain, name, type,
(const char *const *) add_groups,
(const char *const *) del_groups);
if (ret != EOK) {
@@ -1082,7 +1082,7 @@ sdap_initgr_store_group_memberships(struct sdap_initgr_nested_state *state)
in_transaction = true;
DLIST_FOR_EACH(miter, memberships) {
- ret = sysdb_update_members(state->sysdb, miter->name,
+ ret = sysdb_update_members(state->sysdb, state->dom, miter->name,
SYSDB_MEMBER_GROUP,
(const char *const *) miter->add,
(const char *const *) miter->del);
@@ -1210,7 +1210,8 @@ sdap_initgr_store_user_memberships(struct sdap_initgr_nested_state *state)
in_transaction = true;
DEBUG(8, ("Updating memberships for %s\n", state->username));
- ret = sysdb_update_members(state->sysdb, state->username, SYSDB_MEMBER_USER,
+ ret = sysdb_update_members(state->sysdb, state->dom,
+ state->username, SYSDB_MEMBER_USER,
(const char *const *) add_groups,
(const char *const *) del_groups);
if (ret != EOK) {
@@ -1871,7 +1872,7 @@ save_rfc2307bis_group_memberships(struct sdap_initgr_rfc2307bis_state *state)
} else {
add[num_added] = NULL;
}
- ret = sysdb_update_members(state->sysdb, iter->name,
+ ret = sysdb_update_members(state->sysdb, state->dom, iter->name,
SYSDB_MEMBER_GROUP,
(const char *const *) add,
(const char *const *) iter->del);
@@ -2017,7 +2018,8 @@ errno_t save_rfc2307bis_user_memberships(
}
DEBUG(8, ("Updating memberships for %s\n", state->name));
- ret = sysdb_update_members(state->sysdb, state->name, SYSDB_MEMBER_USER,
+ ret = sysdb_update_members(state->sysdb, state->dom,
+ state->name, SYSDB_MEMBER_USER,
(const char *const *)add_groups,
(const char *const *)del_groups);
if (ret != EOK) {
diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c
index d9357384..a3f6694a 100644
--- a/src/providers/ldap/sdap_async_initgroups_ad.c
+++ b/src/providers/ldap/sdap_async_initgroups_ad.c
@@ -544,8 +544,8 @@ sdap_get_ad_tokengroups_initgroups_lookup_done(struct tevent_req *subreq)
DEBUG(SSSDBG_TRACE_LIBS,
("Updating memberships for [%s]\n", state->username));
- ret = sysdb_update_members(state->sysdb, state->username,
- SYSDB_MEMBER_USER,
+ ret = sysdb_update_members(state->sysdb, state->domain,
+ state->username, SYSDB_MEMBER_USER,
(const char *const *) add_groups,
(const char *const *) del_groups);
if (ret != EOK) {
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index cf6a1478..e63aa77a 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -323,7 +323,7 @@ static int test_add_group_member(struct test_data *data)
return ENOMEM;
}
- ret = sysdb_add_group_member(data->ctx->sysdb,
+ ret = sysdb_add_group_member(data->ctx->sysdb, data->ctx->domain,
data->groupname, username,
SYSDB_MEMBER_USER);
return ret;
@@ -339,7 +339,7 @@ static int test_remove_group_member(struct test_data *data)
return ENOMEM;
}
- ret = sysdb_remove_group_member(data->ctx->sysdb,
+ ret = sysdb_remove_group_member(data->ctx->sysdb, data->ctx->domain,
data->groupname, username,
SYSDB_MEMBER_USER);
return ret;
@@ -3458,7 +3458,8 @@ START_TEST (test_sysdb_update_members)
add_groups[1] = talloc_strdup(add_groups, "testgroup28002");
add_groups[2] = NULL;
- ret = sysdb_update_members(test_ctx->sysdb, user, SYSDB_MEMBER_USER,
+ ret = sysdb_update_members(test_ctx->sysdb, test_ctx->domain,
+ user, SYSDB_MEMBER_USER,
(const char *const *)add_groups, NULL);
fail_unless(ret == EOK, "Could not add groups");
talloc_zfree(add_groups);
@@ -3471,7 +3472,8 @@ START_TEST (test_sysdb_update_members)
add_groups[0] = talloc_strdup(add_groups, "testgroup28003");
add_groups[1] = NULL;
- ret = sysdb_update_members(test_ctx->sysdb, user, SYSDB_MEMBER_USER,
+ ret = sysdb_update_members(test_ctx->sysdb, test_ctx->domain,
+ user, SYSDB_MEMBER_USER,
(const char *const *)add_groups,
(const char *const *)del_groups);
fail_unless(ret == EOK, "Group replace failed");
@@ -3484,7 +3486,8 @@ START_TEST (test_sysdb_update_members)
del_groups[1] = talloc_strdup(del_groups, "testgroup28003");
del_groups[2] = NULL;
- ret = sysdb_update_members(test_ctx->sysdb, user, SYSDB_MEMBER_USER,
+ ret = sysdb_update_members(test_ctx->sysdb, test_ctx->domain,
+ user, SYSDB_MEMBER_USER,
NULL, (const char *const *)del_groups);
fail_unless(ret == EOK, "Could not remove groups");
@@ -3767,7 +3770,8 @@ START_TEST(test_odd_characters)
talloc_zfree(msg);
/* Add to the group */
- ret = sysdb_add_group_member(test_ctx->sysdb, odd_groupname, odd_username,
+ ret = sysdb_add_group_member(test_ctx->sysdb, test_ctx->domain,
+ odd_groupname, odd_username,
SYSDB_MEMBER_USER);
fail_unless(ret == EOK, "sysdb_add_group_member error [%d][%s]",
ret, strerror(ret));