diff options
author | Stefan Metzmacher <metze@samba.org> | 2007-01-19 15:37:20 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:43:50 -0500 |
commit | cde247b7d052af6296cbb425e44eca90653fddae (patch) | |
tree | c31172881a21428ee680769c055a6db4475cacb5 /source4/scripting | |
parent | 0f6a080ee3b7e773c595cf67a402eaab81da079f (diff) | |
download | samba-cde247b7d052af6296cbb425e44eca90653fddae.tar.gz samba-cde247b7d052af6296cbb425e44eca90653fddae.tar.bz2 samba-cde247b7d052af6296cbb425e44eca90653fddae.zip |
r20908: - fix uninitialized usage of 'ctx'
- remove unused mem_ctx variable
- copy the userman_domain string as child of obj
metze
(This used to be commit 575938753bb2f3b8593f240234cff71995a28df8)
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/ejs/ejsnet/net_user.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/source4/scripting/ejs/ejsnet/net_user.c b/source4/scripting/ejs/ejsnet/net_user.c index a13e84c147..24fc46f842 100644 --- a/source4/scripting/ejs/ejsnet/net_user.c +++ b/source4/scripting/ejs/ejsnet/net_user.c @@ -41,11 +41,17 @@ static int ejs_net_userlist(MprVarHandle eid, int argc, struct MprVar **argv); */ int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv) { - TALLOC_CTX *mem_ctx; struct libnet_context *ctx; const char *userman_domain = NULL; struct MprVar *obj = NULL; + /* libnet context */ + ctx = mprGetThisPtr(eid, "ctx"); + if (ctx == NULL) { + ejsSetErrorMsg(eid, "ctx property returns null pointer"); + return 0; + } + /* fetch the arguments: domain name */ if (argc == 0) { /* default domain name is supplied in credentials */ @@ -54,31 +60,25 @@ int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv) } else if (argc == 1 && mprVarIsString(argv[0]->type)) { /* domain name can also be specified explicitly (e.g. to connect remote domain) */ - userman_domain = talloc_strdup(ctx, mprToString(argv[0])); + userman_domain = mprToString(argv[0]); } else { ejsSetErrorMsg(eid, "too many arguments"); - goto done; + return 0; } - /* libnet context */ - ctx = mprGetThisPtr(eid, "ctx"); - if (ctx == NULL) { - ejsSetErrorMsg(eid, "ctx property returns null pointer"); - goto done; - } - - mem_ctx = talloc_new(mprMemCtx()); - /* any domain name must be specified anyway */ if (userman_domain == NULL) { ejsSetErrorMsg(eid, "a domain must be specified for user management"); - goto done; + return 0; } - + /* create 'net user' subcontext */ obj = mprInitObject(eid, "NetUsrCtx", argc, argv); + /* we need to make a copy of the string for this object */ + userman_domain = talloc_strdup(obj, userman_domain); + /* add properties */ mprSetPtrChild(obj, "ctx", ctx); mprSetPtrChild(obj, "domain", userman_domain); @@ -89,8 +89,6 @@ int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv) mprSetStringCFunction(obj, "Info", ejs_net_userinfo); mprSetCFunction(obj, "List", ejs_net_userlist); -done: - talloc_free(mem_ctx); return 0; } |