summaryrefslogtreecommitdiffstats
path: root/server/tools
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-03-08 00:18:59 +0100
committerStephen Gallagher <sgallagh@redhat.com>2009-03-08 10:15:04 -0400
commit434c6d075f41f01a875756a02dd01fc802148ada (patch)
tree9fcdaf5d1f99b19bb2c204319eba1bccbac432a2 /server/tools
parent4c4bfc1a9590b3da9c901194f84dcb189481b25a (diff)
downloadsssd-434c6d075f41f01a875756a02dd01fc802148ada.tar.gz
sssd-434c6d075f41f01a875756a02dd01fc802148ada.tar.xz
sssd-434c6d075f41f01a875756a02dd01fc802148ada.zip
Fix initialization problems
Init tools ctx in groupadd before copying its value
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/sss_groupadd.c15
-rw-r--r--server/tools/sss_groupdel.c2
-rw-r--r--server/tools/sss_useradd.c4
-rw-r--r--server/tools/sss_userdel.c2
4 files changed, 12 insertions, 11 deletions
diff --git a/server/tools/sss_groupadd.c b/server/tools/sss_groupadd.c
index 61f49c723..e36e220fe 100644
--- a/server/tools/sss_groupadd.c
+++ b/server/tools/sss_groupadd.c
@@ -84,19 +84,13 @@ int main(int argc, const char **argv)
POPT_TABLEEND
};
- poptContext pc;
+ poptContext pc = NULL;
struct tools_ctx *ctx = NULL;
struct group_add_ctx *group_ctx = NULL;
int ret = EXIT_SUCCESS;
debug_prg_name = argv[0];
- group_ctx = talloc_zero(NULL, struct group_add_ctx);
- if (group_ctx == NULL) {
- DEBUG(0, ("Could not allocate memory for group_ctx context\n"));
- return ENOMEM;
- }
- group_ctx->ctx = ctx;
/* arguments processed, go on to actual work */
ret = setup_db(&ctx);
@@ -106,6 +100,13 @@ int main(int argc, const char **argv)
goto fini;
}
+ group_ctx = talloc_zero(NULL, struct group_add_ctx);
+ if (group_ctx == NULL) {
+ DEBUG(0, ("Could not allocate memory for group_ctx context\n"));
+ return ENOMEM;
+ }
+ group_ctx->ctx = ctx;
+
/* parse params */
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "GROUPNAME");
diff --git a/server/tools/sss_groupdel.c b/server/tools/sss_groupdel.c
index 1950aaef1..1cbddf458 100644
--- a/server/tools/sss_groupdel.c
+++ b/server/tools/sss_groupdel.c
@@ -81,7 +81,7 @@ int main(int argc, const char **argv)
struct tools_ctx *ctx = NULL;
- poptContext pc;
+ poptContext pc = NULL;
struct poptOption long_options[] = {
POPT_AUTOHELP
POPT_TABLEEND
diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c
index 2cf7826eb..98f837742 100644
--- a/server/tools/sss_useradd.c
+++ b/server/tools/sss_useradd.c
@@ -269,9 +269,9 @@ int main(int argc, const char **argv)
{ "groups", 'G', POPT_ARG_STRING, NULL, 0, "Groups", NULL },
POPT_TABLEEND
};
- poptContext pc;
+ poptContext pc = NULL;
struct user_add_ctx *user_ctx = NULL;
- struct tools_ctx *ctx;
+ struct tools_ctx *ctx = NULL;
char *groups;
int ret;
diff --git a/server/tools/sss_userdel.c b/server/tools/sss_userdel.c
index e0f6300ee..1a56cf9d8 100644
--- a/server/tools/sss_userdel.c
+++ b/server/tools/sss_userdel.c
@@ -80,7 +80,7 @@ int main(int argc, const char **argv)
struct tools_ctx *ctx = NULL;
- poptContext pc;
+ poptContext pc = NULL;
struct poptOption long_options[] = {
POPT_AUTOHELP
POPT_TABLEEND