summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-07 18:48:01 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 10:53:01 +0100
commit5c1135221ff3ea9132b6ebf073f2dcae88b73b3f (patch)
tree1b720a242ce96a267ec15717fcbc5423b25c034a /src
parent7c26e3568d0d789067feef945086dff367408a1c (diff)
downloadsssd-5c1135221ff3ea9132b6ebf073f2dcae88b73b3f.tar.gz
sssd-5c1135221ff3ea9132b6ebf073f2dcae88b73b3f.tar.xz
sssd-5c1135221ff3ea9132b6ebf073f2dcae88b73b3f.zip
Add domain arguments to sysdb_add_group functions.
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.h3
-rw-r--r--src/db/sysdb_ops.c19
-rw-r--r--src/providers/ldap/sdap_async_initgroups.c4
-rw-r--r--src/providers/ldap/sdap_async_initgroups_ad.c6
-rw-r--r--src/tests/sysdb-tests.c16
-rw-r--r--src/tools/sss_sync_ops.c3
6 files changed, 31 insertions, 20 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index f0eedcd97..dccd0450e 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -623,16 +623,19 @@ int sysdb_add_user(struct sysdb_ctx *sysdb,
/* Add group (only basic attrs and w/o checks) */
int sysdb_add_basic_group(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name, gid_t gid);
/* Add group (all checks) */
int sysdb_add_group(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name, gid_t gid,
struct sysdb_attrs *attrs,
int cache_timeout,
time_t now);
int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
gid_t gid,
const char *original_dn, bool posix,
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 094ff5eee..33c6ac045 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1216,6 +1216,7 @@ done:
/* =Add-Basic-Group-NO-CHECKS============================================= */
int sysdb_add_basic_group(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name, gid_t gid)
{
struct ldb_message *msg;
@@ -1234,7 +1235,7 @@ int sysdb_add_basic_group(struct sysdb_ctx *sysdb,
}
/* group dn */
- msg->dn = sysdb_group_dn(sysdb, msg, sysdb->domain, name);
+ msg->dn = sysdb_group_dn(sysdb, msg, domain, name);
if (!msg->dn) {
ERROR_OUT(ret, ENOMEM, done);
}
@@ -1268,6 +1269,7 @@ done:
/* =Add-Group-Function==================================================== */
int sysdb_add_group(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name, gid_t gid,
struct sysdb_attrs *attrs,
int cache_timeout,
@@ -1279,8 +1281,6 @@ int sysdb_add_group(struct sysdb_ctx *sysdb,
int ret;
bool posix;
- struct sss_domain_info *domain = sysdb->domain;
-
if (domain->id_max != 0 && gid != 0 &&
(gid < domain->id_min || gid > domain->id_max)) {
DEBUG(2, ("Supplied gid [%d] is not in the allowed range [%d-%d].\n",
@@ -1325,7 +1325,7 @@ int sysdb_add_group(struct sysdb_ctx *sysdb,
}
/* try to add the group */
- ret = sysdb_add_basic_group(sysdb, name, gid);
+ ret = sysdb_add_basic_group(sysdb, domain, name, gid);
if (ret) goto done;
if (!attrs) {
@@ -1380,6 +1380,7 @@ done:
}
int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
gid_t gid,
const char *original_dn,
@@ -1396,7 +1397,7 @@ int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb,
}
/* try to add the group */
- ret = sysdb_add_basic_group(sysdb, name, gid);
+ ret = sysdb_add_basic_group(sysdb, domain, name, gid);
if (ret) goto done;
attrs = sysdb_new_attrs(tmp_ctx);
@@ -1424,7 +1425,7 @@ int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb,
if (ret) goto done;
}
- ret = sysdb_set_group_attr(sysdb, sysdb->domain, name, attrs, SYSDB_MOD_REP);
+ ret = sysdb_set_group_attr(sysdb, domain, name, attrs, SYSDB_MOD_REP);
done:
if (ret != EOK) {
@@ -1821,7 +1822,8 @@ int sysdb_store_group(struct sysdb_ctx *sysdb,
if (new_group) {
/* group doesn't exist, turn into adding a group */
- ret = sysdb_add_group(sysdb, name, gid, attrs, cache_timeout, now);
+ ret = sysdb_add_group(sysdb, sysdb->domain, name, gid,
+ attrs, cache_timeout, now);
if (ret == EEXIST) {
/* This may be a group rename. If there is a group with the
* same GID, remove it and try to add the basic group again
@@ -1838,7 +1840,8 @@ int sysdb_store_group(struct sysdb_ctx *sysdb,
DEBUG(SSSDBG_MINOR_FAILURE,
("A group with the same GID [%llu] was removed from the "
"cache\n", (unsigned long long) gid));
- ret = sysdb_add_group(sysdb, name, gid, attrs, cache_timeout, now);
+ ret = sysdb_add_group(sysdb, sysdb->domain, name, gid,
+ attrs, cache_timeout, now);
}
goto done;
}
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index 7ccbe47be..1667473d5 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -169,8 +169,8 @@ static errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb,
}
DEBUG(8, ("Adding fake group %s to sysdb\n", name));
- ret = sysdb_add_incomplete_group(sysdb, name, gid, original_dn,
- posix, now);
+ ret = sysdb_add_incomplete_group(sysdb, domain, name, gid,
+ original_dn, posix, now);
if (ret != EOK) {
goto done;
}
diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c
index e0ac7ccd0..d93573847 100644
--- a/src/providers/ldap/sdap_async_initgroups_ad.c
+++ b/src/providers/ldap/sdap_async_initgroups_ad.c
@@ -493,8 +493,10 @@ sdap_get_ad_tokengroups_initgroups_lookup_done(struct tevent_req *subreq)
* temporary entry.
*/
group_name = sid_str;
- ret = sysdb_add_incomplete_group(state->sysdb, group_name,
- gid, NULL, false, now);
+ ret = sysdb_add_incomplete_group(state->sysdb,
+ state->domain,
+ group_name, gid,
+ NULL, false, now);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
("Could not create incomplete group: [%s]\n",
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index b645761ef..e9c771a69 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -254,8 +254,8 @@ static int test_add_group(struct test_data *data)
{
int ret;
- ret = sysdb_add_group(data->ctx->sysdb, data->groupname,
- data->gid, data->attrs, 0, 0);
+ ret = sysdb_add_group(data->ctx->sysdb, data->ctx->domain,
+ data->groupname, data->gid, data->attrs, 0, 0);
return ret;
}
@@ -263,7 +263,8 @@ static int test_add_incomplete_group(struct test_data *data)
{
int ret;
- ret = sysdb_add_incomplete_group(data->ctx->sysdb, data->groupname,
+ ret = sysdb_add_incomplete_group(data->ctx->sysdb,
+ data->ctx->domain, data->groupname,
data->gid, NULL, true, 0);
return ret;
}
@@ -3324,7 +3325,8 @@ START_TEST(test_group_rename)
name, fromname);
/* Perform rename and check that GID is the same, but name changed */
- ret = sysdb_add_group(test_ctx->sysdb, toname, grgid, NULL, 0, 0);
+ ret = sysdb_add_group(test_ctx->sysdb, test_ctx->domain,
+ toname, grgid, NULL, 0, 0);
fail_unless(ret == EEXIST, "Group renamed with a low level call?");
ret = sysdb_store_group(test_ctx->sysdb, toname, grgid, NULL, 0, 0);
@@ -3710,7 +3712,7 @@ START_TEST(test_odd_characters)
/* ===== Groups ===== */
/* Add */
- ret = sysdb_add_incomplete_group(test_ctx->sysdb,
+ ret = sysdb_add_incomplete_group(test_ctx->sysdb, test_ctx->domain,
odd_groupname, 20000, NULL, true, 0);
fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]",
ret, strerror(ret));
@@ -4237,14 +4239,14 @@ START_TEST(test_sysdb_original_dn_case_insensitive)
ret = setup_sysdb_tests(&test_ctx);
fail_if(ret != EOK, "Could not set up the test");
- ret = sysdb_add_incomplete_group(test_ctx->sysdb,
+ ret = sysdb_add_incomplete_group(test_ctx->sysdb, test_ctx->domain,
"case_sensitive_group1", 29000,
"cn=case_sensitive_group1,cn=example,cn=com",
true, 0);
fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]",
ret, strerror(ret));
- ret = sysdb_add_incomplete_group(test_ctx->sysdb,
+ ret = sysdb_add_incomplete_group(test_ctx->sysdb, test_ctx->domain,
"case_sensitive_group2", 29001,
"cn=CASE_SENSITIVE_GROUP1,cn=EXAMPLE,cn=COM",
true, 0);
diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c
index 46e86ceca..25c976345 100644
--- a/src/tools/sss_sync_ops.c
+++ b/src/tools/sss_sync_ops.c
@@ -533,7 +533,8 @@ int groupadd(struct sysdb_ctx *sysdb,
{
int ret;
- ret = sysdb_add_group(sysdb, data->name, data->gid, NULL, 0, 0);
+ ret = sysdb_add_group(sysdb, data->domain,
+ data->name, data->gid, NULL, 0, 0);
if (ret == EOK) {
flush_nscd_cache(NSCD_DB_GROUP);
}