summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/db/sysdb.h1
-rw-r--r--src/db/sysdb_ops.c15
-rw-r--r--src/tests/sysdb-tests.c4
-rw-r--r--src/tools/sss_seed.c2
-rw-r--r--src/tools/sss_sync_ops.c3
5 files changed, 14 insertions, 11 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index a57da489..f0eedcd9 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -610,6 +610,7 @@ int sysdb_add_basic_user(struct sysdb_ctx *sysdb,
/* Add user (all checks) */
int sysdb_add_user(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
uid_t uid, gid_t gid,
const char *gecos,
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 640a928a..094ff5ee 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -978,6 +978,7 @@ done:
static errno_t
sysdb_remove_ghostattr_from_groups(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *orig_dn,
struct sysdb_attrs *attrs,
const char *name)
@@ -1026,7 +1027,7 @@ sysdb_remove_ghostattr_from_groups(struct sysdb_ctx *sysdb,
goto done;
}
- tmpdn = sysdb_user_dn(sysdb, tmp_ctx, sysdb->domain, name);
+ tmpdn = sysdb_user_dn(sysdb, tmp_ctx, domain, name);
if (!tmpdn) {
ERROR_OUT(ret, ENOMEM, done);
}
@@ -1037,7 +1038,7 @@ sysdb_remove_ghostattr_from_groups(struct sysdb_ctx *sysdb,
}
tmpdn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb,
- SYSDB_TMPL_GROUP_BASE, sysdb->domain->name);
+ SYSDB_TMPL_GROUP_BASE, domain->name);
if (!tmpdn) {
ret = ENOMEM;
goto done;
@@ -1068,6 +1069,7 @@ done:
/* =Add-User-Function===================================================== */
int sysdb_add_user(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
uid_t uid, gid_t gid,
const char *gecos,
@@ -1084,8 +1086,6 @@ int sysdb_add_user(struct sysdb_ctx *sysdb,
uint32_t id;
int ret;
- struct sss_domain_info *domain = sysdb->domain;
-
if (sysdb->mpg) {
if (gid != 0) {
DEBUG(0, ("Cannot add user with arbitrary GID in MPG domain!\n"));
@@ -1195,7 +1195,8 @@ int sysdb_add_user(struct sysdb_ctx *sysdb,
if (ret) goto done;
/* remove all ghost users */
- ret = sysdb_remove_ghostattr_from_groups(sysdb, orig_dn, attrs, name);
+ ret = sysdb_remove_ghostattr_from_groups(sysdb, domain,
+ orig_dn, attrs, name);
if (ret) goto done;
ret = EOK;
@@ -1663,7 +1664,7 @@ int sysdb_store_user(struct sysdb_ctx *sysdb,
if (ret == ENOENT) {
/* users doesn't exist, turn into adding a user */
- ret = sysdb_add_user(sysdb, name, uid, gid, gecos, homedir,
+ ret = sysdb_add_user(sysdb, sysdb->domain, name, uid, gid, gecos, homedir,
shell, orig_dn, attrs, cache_timeout, now);
if (ret == EEXIST) {
/* This may be a user rename. If there is a user with the
@@ -1682,7 +1683,7 @@ int sysdb_store_user(struct sysdb_ctx *sysdb,
DEBUG(SSSDBG_MINOR_FAILURE,
("A user with the same UID [%llu] was removed from the "
"cache\n", (unsigned long long) uid));
- ret = sysdb_add_user(sysdb, name, uid, gid, gecos, homedir,
+ ret = sysdb_add_user(sysdb, sysdb->domain, name, uid, gid, gecos, homedir,
shell, orig_dn, attrs, cache_timeout, now);
}
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index efa5339e..b645761e 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -191,7 +191,7 @@ static int test_add_user(struct test_data *data)
homedir = talloc_asprintf(data, "/home/testuser%d", data->uid);
gecos = talloc_asprintf(data, "Test User %d", data->uid);
- ret = sysdb_add_user(data->ctx->sysdb, data->username,
+ ret = sysdb_add_user(data->ctx->sysdb, data->ctx->domain, data->username,
data->uid, 0, gecos, homedir, "/bin/bash",
NULL, NULL, 0, 0);
return ret;
@@ -3397,7 +3397,7 @@ START_TEST(test_user_rename)
name, fromname);
/* Perform rename and check that GID is the same, but name changed */
- ret = sysdb_add_user(test_ctx->sysdb, toname, userid, 0,
+ ret = sysdb_add_user(test_ctx->sysdb, test_ctx->domain, toname, userid, 0,
fromname, "/", "/bin/sh", NULL, NULL, 0, 0);
fail_unless(ret == EEXIST, "A second user added with low level call?");
diff --git a/src/tools/sss_seed.c b/src/tools/sss_seed.c
index 45b4d1ad..5e4504e0 100644
--- a/src/tools/sss_seed.c
+++ b/src/tools/sss_seed.c
@@ -739,7 +739,7 @@ static int seed_cache_user(struct seed_ctx *sctx)
in_transaction = true;
if (sctx->user_cached == false) {
- ret = sysdb_add_user(sctx->sysdb, sctx->uctx->name,
+ ret = sysdb_add_user(sctx->sysdb, sctx->domain, sctx->uctx->name,
sctx->uctx->uid, sctx->uctx->gid,
sctx->uctx->gecos, sctx->uctx->home,
sctx->uctx->shell, NULL, NULL, 0, 0);
diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c
index 34618825..46e86cec 100644
--- a/src/tools/sss_sync_ops.c
+++ b/src/tools/sss_sync_ops.c
@@ -468,7 +468,8 @@ int useradd(TALLOC_CTX *mem_ctx,
{
int ret;
- ret = sysdb_add_user(sysdb, data->name, data->uid, data->gid,
+ ret = sysdb_add_user(sysdb,
+ data->domain, data->name, data->uid, data->gid,
data->gecos, data->home, data->shell,
NULL, NULL, 0, 0);
if (ret) {