summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-04-29 14:37:27 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-04-29 20:34:19 +0200
commit36c50faf2674a3ebd8a6458f3c53fb72a68d1f28 (patch)
treefc991420ec485d990074a668d447c6688b75f272 /src
parent46222e5191473f9a46aec581273eb2eef22e23be (diff)
downloadsssd-36c50faf2674a3ebd8a6458f3c53fb72a68d1f28.tar.gz
sssd-36c50faf2674a3ebd8a6458f3c53fb72a68d1f28.tar.xz
sssd-36c50faf2674a3ebd8a6458f3c53fb72a68d1f28.zip
Only try to relink ghost users if we're not enumerating
https://fedorahosted.org/sssd/ticket/1893 When SSSD is not enumerating (which is the default), we are trying to link any "ghost" entries with a newly created user entry. However, when enumeration is on, this means a spurious search on adding any user.
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb_ops.c13
-rw-r--r--src/tests/sysdb-tests.c12
2 files changed, 17 insertions, 8 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 1f27af8d..45a7265c 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1199,10 +1199,15 @@ int sysdb_add_user(struct sysdb_ctx *sysdb,
ret = sysdb_set_user_attr(sysdb, domain, name, attrs, SYSDB_MOD_REP);
if (ret) goto done;
- /* remove all ghost users */
- ret = sysdb_remove_ghostattr_from_groups(sysdb, domain,
- orig_dn, attrs, name);
- if (ret) goto done;
+ if (domain->enumerate == false) {
+ /* If we're not enumerating, previous getgr{nam,gid} calls might
+ * have stored ghost users into the cache, so we need to link them
+ * with the newly-created user entry
+ */
+ ret = sysdb_remove_ghostattr_from_groups(sysdb, domain,
+ orig_dn, attrs, name);
+ if (ret) goto done;
+ }
ret = EOK;
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 765fd09a..b30f2ed4 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -60,7 +60,7 @@ struct sysdb_test_ctx {
struct sss_domain_info *domain;
};
-static int setup_sysdb_tests(struct sysdb_test_ctx **ctx)
+static int _setup_sysdb_tests(struct sysdb_test_ctx **ctx, bool enumerate)
{
struct sysdb_test_ctx *test_ctx;
char *conf_db;
@@ -127,7 +127,7 @@ static int setup_sysdb_tests(struct sysdb_test_ctx **ctx)
return ret;
}
- val[0] = "TRUE";
+ val[0] = enumerate ? "TRUE" : "FALSE";
ret = confdb_add_param(test_ctx->confdb, true,
"config/domain/LOCAL", "enumerate", val);
if (ret != EOK) {
@@ -158,6 +158,8 @@ static int setup_sysdb_tests(struct sysdb_test_ctx **ctx)
return EOK;
}
+#define setup_sysdb_tests(ctx) _setup_sysdb_tests((ctx), false)
+
struct test_data {
struct tevent_context *ev;
struct sysdb_test_ctx *ctx;
@@ -3178,8 +3180,10 @@ START_TEST (test_sysdb_memberof_check_convert)
struct ldb_message_element *members;
int exp_mem, exp_gh;
- /* Setup */
- ret = setup_sysdb_tests(&test_ctx);
+ /* Eplicitly disable enumeration during setup as converting the ghost
+ * users into real ones work only when enumeration is disabled
+ */
+ ret = _setup_sysdb_tests(&test_ctx, false);
if (ret != EOK) {
fail("Could not set up the test");
return;