summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-08-31 18:12:25 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-09-08 09:36:22 -0400
commit8443d24c0584f45151e0c80506d7a572b8a38ed7 (patch)
tree3df77db1747c04ed38095bb6b78087c6534adc50 /src/tools
parent4f6a396fcf16f97b2abc3d0cba10e9aa9bc38619 (diff)
downloadsssd-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.c8
-rw-r--r--src/tools/sss_groupdel.c8
-rw-r--r--src/tools/sss_groupmod.c14
-rw-r--r--src/tools/sss_groupshow.c8
-rw-r--r--src/tools/sss_useradd.c13
-rw-r--r--src/tools/sss_userdel.c8
-rw-r--r--src/tools/sss_usermod.c14
-rw-r--r--src/tools/tools_util.c5
-rw-r--r--src/tools/tools_util.h6
9 files changed, 37 insertions, 47 deletions
diff --git a/src/tools/sss_groupadd.c b/src/tools/sss_groupadd.c
index e5ef7218..8817625d 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 006ed09c..99b69086 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 bd684ba0..59ec10ba 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 be28f165..15324855 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 f9b95155..edff6e14 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 869ec9c8..1d0cb12b 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 54e3304f..bcf2b3a2 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 e76ffe76..96ca5843 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 84fc3be5..e8b25361 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) { \