diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-04-07 19:25:48 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-04-08 10:55:03 -0400 |
commit | 6b5d45693f01eec55128eb3508266cda73071d93 (patch) | |
tree | c51ca00f2fb243e5eaf06128e8092583fba1bd8c /server/tools | |
parent | e8a7526b06acf4af322fdab593c8bafbd9f4a103 (diff) | |
download | sssd2-6b5d45693f01eec55128eb3508266cda73071d93.tar.gz sssd2-6b5d45693f01eec55128eb3508266cda73071d93.tar.xz sssd2-6b5d45693f01eec55128eb3508266cda73071d93.zip |
Change the way we retrieve domains
To be able to correctly filter out duplicate names when multiple non-fully
qualified domains are in use we need to be able to specify the domains order.
This is now accomplished by the configuration paramets 'domains' in the
config/domains entry. 'domains' is a comma separated list of domain names.
This paramter allows also to have disbaled domains in the configuration without
requiring to completely delete them.
The domains list is now kept in a linked list of sss_domain_info objects.
The first domain is also the "default" domain.
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/sss_groupadd.c | 9 | ||||
-rw-r--r-- | server/tools/sss_groupdel.c | 12 | ||||
-rw-r--r-- | server/tools/sss_groupmod.c | 11 | ||||
-rw-r--r-- | server/tools/sss_useradd.c | 10 | ||||
-rw-r--r-- | server/tools/sss_userdel.c | 11 | ||||
-rw-r--r-- | server/tools/sss_usermod.c | 12 | ||||
-rw-r--r-- | server/tools/tools_util.h | 2 |
7 files changed, 46 insertions, 21 deletions
diff --git a/server/tools/sss_groupadd.c b/server/tools/sss_groupadd.c index 5363dbba..d0559716 100644 --- a/server/tools/sss_groupadd.c +++ b/server/tools/sss_groupadd.c @@ -83,7 +83,7 @@ int main(int argc, const char **argv) { "gid", 'g', POPT_ARG_INT, &pc_gid, 0, "The GID of the group", NULL }, POPT_TABLEEND }; - + struct sss_domain_info *dom; poptContext pc = NULL; struct tools_ctx *ctx = NULL; struct group_add_ctx *group_ctx = NULL; @@ -128,12 +128,15 @@ int main(int argc, const char **argv) /* arguments processed, go on to actual work */ - group_ctx->domain = btreemap_get_value(ctx->domains, "LOCAL"); - if (group_ctx->domain == NULL) { + for (dom = ctx->domains; dom; dom = dom->next) { + if (strcasecmp(dom->name, "LOCAL") == 0) break; + } + if (dom == NULL) { DEBUG(0, ("Could not get domain info\n")); ret = EXIT_FAILURE; goto fini; } + group_ctx->domain = dom; /* add_group */ ret = sysdb_transaction(ctx, ctx->sysdb, add_group, group_ctx); diff --git a/server/tools/sss_groupdel.c b/server/tools/sss_groupdel.c index 1cbddf45..8e85003c 100644 --- a/server/tools/sss_groupdel.c +++ b/server/tools/sss_groupdel.c @@ -79,7 +79,7 @@ int main(int argc, const char **argv) int ret = EXIT_SUCCESS; struct group_del_ctx *group_ctx = NULL; struct tools_ctx *ctx = NULL; - + struct sss_domain_info *dom; poptContext pc = NULL; struct poptOption long_options[] = { @@ -121,12 +121,16 @@ int main(int argc, const char **argv) /* arguments processed, go on to actual work */ - group_ctx->domain = btreemap_get_value(ctx->domains, "LOCAL"); - if (group_ctx->domain == NULL) { - DEBUG(0, ("Could not set default values\n")); + for (dom = ctx->domains; dom; dom = dom->next) { + if (strcasecmp(dom->name, "LOCAL") == 0) break; + } + if (dom == NULL) { + DEBUG(0, ("Could not get domain info\n")); ret = EXIT_FAILURE; goto fini; } + group_ctx->domain = dom; + group_ctx->group_dn = sysdb_group_dn(ctx->sysdb, ctx, group_ctx->domain->name, diff --git a/server/tools/sss_groupmod.c b/server/tools/sss_groupmod.c index ed16033a..922555f0 100644 --- a/server/tools/sss_groupmod.c +++ b/server/tools/sss_groupmod.c @@ -186,6 +186,7 @@ int main(int argc, const char **argv) POPT_TABLEEND }; poptContext pc = NULL; + struct sss_domain_info *dom; struct group_mod_ctx *group_ctx = NULL; struct tools_ctx *ctx = NULL; char *groups; @@ -246,12 +247,16 @@ int main(int argc, const char **argv) group_ctx->gid = pc_gid; /* arguments processed, go on to actual work */ - group_ctx->domain = btreemap_get_value(ctx->domains, "LOCAL"); - if (group_ctx->domain == NULL) { - DEBUG(0, ("Could not get the domain\n")); + + for (dom = ctx->domains; dom; dom = dom->next) { + if (strcasecmp(dom->name, "LOCAL") == 0) break; + } + if (dom == NULL) { + DEBUG(0, ("Could not get domain info\n")); ret = EXIT_FAILURE; goto fini; } + group_ctx->domain = dom; ret = sysdb_transaction(ctx, ctx->sysdb, mod_group, group_ctx); if (ret != EOK) { diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c index ba89276f..d3b930d1 100644 --- a/server/tools/sss_useradd.c +++ b/server/tools/sss_useradd.c @@ -233,6 +233,7 @@ int main(int argc, const char **argv) POPT_TABLEEND }; poptContext pc = NULL; + struct sss_domain_info *dom; struct user_add_ctx *user_ctx = NULL; struct tools_ctx *ctx = NULL; char *groups; @@ -332,12 +333,15 @@ int main(int argc, const char **argv) /* arguments processed, go on to actual work */ - user_ctx->domain = btreemap_get_value(ctx->domains, "LOCAL"); - if (user_ctx->domain == NULL) { - DEBUG(0, ("Could not set default values\n")); + for (dom = ctx->domains; dom; dom = dom->next) { + if (strcasecmp(dom->name, "LOCAL") == 0) break; + } + if (dom == NULL) { + DEBUG(0, ("Could not get domain info\n")); ret = EXIT_FAILURE; goto fini; } + user_ctx->domain = dom; /* useradd */ ret = sysdb_transaction(ctx, ctx->sysdb, add_user, user_ctx); diff --git a/server/tools/sss_userdel.c b/server/tools/sss_userdel.c index 1a56cf9d..47188824 100644 --- a/server/tools/sss_userdel.c +++ b/server/tools/sss_userdel.c @@ -78,7 +78,7 @@ int main(int argc, const char **argv) int ret = EXIT_SUCCESS; struct user_del_ctx *user_ctx = NULL; struct tools_ctx *ctx = NULL; - + struct sss_domain_info *dom; poptContext pc = NULL; struct poptOption long_options[] = { @@ -120,12 +120,15 @@ int main(int argc, const char **argv) /* arguments processed, go on to actual work */ - user_ctx->domain = btreemap_get_value(ctx->domains, "LOCAL"); - if (user_ctx->domain == NULL) { - DEBUG(0, ("Could not set default values\n")); + for (dom = ctx->domains; dom; dom = dom->next) { + if (strcasecmp(dom->name, "LOCAL") == 0) break; + } + if (dom == NULL) { + DEBUG(0, ("Could not get domain info\n")); ret = EXIT_FAILURE; goto fini; } + user_ctx->domain = dom; user_ctx->user_dn = sysdb_user_dn(ctx->sysdb, ctx, user_ctx->domain->name, diff --git a/server/tools/sss_usermod.c b/server/tools/sss_usermod.c index 6f1d4ce6..dae584e2 100644 --- a/server/tools/sss_usermod.c +++ b/server/tools/sss_usermod.c @@ -210,6 +210,7 @@ int main(int argc, const char **argv) POPT_TABLEEND }; poptContext pc = NULL; + struct sss_domain_info *dom; struct user_mod_ctx *user_ctx = NULL; struct tools_ctx *ctx = NULL; char *groups; @@ -328,10 +329,15 @@ int main(int argc, const char **argv) /* arguments processed, go on to actual work */ - user_ctx->domain = btreemap_get_value(ctx->domains, "LOCAL"); - if (user_ctx->domain == NULL) { - VAR_CHECK(ret, EOK, "Could not set default values\n"); + for (dom = ctx->domains; dom; dom = dom->next) { + if (strcasecmp(dom->name, "LOCAL") == 0) break; } + if (dom == NULL) { + DEBUG(0, ("Could not get domain info\n")); + ret = EXIT_FAILURE; + goto fini; + } + user_ctx->domain = dom; ret = sysdb_transaction(ctx, ctx->sysdb, mod_user, user_ctx); if (ret != EOK) { diff --git a/server/tools/tools_util.h b/server/tools/tools_util.h index 4a32e9c7..ef55dede 100644 --- a/server/tools/tools_util.h +++ b/server/tools/tools_util.h @@ -9,7 +9,7 @@ struct tools_ctx { struct confdb_ctx *confdb; struct sysdb_ctx *sysdb; - struct btreemap *domains; + struct sss_domain_info *domains; }; int setup_db(struct tools_ctx **ctx); |