diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-08-31 18:12:25 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-09-08 09:36:22 -0400 |
commit | 8443d24c0584f45151e0c80506d7a572b8a38ed7 (patch) | |
tree | 3df77db1747c04ed38095bb6b78087c6534adc50 /src/tools | |
parent | 4f6a396fcf16f97b2abc3d0cba10e9aa9bc38619 (diff) | |
download | sssd-8443d24c0584f45151e0c80506d7a572b8a38ed7.tar.gz sssd-8443d24c0584f45151e0c80506d7a572b8a38ed7.tar.xz sssd-8443d24c0584f45151e0c80506d7a572b8a38ed7.zip |
Fix assorted minor bugs in sss_ tools
Fixes: #585
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/sss_groupadd.c | 8 | ||||
-rw-r--r-- | src/tools/sss_groupdel.c | 8 | ||||
-rw-r--r-- | src/tools/sss_groupmod.c | 14 | ||||
-rw-r--r-- | src/tools/sss_groupshow.c | 8 | ||||
-rw-r--r-- | src/tools/sss_useradd.c | 13 | ||||
-rw-r--r-- | src/tools/sss_userdel.c | 8 | ||||
-rw-r--r-- | src/tools/sss_usermod.c | 14 | ||||
-rw-r--r-- | src/tools/tools_util.c | 5 | ||||
-rw-r--r-- | src/tools/tools_util.h | 6 |
9 files changed, 37 insertions, 47 deletions
diff --git a/src/tools/sss_groupadd.c b/src/tools/sss_groupadd.c index e5ef7218b..8817625d5 100644 --- a/src/tools/sss_groupadd.c +++ b/src/tools/sss_groupadd.c @@ -62,9 +62,7 @@ int main(int argc, const char **argv) pc = poptGetContext(NULL, argc, argv, long_options, 0); poptSetOtherOptionHelp(pc, "GROUPNAME"); if ((ret = poptGetNextOpt(pc)) < -1) { - usage(pc, poptStrerror(ret)); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } debug_level = pc_debug; @@ -72,9 +70,7 @@ int main(int argc, const char **argv) /* groupname is an argument, not option */ pc_groupname = poptGetArg(pc); if (pc_groupname == NULL) { - usage(pc, _("Specify group to add\n")); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, _("Specify group to add\n"), ret, fini); } CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c index 006ed09ce..99b690869 100644 --- a/src/tools/sss_groupdel.c +++ b/src/tools/sss_groupdel.c @@ -58,18 +58,14 @@ int main(int argc, const char **argv) pc = poptGetContext(NULL, argc, argv, long_options, 0); poptSetOtherOptionHelp(pc, "GROUPNAME"); if ((ret = poptGetNextOpt(pc)) < -1) { - usage(pc, poptStrerror(ret)); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } debug_level = pc_debug; pc_groupname = poptGetArg(pc); if (pc_groupname == NULL) { - usage(pc, _("Specify group to delete\n")); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, _("Specify group to delete\n"), ret, fini); } CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_groupmod.c b/src/tools/sss_groupmod.c index bd684ba0c..59ec10bab 100644 --- a/src/tools/sss_groupmod.c +++ b/src/tools/sss_groupmod.c @@ -73,31 +73,29 @@ int main(int argc, const char **argv) case 'a': addgroups = poptGetOptArg(pc); if (addgroups == NULL) { - ret = -1; + BAD_POPT_PARAMS(pc, _("Specify group to add to\n"), + ret, fini); } break; case 'r': rmgroups = poptGetOptArg(pc); if (rmgroups == NULL) { - ret = -1; + BAD_POPT_PARAMS(pc, _("Specify group to remove from\n"), + ret, fini); } break; } } if (ret != -1) { - usage(pc, poptStrerror(ret)); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } /* groupname is an argument without --option */ pc_groupname = poptGetArg(pc); if (pc_groupname == NULL) { - usage(pc, _("Specify group to modify\n")); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, _("Specify group to modify\n"), ret, fini); } debug_level = pc_debug; diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c index be28f165f..15324855c 100644 --- a/src/tools/sss_groupshow.c +++ b/src/tools/sss_groupshow.c @@ -647,16 +647,12 @@ int main(int argc, const char **argv) debug_level = pc_debug; if (ret != -1) { - usage(pc, poptStrerror(ret)); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } pc_groupname = poptGetArg(pc); if (pc_groupname == NULL) { - usage(pc, _("Specify group to show\n")); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, _("Specify group to show\n"), ret, fini); } CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c index f9b95155e..edff6e141 100644 --- a/src/tools/sss_useradd.c +++ b/src/tools/sss_useradd.c @@ -80,7 +80,10 @@ int main(int argc, const char **argv) switch (ret) { case 'G': groups = poptGetOptArg(pc); - if (!groups) goto fini; + if (!groups) { + BAD_POPT_PARAMS(pc, _("Specify group to add to\n"), + ret, fini); + } break; case 'm': @@ -96,17 +99,13 @@ int main(int argc, const char **argv) debug_level = pc_debug; if (ret != -1) { - usage(pc, poptStrerror(ret)); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } /* username is an argument without --option */ pc_username = poptGetArg(pc); if (pc_username == NULL) { - usage(pc, (_("Specify user to add\n"))); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, _("Specify user to add\n"), ret, fini); } CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c index 869ec9c80..1d0cb12b4 100644 --- a/src/tools/sss_userdel.c +++ b/src/tools/sss_userdel.c @@ -176,16 +176,12 @@ int main(int argc, const char **argv) debug_level = pc_debug; if (ret != -1) { - usage(pc, poptStrerror(ret)); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } pc_username = poptGetArg(pc); if (pc_username == NULL) { - usage(pc, _("Specify user to delete\n")); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, _("Specify user to delete\n"), ret, fini); } CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_usermod.c b/src/tools/sss_usermod.c index 54e3304ff..bcf2b3a24 100644 --- a/src/tools/sss_usermod.c +++ b/src/tools/sss_usermod.c @@ -82,14 +82,16 @@ int main(int argc, const char **argv) case 'a': addgroups = poptGetOptArg(pc); if (addgroups == NULL) { - ret = -1; + BAD_POPT_PARAMS(pc, _("Specify group to add to\n"), + ret, fini); } break; case 'r': rmgroups = poptGetOptArg(pc); if (rmgroups == NULL) { - ret = -1; + BAD_POPT_PARAMS(pc, _("Specify group to remove from\n"), + ret, fini); } break; @@ -104,9 +106,7 @@ int main(int argc, const char **argv) } if (ret != -1) { - usage(pc, poptStrerror(ret)); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } debug_level = pc_debug; @@ -114,9 +114,7 @@ int main(int argc, const char **argv) /* username is an argument without --option */ pc_username = poptGetArg(pc); if (pc_username == NULL) { - usage(pc, _("Specify user to modify\n")); - ret = EXIT_FAILURE; - goto fini; + BAD_POPT_PARAMS(pc, _("Specify user to modify\n"), ret, fini); } CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c index e76ffe761..96ca58436 100644 --- a/src/tools/tools_util.c +++ b/src/tools/tools_util.c @@ -139,6 +139,11 @@ int parse_group_name_domain(struct tools_ctx *tctx, for (i = 0; groups[i]; ++i) { ret = sss_parse_name(tctx, tctx->snctx, groups[i], &domain, &name); + if (ret != EOK) { + DEBUG(1, ("Invalid name in group list, skipping: [%s] (%d)\n", + groups[i], ret)); + continue; + } /* If FQDN is specified, it must be within the same domain as user */ if (domain) { diff --git a/src/tools/tools_util.h b/src/tools/tools_util.h index 84fc3be55..e8b253616 100644 --- a/src/tools/tools_util.h +++ b/src/tools/tools_util.h @@ -27,6 +27,12 @@ #include "util/util.h" +#define BAD_POPT_PARAMS(pc, msg, val, label) do { \ + usage(pc, msg); \ + val = EXIT_FAILURE; \ + goto label; \ +} while(0) + #define CHECK_ROOT(val, prg_name) do { \ val = getuid(); \ if (val != 0) { \ |