diff options
Diffstat (limited to 'server/tools/sss_groupdel.c')
-rw-r--r-- | server/tools/sss_groupdel.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/server/tools/sss_groupdel.c b/server/tools/sss_groupdel.c index a8b93578..96782084 100644 --- a/server/tools/sss_groupdel.c +++ b/server/tools/sss_groupdel.c @@ -147,6 +147,7 @@ int main(int argc, const char **argv) struct tevent_req *req; struct sss_domain_info *dom; struct group *grp_info; + const char *pc_groupname = NULL; poptContext pc = NULL; struct poptOption long_options[] = { @@ -195,27 +196,48 @@ int main(int argc, const char **argv) debug_level = pc_debug; - data->name = poptGetArg(pc); - if(data->name == NULL) { + pc_groupname = poptGetArg(pc); + if(pc_groupname == NULL) { usage(pc, _("Specify group to delete\n")); ret = EXIT_FAILURE; goto fini; } + ret = parse_name_domain(data, pc_groupname); + if (ret != EOK) { + ret = EXIT_FAILURE; + goto fini; + } + /* arguments processed, go on to actual work */ grp_info = getgrnam(data->name); if (grp_info) { data->gid = grp_info->gr_gid; } - ret = find_domain_for_id(ctx, data->gid, &dom); + /* arguments processed, go on to actual work */ + ret = get_domain_by_id(data->ctx, data->gid, &dom); + if (ret != EOK) { + ERROR("Cannot get domain info\n"); + ret = EXIT_FAILURE; + goto fini; + } + if (data->domain && data->gid && data->domain != dom) { + ERROR("Selected domain %s conflicts with selected GID %llu\n", + data->domain->name, (unsigned long long int) data->gid); + ret = EXIT_FAILURE; + goto fini; + } + if (data->domain == NULL && dom) { + data->domain = dom; + } + + ret = get_domain_type(data->ctx, data->domain); switch (ret) { case ID_IN_LOCAL: - data->domain = dom; break; case ID_IN_LEGACY_LOCAL: - data->domain = dom; case ID_OUTSIDE: ret = groupdel_legacy(data); if(ret != EOK) { @@ -232,7 +254,7 @@ int main(int argc, const char **argv) goto fini; default: - DEBUG(1, ("Unknown return code %d from find_domain_for_id\n", ret)); + DEBUG(1, ("Unknown return code %d from get_domain_type\n", ret)); ERROR("Error looking up domain\n"); ret = EXIT_FAILURE; goto fini; |