summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-03-09 00:28:43 +0100
committerStephen Gallagher <sgallagh@redhat.com>2009-03-09 06:58:56 -0400
commit9a86aa6fb50926689befb0d8950312d2e97e30b0 (patch)
treeefddc4a53ba1fea122098d88fc9939ed60ce335c
parent53ca322a5d6c538a7e47613aaacaba33986291d7 (diff)
downloadsssd-9a86aa6fb50926689befb0d8950312d2e97e30b0.tar.gz
sssd-9a86aa6fb50926689befb0d8950312d2e97e30b0.tar.bz2
sssd-9a86aa6fb50926689befb0d8950312d2e97e30b0.zip
Fix parameter parsing and adding to groups in useradd
-rw-r--r--server/tools/sss_useradd.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c
index 98f83774..0897cfde 100644
--- a/server/tools/sss_useradd.c
+++ b/server/tools/sss_useradd.c
@@ -65,7 +65,10 @@ static int parse_groups(TALLOC_CTX *mem_ctx, const char *optstr, char ***_out)
n = orig;
tokens = 1;
- while ((n = strchr(n, delim))) tokens++;
+ while ((n = strchr(n, delim))) {
+ n++;
+ tokens++;
+ }
out = talloc_array(mem_ctx, char *, tokens+1);
if (!out) {
@@ -78,13 +81,13 @@ static int parse_groups(TALLOC_CTX *mem_ctx, const char *optstr, char ***_out)
o = n;
n = strchr(n, delim);
if (!n) {
- talloc_free(orig);
- return ERANGE;
+ break;
}
*n = '\0';
n++;
out[i] = talloc_strdup(out, o);
}
+ out[tokens-1] = talloc_strdup(out, o);
out[tokens] = NULL;
talloc_free(orig);
@@ -250,6 +253,9 @@ static void add_to_groups(void *pvt, int error, struct ldb_result *ignore)
add_to_groups, user_ctx);
if (ret != EOK)
add_user_done(user_ctx, ret, NULL);
+
+ /* go on to next group */
+ user_ctx->cur++;
}
int main(int argc, const char **argv)
@@ -266,7 +272,7 @@ int main(int argc, const char **argv)
{ "gecos", 'c', POPT_ARG_STRING, &pc_gecos, 0, "The comment string", NULL },
{ "home", 'h', POPT_ARG_STRING, &pc_home, 0, "Home directory", NULL },
{ "shell", 's', POPT_ARG_STRING, &pc_shell, 0, "Login shell", NULL },
- { "groups", 'G', POPT_ARG_STRING, NULL, 0, "Groups", NULL },
+ { "groups", 'G', POPT_ARG_STRING, NULL, 'G', "Groups", NULL },
POPT_TABLEEND
};
poptContext pc = NULL;