summaryrefslogtreecommitdiff
path: root/server/tools
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/sss_groupadd.c10
-rw-r--r--server/tools/sss_groupdel.c12
-rw-r--r--server/tools/sss_groupmod.c18
-rw-r--r--server/tools/sss_useradd.c16
-rw-r--r--server/tools/sss_userdel.c12
-rw-r--r--server/tools/sss_usermod.c18
-rw-r--r--server/tools/tools_util.c4
-rw-r--r--server/tools/tools_util.h3
8 files changed, 71 insertions, 22 deletions
diff --git a/server/tools/sss_groupadd.c b/server/tools/sss_groupadd.c
index 5c4733d7..10bb9649 100644
--- a/server/tools/sss_groupadd.c
+++ b/server/tools/sss_groupadd.c
@@ -261,8 +261,16 @@ int main(int argc, const char **argv)
goto fini;
}
+ ret = sysdb_get_ctx_from_list(ctx->db_list, data->domain, &data->sysdb);
+ if (ret != EOK) {
+ DEBUG(0, ("Cannot get domain database!\n"));
+ ERROR("Internal error accesing database\n");
+ ret = EXIT_FAILURE;
+ goto fini;
+ }
+
/* add_group */
- req = sysdb_transaction_send(ctx, ctx->ev, ctx->sysdb);
+ req = sysdb_transaction_send(ctx, ctx->ev, data->sysdb);
if (!req) {
DEBUG(1, ("Could not start transaction (%d)[%s]\n", ret, strerror(ret)));
ERROR("Transaction error. Could not add group.\n");
diff --git a/server/tools/sss_groupdel.c b/server/tools/sss_groupdel.c
index 1cf9ed0c..8f02cf3d 100644
--- a/server/tools/sss_groupdel.c
+++ b/server/tools/sss_groupdel.c
@@ -90,7 +90,7 @@ static void group_del(struct tevent_req *req)
return groupdel_done(data, ret, NULL);
}
- group_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ group_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name, data->name);
if (group_dn == NULL) {
DEBUG(1, ("Could not construct a group DN\n"));
@@ -265,8 +265,16 @@ int main(int argc, const char **argv)
goto fini;
}
+ ret = sysdb_get_ctx_from_list(ctx->db_list, data->domain, &data->sysdb);
+ if (ret != EOK) {
+ DEBUG(0, ("Cannot get domain database!\n"));
+ ERROR("Internal error accesing database\n");
+ ret = EXIT_FAILURE;
+ goto fini;
+ }
+
/* groupdel */
- req = sysdb_transaction_send(ctx, ctx->ev, ctx->sysdb);
+ req = sysdb_transaction_send(ctx, ctx->ev, data->sysdb);
if (!req) {
DEBUG(1, ("Could not start transaction (%d)[%s]\n", ret, strerror(ret)));
ERROR("Transaction error. Could not remove group.\n");
diff --git a/server/tools/sss_groupmod.c b/server/tools/sss_groupmod.c
index cca9abc6..6f60b6eb 100644
--- a/server/tools/sss_groupmod.c
+++ b/server/tools/sss_groupmod.c
@@ -156,13 +156,13 @@ static void remove_from_groups(struct ops_ctx *data)
struct ldb_dn *member_dn;
struct tevent_req *req;
- parent_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ parent_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name, data->name);
if (!parent_dn) {
return mod_group_done(data, ENOMEM);
}
- member_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ member_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name,
data->rmgroups[data->cur]);
if (!member_dn) {
@@ -213,13 +213,13 @@ static void add_to_groups(struct ops_ctx *data)
struct ldb_dn *member_dn;
struct tevent_req *req;
- parent_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ parent_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name, data->name);
if (!parent_dn) {
return mod_group_done(data, ENOMEM);
}
- member_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ member_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name,
data->addgroups[data->cur]);
if (!member_dn) {
@@ -463,7 +463,15 @@ int main(int argc, const char **argv)
goto fini;
}
- req = sysdb_transaction_send(ctx, ctx->ev, ctx->sysdb);
+ ret = sysdb_get_ctx_from_list(ctx->db_list, data->domain, &data->sysdb);
+ if (ret != EOK) {
+ DEBUG(0, ("Cannot get domain database!\n"));
+ ERROR("Internal error accesing database\n");
+ ret = EXIT_FAILURE;
+ goto fini;
+ }
+
+ req = sysdb_transaction_send(ctx, ctx->ev, data->sysdb);
if (!req) {
DEBUG(1, ("Could not start transaction (%d)[%s]\n", ret, strerror(ret)));
ERROR("Transaction error. Could not modify group.\n");
diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c
index 51f0eed8..928212d4 100644
--- a/server/tools/sss_useradd.c
+++ b/server/tools/sss_useradd.c
@@ -126,7 +126,7 @@ static int get_gid(struct ops_ctx *data, const char *groupname)
errno != 0 || data->gid == 0) {
/* Does not look like a gid - find the group name */
- ret = sysdb_getgrnam(data, data->ctx->sysdb,
+ ret = sysdb_getgrnam(data, data->sysdb,
data->domain, groupname,
get_gid_callback, data);
if (ret != EOK) {
@@ -233,13 +233,13 @@ static void add_to_groups(struct ops_ctx *data)
struct ldb_dn *member_dn;
struct tevent_req *subreq;
- member_dn = sysdb_user_dn(data->ctx->sysdb, data,
+ member_dn = sysdb_user_dn(data->sysdb, data,
data->domain->name, data->name);
if (!member_dn) {
return add_user_terminate(data, ENOMEM);
}
- parent_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ parent_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name,
data->groups[data->cur]);
if (!parent_dn) {
@@ -526,8 +526,16 @@ int main(int argc, const char **argv)
goto fini;
}
+ ret = sysdb_get_ctx_from_list(ctx->db_list, data->domain, &data->sysdb);
+ if (ret != EOK) {
+ DEBUG(0, ("Cannot get domain database!\n"));
+ ERROR("Internal error accesing database\n");
+ ret = EXIT_FAILURE;
+ goto fini;
+ }
+
/* useradd */
- req = sysdb_transaction_send(ctx, ctx->ev, ctx->sysdb);
+ req = sysdb_transaction_send(ctx, ctx->ev, data->sysdb);
if (!req) {
DEBUG(1, ("Could not start transaction (%d)[%s]\n", ret, strerror(ret)));
ERROR("Transaction error. Could not modify user.\n");
diff --git a/server/tools/sss_userdel.c b/server/tools/sss_userdel.c
index 7c796bb6..2e595f55 100644
--- a/server/tools/sss_userdel.c
+++ b/server/tools/sss_userdel.c
@@ -91,7 +91,7 @@ static void user_del(struct tevent_req *req)
return userdel_done(data, ret, NULL);
}
- user_dn = sysdb_user_dn(data->ctx->sysdb, data,
+ user_dn = sysdb_user_dn(data->sysdb, data,
data->domain->name, data->name);
if (!user_dn) {
DEBUG(1, ("Could not construct a user DN\n"));
@@ -265,8 +265,16 @@ int main(int argc, const char **argv)
goto fini;
}
+ ret = sysdb_get_ctx_from_list(ctx->db_list, data->domain, &data->sysdb);
+ if (ret != EOK) {
+ DEBUG(0, ("Cannot get domain database!\n"));
+ ERROR("Internal error accesing database\n");
+ ret = EXIT_FAILURE;
+ goto fini;
+ }
+
/* userdel */
- req = sysdb_transaction_send(ctx, ctx->ev, ctx->sysdb);
+ req = sysdb_transaction_send(ctx, ctx->ev, data->sysdb);
if (!req) {
DEBUG(1, ("Could not start transaction (%d)[%s]\n", ret, strerror(ret)));
ERROR("Transaction error. Could not remove user.\n");
diff --git a/server/tools/sss_usermod.c b/server/tools/sss_usermod.c
index 1dfd2a72..b53c8706 100644
--- a/server/tools/sss_usermod.c
+++ b/server/tools/sss_usermod.c
@@ -182,13 +182,13 @@ static void remove_from_groups(struct ops_ctx *data)
struct ldb_dn *member_dn;
struct tevent_req *req;
- member_dn = sysdb_user_dn(data->ctx->sysdb, data,
+ member_dn = sysdb_user_dn(data->sysdb, data,
data->domain->name, data->name);
if (!member_dn) {
return mod_user_done(data, ENOMEM);
}
- parent_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ parent_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name,
data->rmgroups[data->cur]);
if (!parent_dn) {
@@ -239,13 +239,13 @@ static void add_to_groups(struct ops_ctx *data)
struct ldb_dn *member_dn;
struct tevent_req *req;
- member_dn = sysdb_user_dn(data->ctx->sysdb, data,
+ member_dn = sysdb_user_dn(data->sysdb, data,
data->domain->name, data->name);
if (!member_dn) {
return mod_user_done(data, ENOMEM);
}
- parent_dn = sysdb_group_dn(data->ctx->sysdb, data,
+ parent_dn = sysdb_group_dn(data->sysdb, data,
data->domain->name,
data->addgroups[data->cur]);
if (!parent_dn) {
@@ -589,7 +589,15 @@ int main(int argc, const char **argv)
"Could not add attribute to changeset\n");
}
- req = sysdb_transaction_send(ctx, ctx->ev, ctx->sysdb);
+ ret = sysdb_get_ctx_from_list(ctx->db_list, data->domain, &data->sysdb);
+ if (ret != EOK) {
+ DEBUG(0, ("Cannot get domain database!\n"));
+ ERROR("Internal error accesing database\n");
+ ret = EXIT_FAILURE;
+ goto fini;
+ }
+
+ req = sysdb_transaction_send(ctx, ctx->ev, data->sysdb);
if (!req) {
DEBUG(1, ("Could not start transaction (%d)[%s]\n", ret, strerror(ret)));
ERROR("Transaction error. Could not modify user.\n");
diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c
index 62013994..3b16f593 100644
--- a/server/tools/tools_util.c
+++ b/server/tools/tools_util.c
@@ -167,7 +167,7 @@ int setup_db(struct tools_ctx **tools_ctx)
return ret;
}
- ret = confdb_get_domains(ctx->confdb, ctx, &ctx->domains);
+ ret = confdb_get_domains(ctx->confdb, &ctx->domains);
if (ret != EOK) {
DEBUG(1, ("Could not get domains"));
talloc_free(ctx);
@@ -175,7 +175,7 @@ int setup_db(struct tools_ctx **tools_ctx)
}
/* open sysdb at default path */
- ret = sysdb_init(ctx, ctx->ev, ctx->confdb, NULL, &ctx->sysdb);
+ ret = sysdb_init(ctx, ctx->ev, ctx->confdb, NULL, false, &ctx->db_list);
if (ret != EOK) {
DEBUG(1, ("Could not initialize connection to the sysdb"));
talloc_free(ctx);
diff --git a/server/tools/tools_util.h b/server/tools/tools_util.h
index 772ba36b..5e2dd95c 100644
--- a/server/tools/tools_util.h
+++ b/server/tools/tools_util.h
@@ -43,7 +43,7 @@ enum id_domain {
struct tools_ctx {
struct tevent_context *ev;
struct confdb_ctx *confdb;
- struct sysdb_ctx *sysdb;
+ struct sysdb_ctx_list *db_list;
struct sss_names_ctx *snctx;
struct sss_domain_info *domains;
@@ -53,6 +53,7 @@ struct ops_ctx {
struct tools_ctx *ctx;
struct tevent_context *ev;
struct sss_domain_info *domain;
+ struct sysdb_ctx *sysdb;
char *name;
uid_t uid;