diff options
Diffstat (limited to 'source4/scripting/ejs/smbcalls_creds.c')
-rw-r--r-- | source4/scripting/ejs/smbcalls_creds.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c index 61a5139cda..45da5895e4 100644 --- a/source4/scripting/ejs/smbcalls_creds.c +++ b/source4/scripting/ejs/smbcalls_creds.c @@ -23,6 +23,7 @@ #include "includes.h" #include "scripting/ejs/smbcalls.h" #include "lib/appweb/ejs/ejs.h" +#include "lib/cmdline/popt_common.h" /* helper function to get the local objects credentials ptr @@ -184,19 +185,9 @@ static int ejs_creds_get_workstation(MprVarHandle eid, int argc, struct MprVar * /* initialise credentials ejs object */ -static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv) +static int ejs_credentials_obj(MprVarHandle eid, int argc, struct MprVar **argv, struct cli_credentials *creds) { struct MprVar *obj = mprInitObject(eid, "credentials", argc, argv); - struct cli_credentials *creds; - - creds = cli_credentials_init(mprMemCtx()); - if (creds == NULL) { - return -1; - } - - cli_credentials_guess(creds); - cli_credentials_set_username(creds, "", CRED_GUESSED); - cli_credentials_set_password(creds, "", CRED_GUESSED); mprSetPtrChild(obj, "creds", creds); @@ -217,6 +208,30 @@ static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv /* + initialise credentials ejs object +*/ +static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct cli_credentials *creds; + + creds = cli_credentials_init(mprMemCtx()); + if (creds == NULL) { + return -1; + } + + return ejs_credentials_obj(eid, argc, argv, creds); +} + +/* + initialise cmdline credentials ejs object +*/ +int ejs_credentials_cmdline(int eid, int argc, struct MprVar **argv) +{ + return ejs_credentials_obj(eid, argc, argv, cmdline_credentials); +} + + +/* setup C functions that be called from ejs */ void smb_setup_ejs_credentials(void) |