From 8754c793bfe79e87febb026e5915e054c23cfede Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 29 May 2005 11:35:56 +0000 Subject: r7072: moved the esp hooks calls to the ejs level, so we can call them from both esp scripts and ejs scripts. This allows the smbscript program to call all the existing extension calls like lpGet() and ldbSearch() Also fixed smbscript to load smb.conf, and setup logging for DEBUG() I left the unixAuth() routine in web_server/calls.c at the moment, as that is really only useful for esp scripts. I imagine that as we extend esp/ejs, we will put some functions in scripting/ejs/ for use in both ejs and esp, and some functions in web_server/ where they will only be accessed by esp web scripts (This used to be commit e59ae64f60d388a5634559e4e0887e4676b70871) --- source4/scripting/ejs/smbcalls.c | 259 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 source4/scripting/ejs/smbcalls.c (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c new file mode 100644 index 0000000000..664bb74df3 --- /dev/null +++ b/source4/scripting/ejs/smbcalls.c @@ -0,0 +1,259 @@ +/* + Unix SMB/CIFS implementation. + + provide hooks into smbd C calls from ejs scripts + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#include "param/loadparm.h" +#include "lib/ldb/include/ldb.h" + +/* + return the type of a variable +*/ +static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) +{ + const struct { + MprType type; + const char *name; + } types[] = { + { MPR_TYPE_UNDEFINED, "undefined" }, + { MPR_TYPE_NULL, "null" }, + { MPR_TYPE_BOOL, "boolean" }, + { MPR_TYPE_CFUNCTION, "function" }, + { MPR_TYPE_FLOAT, "float" }, + { MPR_TYPE_INT, "int" }, + { MPR_TYPE_INT64, "int64" }, + { MPR_TYPE_OBJECT, "object" }, + { MPR_TYPE_FUNCTION, "function" }, + { MPR_TYPE_STRING, "string" }, + { MPR_TYPE_STRING_CFUNCTION, "function" } + }; + int i; + const char *type = "unknown"; + + if (argc != 1) return -1; + + for (i=0;itype == types[i].type) { + type = types[i].name; + break; + } + } + + ejsSetReturnString(eid, type); + return 0; +} + +/* + setup a return of a string list +*/ +static void ejs_returnlist(MprVarHandle eid, + const char *name, const char **list) +{ + ejsSetReturnValue(eid, mprList(name, list)); +} + +/* + return a list of defined services +*/ +static int ejs_lpServices(MprVarHandle eid, int argc, char **argv) +{ + int i; + const char **list = NULL; + if (argc != 0) return -1; + + for (i=0;iclass == P_GLOBAL) { + return -1; + } + parm_ptr = lp_parm_ptr(snum, parm); + } else if (strchr(argv[0], ':')) { + /* its a global parametric option */ + const char *type = talloc_strndup(mprMemCtx(), + argv[0], strcspn(argv[0], ":")); + const char *option = strchr(argv[0], ':') + 1; + const char *value; + if (type == NULL || option == NULL) return -1; + value = lp_get_parametric(-1, type, option); + if (value == NULL) return -1; + ejsSetReturnString(eid, value); + return 0; + } else { + /* its a global parameter */ + parm = lp_parm_struct(argv[0]); + if (parm == NULL) return -1; + parm_ptr = parm->ptr; + } + + if (parm == NULL || parm_ptr == NULL) { + return -1; + } + + /* construct and return the right type of ejs object */ + switch (parm->type) { + case P_STRING: + case P_USTRING: + ejsSetReturnString(eid, *(char **)parm_ptr); + break; + case P_BOOL: + ejsSetReturnValue(eid, mprCreateBoolVar(*(BOOL *)parm_ptr)); + break; + case P_INTEGER: + ejsSetReturnValue(eid, mprCreateIntegerVar(*(int *)parm_ptr)); + break; + case P_ENUM: + for (i=0; parm->enum_list[i].name; i++) { + if (*(int *)parm_ptr == parm->enum_list[i].value) { + ejsSetReturnString(eid, parm->enum_list[i].name); + return 0; + } + } + return -1; + case P_LIST: + ejs_returnlist(eid, parm->label, *(const char ***)parm_ptr); + break; + case P_SEP: + return -1; + } + return 0; +} + + +/* + perform an ldb search, returning an array of results + + syntax: + ldbSearch("dbfile", "expression"); + var attrs = new Array("attr1", "attr2", "attr3"); + ldbSearch("dbfile", "expression", attrs); +*/ +static int ejs_ldbSearch(MprVarHandle eid, int argc, struct MprVar **argv) +{ + const char **attrs = NULL; + const char *expression, *dbfile; + TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); + struct ldb_context *ldb; + int ret; + struct ldb_message **res; + + /* validate arguments */ + if (argc < 2 || argc > 3 || + argv[0]->type != MPR_TYPE_STRING) { + ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); + goto failed; + } + if (argc == 3 && argv[2]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "ldbSearch attributes must be an object"); + goto failed; + } + + dbfile = mprToString(argv[0]); + expression = mprToString(argv[1]); + if (argc > 2) { + attrs = mprToList(tmp_ctx, argv[2]); + } + if (dbfile == NULL || expression == NULL) { + ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); + goto failed; + } + + ldb = ldb_wrap_connect(tmp_ctx, dbfile, 0, NULL); + if (ldb == NULL) { + ejsSetErrorMsg(eid, "ldbSearch failed to open %s", dbfile); + goto failed; + } + + ret = ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT, expression, attrs, &res); + if (ret == -1) { + ejsSetErrorMsg(eid, "ldbSearch failed - %s", ldb_errstring(ldb)); + goto failed; + } + + ejsSetReturnValue(eid, mprLdbArray(res, ret, "ldb_message")); + + talloc_free(tmp_ctx); + return 0; + +failed: + talloc_free(tmp_ctx); + return -1; +} + + +/* + setup the C functions that be called from ejs +*/ +void smb_setup_ejs_functions(void) +{ + ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, 0); + ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, 0); + ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, 0); + ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, 0); +} -- cgit From 09e00bbdc18741c20f2eeba83da742f056115789 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 29 May 2005 12:41:59 +0000 Subject: r7078: - fix an uninitialised variable in smbscript - fixed handle passing in the smb/ejs interface calls, so they can be called safely from esp (This used to be commit 45ea1b64413de577366939b2106f657f6c47b1bd) --- source4/scripting/ejs/smbcalls.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 664bb74df3..e436fc78df 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -252,8 +252,8 @@ failed: */ void smb_setup_ejs_functions(void) { - ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, 0); - ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, 0); - ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, 0); - ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, 0); + ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 4f1a5b716972bc2af916a528399c9dc0c2f18c35 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 22:14:21 +0000 Subject: r7083: Add a ejs hook to the resolve_name() function. We need to figure out what the best way to return NTSTATUS codes. In the Python wrappers I threw an exception which could be caught by some code, but I'm not sure whether this is possible in ejs. (This used to be commit 6911e46c6a576a379ea06f9ba3ef6a62653170f0) --- source4/scripting/ejs/smbcalls.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index e436fc78df..02b40c46d8 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -24,6 +24,7 @@ #include "lib/ejs/ejs.h" #include "param/loadparm.h" #include "lib/ldb/include/ldb.h" +#include "librpc/gen_ndr/ndr_nbt.h" /* return the type of a variable @@ -246,6 +247,55 @@ failed: return -1; } +/* + look up a netbios name + + syntax: + resolveName("frogurt"); + resolveName("frogurt", 0x1c); +*/ + +static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct nbt_name name; + TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); + NTSTATUS result; + const char *reply_addr; + + /* validate arguments */ + if (argc == 1) { + if (argv[0]->type != MPR_TYPE_STRING) { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto failed; + } + make_nbt_name_client(&name, mprToString(argv[0])); + } else if (argc == 2) { + if (argv[1]->type != MPR_TYPE_INT) { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto failed; + } + make_nbt_name(&name, mprToString(argv[0]), mprToInt(argv[1])); + } else { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto failed; + } + + result = resolve_name(&name, tmp_ctx, &reply_addr); + + if (!NT_STATUS_IS_OK(result)) { + ejsSetErrorMsg(eid, "resolveName name not found"); + goto failed; + } + + ejsSetReturnString(eid, reply_addr); + + talloc_free(tmp_ctx); + return 0; + + failed: + talloc_free(tmp_ctx); + return -1; +} /* setup the C functions that be called from ejs @@ -256,4 +306,5 @@ void smb_setup_ejs_functions(void) ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From a05bd5e9d654b97e1a2128a5048b68b7efd9ccd7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 31 May 2005 04:12:55 +0000 Subject: r7135: make typeof() complient with ECMA 11.4.3 (This used to be commit 29ab4cc6cb244255ab75af7ae2076b51209f4f2d) --- source4/scripting/ejs/smbcalls.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 02b40c46d8..fc2c16a456 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -35,20 +35,20 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) MprType type; const char *name; } types[] = { - { MPR_TYPE_UNDEFINED, "undefined" }, - { MPR_TYPE_NULL, "null" }, - { MPR_TYPE_BOOL, "boolean" }, - { MPR_TYPE_CFUNCTION, "function" }, - { MPR_TYPE_FLOAT, "float" }, - { MPR_TYPE_INT, "int" }, - { MPR_TYPE_INT64, "int64" }, - { MPR_TYPE_OBJECT, "object" }, - { MPR_TYPE_FUNCTION, "function" }, - { MPR_TYPE_STRING, "string" }, + { MPR_TYPE_UNDEFINED, "undefined" }, + { MPR_TYPE_NULL, "object" }, + { MPR_TYPE_BOOL, "boolean" }, + { MPR_TYPE_CFUNCTION, "function" }, + { MPR_TYPE_FLOAT, "number" }, + { MPR_TYPE_INT, "number" }, + { MPR_TYPE_INT64, "number" }, + { MPR_TYPE_OBJECT, "object" }, + { MPR_TYPE_FUNCTION, "function" }, + { MPR_TYPE_STRING, "string" }, { MPR_TYPE_STRING_CFUNCTION, "function" } }; int i; - const char *type = "unknown"; + const char *type = NULL; if (argc != 1) return -1; @@ -58,6 +58,7 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) break; } } + if (type == NULL) return -1; ejsSetReturnString(eid, type); return 0; -- cgit From 266c37e5dc97879e30e790cd87d2ec1f43907477 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 3 Jun 2005 14:17:18 +0000 Subject: r7238: Add pam auth support in swat (This used to be commit 8a98572a3b5dba58181dc402dbebae5452656012) --- source4/scripting/ejs/smbcalls.c | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index fc2c16a456..8a02111bd5 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -25,6 +25,7 @@ #include "param/loadparm.h" #include "lib/ldb/include/ldb.h" #include "librpc/gen_ndr/ndr_nbt.h" +#include "auth/auth.h" /* return the type of a variable @@ -298,6 +299,85 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) return -1; } +static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) +{ + struct auth_usersupplied_info *user_info = NULL; + struct auth_serversupplied_info *server_info = NULL; + struct auth_context *auth_context; + TALLOC_CTX *tmp_ctx; + struct MprVar auth; + NTSTATUS nt_status; + DATA_BLOB pw_blob; + int ret; + + if (argc != 3 || *argv[0] == 0 || *argv[2] == 0) { + ejsSetErrorMsg(eid, "userAuth invalid arguments"); + return -1; + } + + tmp_ctx = talloc_new(mprMemCtx()); + auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); + + if (strcmp("System User", argv[2]) == 0) { + const char *auth_unix[] = { "unix", NULL }; + + nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Auth System Failure", 0)); + goto done; + } + + pw_blob = data_blob(argv[1], strlen(argv[1])), + make_user_info(tmp_ctx, argv[0], argv[0], + argv[2], argv[2], + "foowks", "fooip", + NULL, NULL, + NULL, NULL, + &pw_blob, False, + 0x05, &user_info); + nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Login Failed", 0)); + goto done; + } + + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(server_info->authenticated)); + mprSetPropertyValue(&auth, "username", mprCreateStringVar(server_info->account_name, 0)); + mprSetPropertyValue(&auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); + + } else { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 0)); + } + +done: + ejsSetReturnValue(eid, auth); + talloc_free(tmp_ctx); + return 0; +} + +static int ejs_domain_list(MprVarHandle eid, int argc, char **argv) +{ + struct MprVar list; + struct MprVar dom; + + if (argc != 0) { + ejsSetErrorMsg(eid, "domList invalid arguments"); + return -1; + } + + list = mprCreateObjVar("list", MPR_DEFAULT_HASH_SIZE); + dom = mprCreateStringVar("System User", 1); + mprCreateProperty(&list, "0", &dom); + + ejsSetReturnValue(eid, list); + + return 0; +} + + /* setup the C functions that be called from ejs */ @@ -308,4 +388,6 @@ void smb_setup_ejs_functions(void) ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 383c5fb68a212eed60750793ad4b7e4bbcbcd2d5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 01:08:52 +0000 Subject: r7255: Change syntax of resolveName() js function to be more like the resolve_name() C function. I can't figure out how to return variables by reference though. Writing to argv[] doesn't seem to work. (This used to be commit aef99859f28570b60f4fefe2981160269f6eb02a) --- source4/scripting/ejs/smbcalls.c | 54 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 8a02111bd5..5d4c61b04b 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -253,50 +253,53 @@ failed: look up a netbios name syntax: - resolveName("frogurt"); - resolveName("frogurt", 0x1c); + resolveName(result, "frogurt"); + resolveName(result, "frogurt", 0x1c); */ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) { + int result = -1; struct nbt_name name; TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - NTSTATUS result; + NTSTATUS nt_status; const char *reply_addr; /* validate arguments */ - if (argc == 1) { - if (argv[0]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto failed; - } - make_nbt_name_client(&name, mprToString(argv[0])); - } else if (argc == 2) { + if (argc < 2 || argc > 3) { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto done; + } + + if (argv[1]->type != MPR_TYPE_STRING) { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto done; + } + + if (argc == 2) { + make_nbt_name_client(&name, mprToString(argv[1])); + } else { if (argv[1]->type != MPR_TYPE_INT) { ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto failed; + goto done; } - make_nbt_name(&name, mprToString(argv[0]), mprToInt(argv[1])); - } else { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto failed; + make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2])); } - result = resolve_name(&name, tmp_ctx, &reply_addr); + result = 0; - if (!NT_STATUS_IS_OK(result)) { - ejsSetErrorMsg(eid, "resolveName name not found"); - goto failed; + nt_status = resolve_name(&name, tmp_ctx, &reply_addr); + + if (NT_STATUS_IS_OK(nt_status)) { + mprDestroyAllVars(argv[0]); + *argv[0] = mprCreateStringVar(reply_addr, True); } - - ejsSetReturnString(eid, reply_addr); - talloc_free(tmp_ctx); - return 0; + ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); - failed: + done: talloc_free(tmp_ctx); - return -1; + return result; } static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) @@ -308,7 +311,6 @@ static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) struct MprVar auth; NTSTATUS nt_status; DATA_BLOB pw_blob; - int ret; if (argc != 3 || *argv[0] == 0 || *argv[2] == 0) { ejsSetErrorMsg(eid, "userAuth invalid arguments"); -- cgit From b1243510793cd135f1464dcfeec0b7e88999d1a0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 03:32:18 +0000 Subject: r7261: Pass by reference is done in js via MPR_TYPE_OBJECT. Update argument parsing and example for resolveName(). (This used to be commit 1a4a54931733ebfa743401a184fe460c044427b4) --- source4/scripting/ejs/smbcalls.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 5d4c61b04b..93496bd9c9 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -271,6 +271,11 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) goto done; } + if (argv[0]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "resolvename invalid arguments"); + goto done; + } + if (argv[1]->type != MPR_TYPE_STRING) { ejsSetErrorMsg(eid, "resolveName invalid arguments"); goto done; @@ -291,8 +296,8 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) nt_status = resolve_name(&name, tmp_ctx, &reply_addr); if (NT_STATUS_IS_OK(nt_status)) { - mprDestroyAllVars(argv[0]); - *argv[0] = mprCreateStringVar(reply_addr, True); + mprSetPropertyValue(argv[0], "value", + mprCreateStringVar(reply_addr, 1)); } ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); -- cgit From f84d007c438dd43f2cd5a9b6ca583976c8e777fa Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 07:04:43 +0000 Subject: r7266: Split the different types of js function defines into separate files, as there are going to be a lot more of them. (This used to be commit b086768589ee27de6616945bbea42b18b40d25d5) --- source4/scripting/ejs/smbcalls.c | 250 ++------------------------------------- 1 file changed, 7 insertions(+), 243 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 93496bd9c9..54dc8d4e62 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -4,6 +4,7 @@ provide hooks into smbd C calls from ejs scripts Copyright (C) Andrew Tridgell 2005 + Copyright (C) Tim Potter 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,9 +23,6 @@ #include "includes.h" #include "lib/ejs/ejs.h" -#include "param/loadparm.h" -#include "lib/ldb/include/ldb.h" -#include "librpc/gen_ndr/ndr_nbt.h" #include "auth/auth.h" /* @@ -68,245 +66,11 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) /* setup a return of a string list */ -static void ejs_returnlist(MprVarHandle eid, - const char *name, const char **list) + void ejs_returnlist(MprVarHandle eid, const char *name, const char **list) { ejsSetReturnValue(eid, mprList(name, list)); } -/* - return a list of defined services -*/ -static int ejs_lpServices(MprVarHandle eid, int argc, char **argv) -{ - int i; - const char **list = NULL; - if (argc != 0) return -1; - - for (i=0;iclass == P_GLOBAL) { - return -1; - } - parm_ptr = lp_parm_ptr(snum, parm); - } else if (strchr(argv[0], ':')) { - /* its a global parametric option */ - const char *type = talloc_strndup(mprMemCtx(), - argv[0], strcspn(argv[0], ":")); - const char *option = strchr(argv[0], ':') + 1; - const char *value; - if (type == NULL || option == NULL) return -1; - value = lp_get_parametric(-1, type, option); - if (value == NULL) return -1; - ejsSetReturnString(eid, value); - return 0; - } else { - /* its a global parameter */ - parm = lp_parm_struct(argv[0]); - if (parm == NULL) return -1; - parm_ptr = parm->ptr; - } - - if (parm == NULL || parm_ptr == NULL) { - return -1; - } - - /* construct and return the right type of ejs object */ - switch (parm->type) { - case P_STRING: - case P_USTRING: - ejsSetReturnString(eid, *(char **)parm_ptr); - break; - case P_BOOL: - ejsSetReturnValue(eid, mprCreateBoolVar(*(BOOL *)parm_ptr)); - break; - case P_INTEGER: - ejsSetReturnValue(eid, mprCreateIntegerVar(*(int *)parm_ptr)); - break; - case P_ENUM: - for (i=0; parm->enum_list[i].name; i++) { - if (*(int *)parm_ptr == parm->enum_list[i].value) { - ejsSetReturnString(eid, parm->enum_list[i].name); - return 0; - } - } - return -1; - case P_LIST: - ejs_returnlist(eid, parm->label, *(const char ***)parm_ptr); - break; - case P_SEP: - return -1; - } - return 0; -} - - -/* - perform an ldb search, returning an array of results - - syntax: - ldbSearch("dbfile", "expression"); - var attrs = new Array("attr1", "attr2", "attr3"); - ldbSearch("dbfile", "expression", attrs); -*/ -static int ejs_ldbSearch(MprVarHandle eid, int argc, struct MprVar **argv) -{ - const char **attrs = NULL; - const char *expression, *dbfile; - TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - struct ldb_context *ldb; - int ret; - struct ldb_message **res; - - /* validate arguments */ - if (argc < 2 || argc > 3 || - argv[0]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); - goto failed; - } - if (argc == 3 && argv[2]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "ldbSearch attributes must be an object"); - goto failed; - } - - dbfile = mprToString(argv[0]); - expression = mprToString(argv[1]); - if (argc > 2) { - attrs = mprToList(tmp_ctx, argv[2]); - } - if (dbfile == NULL || expression == NULL) { - ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); - goto failed; - } - - ldb = ldb_wrap_connect(tmp_ctx, dbfile, 0, NULL); - if (ldb == NULL) { - ejsSetErrorMsg(eid, "ldbSearch failed to open %s", dbfile); - goto failed; - } - - ret = ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT, expression, attrs, &res); - if (ret == -1) { - ejsSetErrorMsg(eid, "ldbSearch failed - %s", ldb_errstring(ldb)); - goto failed; - } - - ejsSetReturnValue(eid, mprLdbArray(res, ret, "ldb_message")); - - talloc_free(tmp_ctx); - return 0; - -failed: - talloc_free(tmp_ctx); - return -1; -} - -/* - look up a netbios name - - syntax: - resolveName(result, "frogurt"); - resolveName(result, "frogurt", 0x1c); -*/ - -static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) -{ - int result = -1; - struct nbt_name name; - TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - NTSTATUS nt_status; - const char *reply_addr; - - /* validate arguments */ - if (argc < 2 || argc > 3) { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto done; - } - - if (argv[0]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "resolvename invalid arguments"); - goto done; - } - - if (argv[1]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto done; - } - - if (argc == 2) { - make_nbt_name_client(&name, mprToString(argv[1])); - } else { - if (argv[1]->type != MPR_TYPE_INT) { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto done; - } - make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2])); - } - - result = 0; - - nt_status = resolve_name(&name, tmp_ctx, &reply_addr); - - if (NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(argv[0], "value", - mprCreateStringVar(reply_addr, 1)); - } - - ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); - - done: - talloc_free(tmp_ctx); - return result; -} - static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) { struct auth_usersupplied_info *user_info = NULL; @@ -386,15 +150,15 @@ static int ejs_domain_list(MprVarHandle eid, int argc, char **argv) /* - setup the C functions that be called from ejs + setup C functions that be called from ejs */ void smb_setup_ejs_functions(void) { - ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE); + smb_setup_ejs_config(); + smb_setup_ejs_ldb(); + smb_setup_ejs_nbt(); + ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From b7bc13209f5133a117428f2ce58d995399fb684b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Jun 2005 08:23:15 +0000 Subject: r7267: REMOTE_HOST is a better choice (This used to be commit 41bae267e29614d300ec2505c927ab17ccbbe64f) --- source4/scripting/ejs/smbcalls.c | 99 ++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 34 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 54dc8d4e62..3ca6003ee4 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -71,54 +71,85 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) ejsSetReturnValue(eid, mprList(name, list)); } -static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) +static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, const char *password, const char *domain, const char *remote_host) { struct auth_usersupplied_info *user_info = NULL; struct auth_serversupplied_info *server_info = NULL; struct auth_context *auth_context; - TALLOC_CTX *tmp_ctx; - struct MprVar auth; + const char *auth_unix[] = { "unix", NULL }; NTSTATUS nt_status; DATA_BLOB pw_blob; - if (argc != 3 || *argv[0] == 0 || *argv[2] == 0) { - ejsSetErrorMsg(eid, "userAuth invalid arguments"); - return -1; + nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 0)); + goto done; } - tmp_ctx = talloc_new(mprMemCtx()); - auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); + pw_blob = data_blob(password, strlen(password)), + make_user_info(tmp_ctx, username, username, + domain, domain, + remote_host, remote_host, + NULL, NULL, + NULL, NULL, + &pw_blob, False, + USER_INFO_CASE_INSENSITIVE_USERNAME | + USER_INFO_DONT_CHECK_UNIX_ACCOUNT, + &user_info); + nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Login Failed", 0)); + goto done; + } - if (strcmp("System User", argv[2]) == 0) { - const char *auth_unix[] = { "unix", NULL }; + mprSetPropertyValue(auth, "result", mprCreateBoolVar(server_info->authenticated)); + mprSetPropertyValue(auth, "username", mprCreateStringVar(server_info->account_name, 0)); + mprSetPropertyValue(auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); - nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(&auth, "report", mprCreateStringVar("Auth System Failure", 0)); - goto done; - } +done: + return 0; +} - pw_blob = data_blob(argv[1], strlen(argv[1])), - make_user_info(tmp_ctx, argv[0], argv[0], - argv[2], argv[2], - "foowks", "fooip", - NULL, NULL, - NULL, NULL, - &pw_blob, False, - 0x05, &user_info); - nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(&auth, "report", mprCreateStringVar("Login Failed", 0)); - goto done; - } +/* + perform user authentication, returning an array of results + + syntax: + var authinfo = new Object(); + authinfo.username = myname; + authinfo.password = mypass; + authinfo.domain = mydom; + authinfo.rhost = request['REMOTE_HOST']; + auth = userAuth(authinfo); +*/ +static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) +{ + TALLOC_CTX *tmp_ctx; + const char *username; + const char *password; + const char *domain; + const char *remote_host; + struct MprVar auth; + + if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "userAuth invalid arguments, this function requires an object."); + return -1; + } + + username = mprToString(mprGetProperty(argv[0], "username", NULL)); + password = mprToString(mprGetProperty(argv[0], "password", NULL)); + domain = mprToString(mprGetProperty(argv[0], "domain", NULL)); + remote_host = mprToString(mprGetProperty(argv[0], "rhost", NULL)); + + tmp_ctx = talloc_new(mprMemCtx()); + auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); - mprSetPropertyValue(&auth, "result", mprCreateBoolVar(server_info->authenticated)); - mprSetPropertyValue(&auth, "username", mprCreateStringVar(server_info->account_name, 0)); - mprSetPropertyValue(&auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); + if (strcmp("System User", domain) == 0) { + ejs_systemAuth(tmp_ctx, &auth, username, password, domain, remote_host); } else { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 0)); } @@ -160,5 +191,5 @@ void smb_setup_ejs_functions(void) ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 791db4bf72f282840a7bfefa2a3ccf9b3191a6e6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Jun 2005 08:54:07 +0000 Subject: r7268: allocate the strings to avoid them disappearing under our feet (This used to be commit ddd7454cb3e2445fd32682b380be89c70f8a22cb) --- source4/scripting/ejs/smbcalls.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 3ca6003ee4..8ea5967ef4 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -83,7 +83,7 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char * nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); if (!NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 0)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 1)); goto done; } @@ -100,13 +100,13 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char * nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); if (!NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(auth, "report", mprCreateStringVar("Login Failed", 0)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Login Failed", 1)); goto done; } mprSetPropertyValue(auth, "result", mprCreateBoolVar(server_info->authenticated)); - mprSetPropertyValue(auth, "username", mprCreateStringVar(server_info->account_name, 0)); - mprSetPropertyValue(auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); + mprSetPropertyValue(auth, "username", mprCreateStringVar(server_info->account_name, 1)); + mprSetPropertyValue(auth, "domain", mprCreateStringVar(server_info->domain_name, 1)); done: return 0; @@ -151,7 +151,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) } else { mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 0)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 1)); } done: -- cgit From 8a2e208e45001305a4fa18f92c4109a33b6ed407 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 7 Jun 2005 06:38:13 +0000 Subject: r7350: Remove unused label. (This used to be commit ada004595760605134eb741da9c549521938c2ce) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 8ea5967ef4..00a2547bac 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -154,7 +154,6 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 1)); } -done: ejsSetReturnValue(eid, auth); talloc_free(tmp_ctx); return 0; -- cgit From 6eae7eb3c446e26d8003846a79471e6232b1b92e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 7 Jun 2005 07:00:28 +0000 Subject: r7351: Start of ejs smb client library. I need to figure out a nice API here that doesn't expose too much of the cifs protocol but still allows people to do neat things. Also, talloc lifetimes need to be thought about properly. (This used to be commit 8062e808ef5102b96e1b3de046c858e4a69b4d82) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 00a2547bac..46fce4b98e 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -187,6 +187,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_config(); smb_setup_ejs_ldb(); smb_setup_ejs_nbt(); + smb_setup_ejs_cli(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From 16a5d7c1755ece7f93db0eba42844152c916c11d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 11 Jun 2005 02:39:14 +0000 Subject: r7477: Add MPR_TYPE_PTR to ejs_typeof(). (This used to be commit 8574f64ca2bda864f472067ae594285b6f5dc957) --- source4/scripting/ejs/smbcalls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 46fce4b98e..1b5737db29 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -44,7 +44,8 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) { MPR_TYPE_OBJECT, "object" }, { MPR_TYPE_FUNCTION, "function" }, { MPR_TYPE_STRING, "string" }, - { MPR_TYPE_STRING_CFUNCTION, "function" } + { MPR_TYPE_STRING_CFUNCTION, "function" }, + { MPR_TYPE_PTR, "C pointer" } }; int i; const char *type = NULL; -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/scripting/ejs/smbcalls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1b5737db29..6444ec63cc 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -81,7 +81,10 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char * NTSTATUS nt_status; DATA_BLOB pw_blob; - nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); + /* + darn, we need some way to get the right event_context here + */ + nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context, NULL); if (!NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 1)); -- cgit From 643e5d8239ba105a5ac99ecc513289a17402714b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Jul 2005 05:21:17 +0000 Subject: r8069: the beginnings of code to allow rpc calls to be made from ejs tpot, note that this shows how you can modify passed in MprVar variables in C call (This used to be commit a782541db3de6ca3b599a220265cf9e6cb0c4d7b) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 6444ec63cc..041bd59f1a 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -192,6 +192,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_ldb(); smb_setup_ejs_nbt(); smb_setup_ejs_cli(); + smb_setup_ejs_rpc(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From c11204339ae86604a6edd6491f5ee03bf5e3c950 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Jul 2005 04:55:07 +0000 Subject: r8220: added auto-generation of ENUM constants in ejs wrapper. So we can now use the enum name instead of a integer in ejs scripts making rpc calls (This used to be commit a61cdee384c3002860016c1740276529493d318d) --- source4/scripting/ejs/smbcalls.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 041bd59f1a..0f43da349d 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -198,3 +198,11 @@ void smb_setup_ejs_functions(void) ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } + +/* + setup constants that can be used from ejs +*/ +void smb_setup_ejs_constants(int eid) +{ + smb_setup_ejs_rpc_constants(eid); +} -- cgit From c851532bece629e114382e2c3571a18bf9b42be4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Jul 2005 07:26:45 +0000 Subject: r8230: prevent authentication dying on a NULL domain (This used to be commit e1cfc6d03244e04d59a96ef2abb5b48fcb157b0a) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 0f43da349d..ab5101db6d 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -149,7 +149,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) tmp_ctx = talloc_new(mprMemCtx()); auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); - if (strcmp("System User", domain) == 0) { + if (domain && strcmp("System User", domain) == 0) { ejs_systemAuth(tmp_ctx, &auth, username, password, domain, remote_host); } else { -- cgit From fe1cf1eeb7c1b5955cdd2a44540bb46f82490f9a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Jul 2005 05:24:35 +0000 Subject: r8254: fixed a valgrind error in the unix auth code (This used to be commit ad1a4802d0634960646a6efe039fe8b62ead63dd) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index ab5101db6d..d8bb0c20a5 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -91,7 +91,7 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char * goto done; } - pw_blob = data_blob(password, strlen(password)), + pw_blob = data_blob(password, strlen(password)+1), make_user_info(tmp_ctx, username, username, domain, domain, remote_host, remote_host, -- cgit From 60ec75cbc7dccfceec9c57799e2af5be21a08609 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Jul 2005 02:37:50 +0000 Subject: r8276: fixed the remaining memory leaks in smbscript. We can now loop doing lots of rpc calls without memory usage increasing. (This used to be commit 9c885a7edb771486793eb287288158157b34e8f3) --- source4/scripting/ejs/smbcalls.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index d8bb0c20a5..75702e4e76 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -24,6 +24,7 @@ #include "includes.h" #include "lib/ejs/ejs.h" #include "auth/auth.h" +#include "scripting/ejs/smbcalls.h" /* return the type of a variable @@ -60,16 +61,16 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) } if (type == NULL) return -1; - ejsSetReturnString(eid, type); + mpr_ReturnString(eid, type); return 0; } /* setup a return of a string list */ - void ejs_returnlist(MprVarHandle eid, const char *name, const char **list) +void ejs_returnlist(int eid, const char *name, const char **list) { - ejsSetReturnValue(eid, mprList(name, list)); + mpr_Return(eid, mprList(name, list)); } static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, const char *password, const char *domain, const char *remote_host) @@ -158,7 +159,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 1)); } - ejsSetReturnValue(eid, auth); + mpr_Return(eid, auth); talloc_free(tmp_ctx); return 0; } @@ -166,7 +167,6 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) static int ejs_domain_list(MprVarHandle eid, int argc, char **argv) { struct MprVar list; - struct MprVar dom; if (argc != 0) { ejsSetErrorMsg(eid, "domList invalid arguments"); @@ -174,10 +174,9 @@ static int ejs_domain_list(MprVarHandle eid, int argc, char **argv) } list = mprCreateObjVar("list", MPR_DEFAULT_HASH_SIZE); - dom = mprCreateStringVar("System User", 1); - mprCreateProperty(&list, "0", &dom); + mprSetVar(&list, "0", mprCreateStringVar("System User", 1)); - ejsSetReturnValue(eid, list); + mpr_Return(eid, list); return 0; } -- cgit From b2f84fef133fb4c59e78fd0cf861f553efcbc1ef Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Jul 2005 23:25:42 +0000 Subject: r8296: - split out the ejs auth functions into a separate file - got rid of the one line ejs_returnlist() (This used to be commit 6961fe29058cffd8e69d9ce7e7d3902f973411c0) --- source4/scripting/ejs/smbcalls.c | 120 +-------------------------------------- 1 file changed, 1 insertion(+), 119 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 75702e4e76..ff57eff129 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -23,7 +23,6 @@ #include "includes.h" #include "lib/ejs/ejs.h" -#include "auth/auth.h" #include "scripting/ejs/smbcalls.h" /* @@ -65,122 +64,6 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) return 0; } -/* - setup a return of a string list -*/ -void ejs_returnlist(int eid, const char *name, const char **list) -{ - mpr_Return(eid, mprList(name, list)); -} - -static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, const char *password, const char *domain, const char *remote_host) -{ - struct auth_usersupplied_info *user_info = NULL; - struct auth_serversupplied_info *server_info = NULL; - struct auth_context *auth_context; - const char *auth_unix[] = { "unix", NULL }; - NTSTATUS nt_status; - DATA_BLOB pw_blob; - - /* - darn, we need some way to get the right event_context here - */ - nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context, NULL); - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 1)); - goto done; - } - - pw_blob = data_blob(password, strlen(password)+1), - make_user_info(tmp_ctx, username, username, - domain, domain, - remote_host, remote_host, - NULL, NULL, - NULL, NULL, - &pw_blob, False, - USER_INFO_CASE_INSENSITIVE_USERNAME | - USER_INFO_DONT_CHECK_UNIX_ACCOUNT, - &user_info); - nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(auth, "report", mprCreateStringVar("Login Failed", 1)); - goto done; - } - - mprSetPropertyValue(auth, "result", mprCreateBoolVar(server_info->authenticated)); - mprSetPropertyValue(auth, "username", mprCreateStringVar(server_info->account_name, 1)); - mprSetPropertyValue(auth, "domain", mprCreateStringVar(server_info->domain_name, 1)); - -done: - return 0; -} - -/* - perform user authentication, returning an array of results - - syntax: - var authinfo = new Object(); - authinfo.username = myname; - authinfo.password = mypass; - authinfo.domain = mydom; - authinfo.rhost = request['REMOTE_HOST']; - auth = userAuth(authinfo); -*/ -static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) -{ - TALLOC_CTX *tmp_ctx; - const char *username; - const char *password; - const char *domain; - const char *remote_host; - struct MprVar auth; - - if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "userAuth invalid arguments, this function requires an object."); - return -1; - } - - username = mprToString(mprGetProperty(argv[0], "username", NULL)); - password = mprToString(mprGetProperty(argv[0], "password", NULL)); - domain = mprToString(mprGetProperty(argv[0], "domain", NULL)); - remote_host = mprToString(mprGetProperty(argv[0], "rhost", NULL)); - - tmp_ctx = talloc_new(mprMemCtx()); - auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); - - if (domain && strcmp("System User", domain) == 0) { - - ejs_systemAuth(tmp_ctx, &auth, username, password, domain, remote_host); - } else { - - mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 1)); - } - - mpr_Return(eid, auth); - talloc_free(tmp_ctx); - return 0; -} - -static int ejs_domain_list(MprVarHandle eid, int argc, char **argv) -{ - struct MprVar list; - - if (argc != 0) { - ejsSetErrorMsg(eid, "domList invalid arguments"); - return -1; - } - - list = mprCreateObjVar("list", MPR_DEFAULT_HASH_SIZE); - mprSetVar(&list, "0", mprCreateStringVar("System User", 1)); - - mpr_Return(eid, list); - - return 0; -} - /* setup C functions that be called from ejs @@ -192,10 +75,9 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_nbt(); smb_setup_ejs_cli(); smb_setup_ejs_rpc(); + smb_setup_ejs_auth(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } /* -- cgit From b2f132182174d13c8bcb535f62522687675947c2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Jul 2005 00:13:11 +0000 Subject: r8297: add libinclude() function in ejs, which is like include() but searches a js library path set in "js include" in smb.conf. This will allow us to start building up a library of common js code, while avoiding the problem of hard-coding include paths in scripts (This used to be commit ff60529ba2515df29a20b4a417327a3565ec8ee9) --- source4/scripting/ejs/smbcalls.c | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index ff57eff129..1abbb52819 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -65,6 +65,52 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) } +/* + libinclude() allows you to include js files using a search path specified + in "js include =" in smb.conf. +*/ +static int ejs_libinclude(int eid, int argc, char **argv) +{ + int i, j; + const char **js_include = lp_js_include(); + + if (js_include == NULL || js_include[0] == NULL) { + return -1; + } + + for (i = 0; i < argc; i++) { + const char *script = argv[i]; + + for (j=0;js_include[j];j++) { + char *path; + path = talloc_asprintf(mprMemCtx(), "%s/%s", js_include[j], script); + if (path == NULL) { + return -1; + } + if (file_exist(path)) { + int ret; + struct MprVar result; + char *emsg; + + ret = ejsEvalFile(eid, path, &result, &emsg); + talloc_free(path); + if (ret < 0) { + ejsSetErrorMsg(eid, "%s: %s", script, emsg); + return -1; + } + break; + } + talloc_free(path); + } + if (js_include[j] == NULL) { + ejsSetErrorMsg(eid, "unable to include '%s'", script); + return -1; + } + } + return 0; +} + + /* setup C functions that be called from ejs */ @@ -78,6 +124,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_auth(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); } /* -- cgit From f583a85d4d520b0ab6ca83efd36e71563108b370 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Jul 2005 07:42:43 +0000 Subject: r8316: give full access to the popt command line parsing in ejs scripts, including access to the samba common options. For example: ok = GetOptions(ARGV, options, "POPT_AUTOHELP", "POPT_COMMON_SAMBA", "myopt=s", "intopt=i", "noopt"); this allows scripts to support their own extended options properly (This used to be commit 775fb56ac287b8d485b38f633b9480d7b7ab64e3) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1abbb52819..328bd14ab5 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -122,6 +122,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_cli(); smb_setup_ejs_rpc(); smb_setup_ejs_auth(); + smb_setup_ejs_options(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From 683432660ea53304d25212c56fd119aaabe2c0e3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Jul 2005 09:19:50 +0000 Subject: r8318: added a bunch more ejs calls. getgr*() getpw*() strlower() strupper() IfaceList() (This used to be commit 1517ad490dd67302f38ab9dcd8a3b24b73b8d550) --- source4/scripting/ejs/smbcalls.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 328bd14ab5..5972518036 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -64,6 +64,20 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) return 0; } +/* + return the list of configured network interfaces +*/ +static int ejs_IfaceList(MprVarHandle eid, int argc, struct MprVar **argv) +{ + int i, count = iface_count(); + struct MprVar ret = mprCreateObjVar("interfaces", MPR_DEFAULT_HASH_SIZE); + for (i=0;i Date: Mon, 11 Jul 2005 10:18:26 +0000 Subject: r8320: make sure all our returned objects are full objects, which means they have the toString() and valueOf() default attributes this allows all our returned objects to be used in logical expressions (This used to be commit 570f071b1544b497d5f480b8ad50df097fe4c843) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 5972518036..2da1e8c669 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -70,7 +70,7 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) static int ejs_IfaceList(MprVarHandle eid, int argc, struct MprVar **argv) { int i, count = iface_count(); - struct MprVar ret = mprCreateObjVar("interfaces", MPR_DEFAULT_HASH_SIZE); + struct MprVar ret = mprObject("interfaces"); for (i=0;i Date: Tue, 12 Jul 2005 02:34:49 +0000 Subject: r8337: - use 64 bit access functions in ejs calls - added access to smbd random functions - fixed ordering in join() - added sys_interfaces(), sys_hostname(), sys_nttime() and sys_ldaptime() (This used to be commit 28c1a1f3c0cd2f8228fd8c3c695ab6f45226fa3f) --- source4/scripting/ejs/smbcalls.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 2da1e8c669..e58151620f 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -64,21 +64,6 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) return 0; } -/* - return the list of configured network interfaces -*/ -static int ejs_IfaceList(MprVarHandle eid, int argc, struct MprVar **argv) -{ - int i, count = iface_count(); - struct MprVar ret = mprObject("interfaces"); - for (i=0;i Date: Tue, 12 Jul 2005 07:17:04 +0000 Subject: r8358: Return an error message if js include path not set instead of silently failing. (This used to be commit 797d9cf0c72992b2d5b9912d0f41873b6acc3195) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index e58151620f..abcde06e30 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -74,6 +74,7 @@ static int ejs_libinclude(int eid, int argc, char **argv) const char **js_include = lp_js_include(); if (js_include == NULL || js_include[0] == NULL) { + ejsSetErrorMsg(eid, "js include path not set"); return -1; } -- cgit From adbb1612c12d03fa94e4ee23fbc2fa96c09d9dcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Jul 2005 00:06:38 +0000 Subject: r8399: move the ejs and esp code closer to the directory layout used by the upstream sources. This makes it much easier to keep it up to date. I will separate out the mpr code into lib/appweb/mpr next (This used to be commit 52db7a052baeb0f11361ed69b71cb790039e3cc9) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index abcde06e30..49bcc64c96 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -22,7 +22,7 @@ */ #include "includes.h" -#include "lib/ejs/ejs.h" +#include "lib/appweb/ejs/ejs.h" #include "scripting/ejs/smbcalls.h" /* -- cgit From a0bc4da1a307753e3b28a11863f50d66b0894190 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Jul 2005 07:18:23 +0000 Subject: r8483: switched our generated ejs rpc code over to the new OO interface. This means we don't pollute the name space, and also makes for faster startup times as we only create variables for the pipes that we use, not all pipes (This used to be commit 57d7a585e8162d21c7152952aa0cc7471968784f) --- source4/scripting/ejs/smbcalls.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 49bcc64c96..59e5b17034 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -132,10 +132,3 @@ void smb_setup_ejs_functions(void) ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); } -/* - setup constants that can be used from ejs -*/ -void smb_setup_ejs_constants(int eid) -{ - smb_setup_ejs_rpc_constants(eid); -} -- cgit From 2a533ec684c8297f893fdd23e919937d92c58c15 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Aug 2005 16:10:13 +0000 Subject: r9059: add a basic credentials object for mimir (This used to be commit 36a9277e878d4db599fcfc02b96d2aaeac0b74dd) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 59e5b17034..4b03e2f404 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -127,6 +127,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_string(); smb_setup_ejs_random(); smb_setup_ejs_system(); + smb_setup_ejs_credentials(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From b99bca56570c0b146128bc243d770bb354ae0cd5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Aug 2005 19:02:28 +0000 Subject: r9132: 'pointer' is better for typedef than 'C pointer' (This used to be commit f91f5eeac9a8b62928233c3925c8ad1b99b32b4e) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 4b03e2f404..cc4a3d703a 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -45,7 +45,7 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) { MPR_TYPE_FUNCTION, "function" }, { MPR_TYPE_STRING, "string" }, { MPR_TYPE_STRING_CFUNCTION, "function" }, - { MPR_TYPE_PTR, "C pointer" } + { MPR_TYPE_PTR, "pointer" } }; int i; const char *type = NULL; -- cgit From 29e5e9e1e3b8f463bf782f3f42ce4a02cd55fca2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 17 Aug 2005 02:55:31 +0000 Subject: r9344: started adding calls for manipulation of data blobs in ejs added: blobToArray() blobFromArray() blobCompare() (This used to be commit cc5a3e9cc3b44f418eb5dfcd4e855a36c5ac8327) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index cc4a3d703a..3981e1dd7a 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -128,6 +128,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_random(); smb_setup_ejs_system(); smb_setup_ejs_credentials(); + smb_setup_ejs_datablob(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From d152839e299e7e406bb938c5b413ad975a895d6f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 28 Aug 2005 23:03:49 +0000 Subject: r9722: Initial attempt at converting samba3dump to EJS.. (This used to be commit 7e3b94dfb9c421793dab7813b96ca63da4b33960) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 3981e1dd7a..a73fbe52c3 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -128,6 +128,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_random(); smb_setup_ejs_system(); smb_setup_ejs_credentials(); + smb_setup_ejs_samba3(); smb_setup_ejs_datablob(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From 9f4b32996c1c97122b198a13216c35ad40f6ea2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 30 Aug 2005 14:44:33 +0000 Subject: r9800: Add EJS interface to param. tridge, sorry this overlaps a bit with your loadparm interface. :-/ (This used to be commit bb0cef581a09a86113f3212c776c011ae73def14) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index a73fbe52c3..d0ce1366a5 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -129,6 +129,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_system(); smb_setup_ejs_credentials(); smb_setup_ejs_samba3(); + smb_setup_ejs_param(); smb_setup_ejs_datablob(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From ab6ae6838eaad3f7e31cb7dd3ce8ac4a75fd2c84 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 24 Oct 2005 21:10:53 +0000 Subject: r11281: Initial ejs interface for libnet functions. rafal (This used to be commit f9c436bbdf0f071247da025f6984f9ee1c48dca8) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index d0ce1366a5..3e5035b272 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -131,6 +131,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_samba3(); smb_setup_ejs_param(); smb_setup_ejs_datablob(); + ejsnet_setup(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); -- cgit From 09c44f6cae89621871d2e5475b0c0f99c25804b4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 21:58:31 +0000 Subject: r12500: Use init functions explicitly in a few more places. 'gensec' and 'librpc' are the only two subsystems left to convert. (This used to be commit f6bbc72996aeee8607fc583140fd60be0e06e969) --- source4/scripting/ejs/smbcalls.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 3e5035b272..ee999402a5 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -24,6 +24,7 @@ #include "includes.h" #include "lib/appweb/ejs/ejs.h" #include "scripting/ejs/smbcalls.h" +#include "smb_build.h" /* return the type of a variable @@ -116,6 +117,9 @@ static int ejs_libinclude(int eid, int argc, char **argv) */ void smb_setup_ejs_functions(void) { + init_module_fn static_init[] = STATIC_SMBCALLS_MODULES; + init_module_fn *shared_init; + smb_setup_ejs_config(); smb_setup_ejs_ldb(); smb_setup_ejs_nbt(); @@ -131,8 +135,16 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_samba3(); smb_setup_ejs_param(); smb_setup_ejs_datablob(); + ejsnet_setup(); + shared_init = load_samba_modules(NULL, "ejs"); + + run_init_functions(static_init); + run_init_functions(shared_init); + + talloc_free(shared_init); + ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From c1c01df22f7145ca86b97fce670131017b3df3b9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 22:47:40 +0000 Subject: r12501: Merge EJSHeader.pm into EJS.pm and simplify smbcalls_rpc.c a bit, now that it is guaranteed that the smbcalls modules are always initialized after the EJS subsystem itself. (This used to be commit 1e8670874bb7415c3e00a42516680fdb4ee2fca1) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index ee999402a5..3e96f8bef2 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -124,7 +124,6 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_ldb(); smb_setup_ejs_nbt(); smb_setup_ejs_cli(); - smb_setup_ejs_rpc(); smb_setup_ejs_auth(); smb_setup_ejs_options(); smb_setup_ejs_nss(); -- cgit From b56282dec786683055f65f25ec419113bd7aa297 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 6 Feb 2006 18:29:57 +0000 Subject: r13369: let's have a way to show the samba4 version through ejs and use it in provisioning to fullfill rfc 3045 requirements (This used to be commit 3fb9571a76481560304a826fc945983d52123299) --- source4/scripting/ejs/smbcalls.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 3e96f8bef2..b63687b304 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -25,6 +25,7 @@ #include "lib/appweb/ejs/ejs.h" #include "scripting/ejs/smbcalls.h" #include "smb_build.h" +#include "version.h" /* return the type of a variable @@ -111,6 +112,15 @@ static int ejs_libinclude(int eid, int argc, char **argv) return 0; } +/* + return the current version +*/ +static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) +{ + mpr_ReturnString(eid, SAMBA_VERSION_STRING); + return 0; +} + /* setup C functions that be called from ejs @@ -146,5 +156,6 @@ void smb_setup_ejs_functions(void) ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 80c8a522861068e7b0974986936f65052dd6f70f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Feb 2006 12:48:13 +0000 Subject: r13655: Use new name of build header (This used to be commit bca0e8054f6d9c7adc9d92e0c30d4323f994c9e9) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index b63687b304..13281f88e9 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -24,7 +24,7 @@ #include "includes.h" #include "lib/appweb/ejs/ejs.h" #include "scripting/ejs/smbcalls.h" -#include "smb_build.h" +#include "build.h" #include "version.h" /* -- cgit From c6519ad9c0a45981a4ae101ee961acc397d4140d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 9 Mar 2006 22:06:54 +0000 Subject: r14109: Modulify the smbcalls subsystem. (This used to be commit d538eac9dbfdd786b533cb5fbbd35ab2fd7358ba) --- source4/scripting/ejs/smbcalls.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 13281f88e9..5aab8cf2c2 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -127,23 +127,13 @@ static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) */ void smb_setup_ejs_functions(void) { - init_module_fn static_init[] = STATIC_SMBCALLS_MODULES; + init_module_fn static_init[] = STATIC_smbcalls_MODULES; init_module_fn *shared_init; - smb_setup_ejs_config(); - smb_setup_ejs_ldb(); - smb_setup_ejs_nbt(); smb_setup_ejs_cli(); - smb_setup_ejs_auth(); smb_setup_ejs_options(); - smb_setup_ejs_nss(); - smb_setup_ejs_string(); - smb_setup_ejs_random(); - smb_setup_ejs_system(); smb_setup_ejs_credentials(); - smb_setup_ejs_samba3(); smb_setup_ejs_param(); - smb_setup_ejs_datablob(); ejsnet_setup(); -- cgit From 5c79bbadd5cfa921c8b4f87b5b4cafe5c488ebda Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 17 Mar 2006 00:45:52 +0000 Subject: r14497: Fix build with shared libraries (This used to be commit c74fc55831ca24819ae7f5e0920d0351e2b46a08) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 5aab8cf2c2..e010f3fdb1 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -137,7 +137,7 @@ void smb_setup_ejs_functions(void) ejsnet_setup(); - shared_init = load_samba_modules(NULL, "ejs"); + shared_init = load_samba_modules(NULL, "smbcalls"); run_init_functions(static_init); run_init_functions(shared_init); -- cgit From dab516d3e72360a10962d37a06df6aee33b1a63f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 21 Mar 2006 07:08:08 +0000 Subject: r14603: Fix building of ejs modules as shared libs Fix calling of ejs_exception() without requiring --export-dynamic (This used to be commit 8575e9a4903450aae1f29f55aae516085a9528bb) --- source4/scripting/ejs/smbcalls.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index e010f3fdb1..1bfbd3b47a 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -121,15 +121,23 @@ static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) return 0; } +static void (*ejs_exception_handler) (const char *) = NULL; + +_PUBLIC_ void ejs_exception(const char *reason) +{ + ejs_exception_handler(reason); +} /* setup C functions that be called from ejs */ -void smb_setup_ejs_functions(void) +void smb_setup_ejs_functions(void (*exception_handler)(const char *)) { init_module_fn static_init[] = STATIC_smbcalls_MODULES; init_module_fn *shared_init; + ejs_exception_handler = exception_handler; + smb_setup_ejs_cli(); smb_setup_ejs_options(); smb_setup_ejs_credentials(); -- cgit From c5718959e6a6d0454a870cbd311e707e69c98e85 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 25 Sep 2006 02:49:56 +0000 Subject: r18880: JSON-RPC work in progress (This used to be commit 34bffbaebf50c2a75c91285d5ec82e8f377981cc) --- source4/scripting/ejs/smbcalls.c | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1bfbd3b47a..85cc5f7027 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -66,6 +66,45 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) return 0; } +/* + return the native type of a variable +*/ +static int ejs_typeof_native(MprVarHandle eid, int argc, struct MprVar **argv) +{ + const struct { + MprType type; + const char *name; + } types[] = { + { MPR_TYPE_UNDEFINED, "undefined" }, + { MPR_TYPE_NULL, "null" }, + { MPR_TYPE_BOOL, "boolean" }, + { MPR_TYPE_CFUNCTION, "c_function" }, + { MPR_TYPE_FLOAT, "float" }, + { MPR_TYPE_INT, "integer" }, + { MPR_TYPE_INT64, "integer64" }, + { MPR_TYPE_OBJECT, "object" }, + { MPR_TYPE_FUNCTION, "function" }, + { MPR_TYPE_STRING, "string" }, + { MPR_TYPE_STRING_CFUNCTION, "string_c_function" }, + { MPR_TYPE_PTR, "pointer" } + }; + int i; + const char *type = NULL; + + if (argc != 1) return -1; + + for (i=0;itype == types[i].type) { + type = types[i].name; + break; + } + } + if (type == NULL) return -1; + + mpr_ReturnString(eid, type); + return 0; +} + /* libinclude() allows you to include js files using a search path specified in "js include =" in smb.conf. @@ -112,6 +151,47 @@ static int ejs_libinclude(int eid, int argc, char **argv) return 0; } +/* + jsonrpc_include() allows you to include jsonrpc files from a path + based at "jsonrpc base =" in smb.conf. +*/ +static int ejs_jsonrpc_include(int eid, int argc, char **argv) +{ + int ret = -1; + char *path; + char *emsg; + const char *jsonrpc_base = lp_jsonrpc_base(); + struct MprVar result; + + + if (jsonrpc_base == NULL || jsonrpc_base == NULL) { + ejsSetErrorMsg(eid, "js include path not set"); + return -1; + } + + if (argc != 1) { + mpr_Return(eid, mprCreateIntegerVar(-1)); + return 0; + } + + path = talloc_asprintf(mprMemCtx(), "%s/%s", jsonrpc_base, argv[0]); + if (path == NULL) { + mpr_Return(eid, mprCreateIntegerVar(-1)); + return 0; + } + + if (file_exist(path)) { + ret = ejsEvalFile(eid, path, &result, &emsg); + if (ret < 0) { + printf("file found; ret=%d (%s)\n", ret, emsg); + } + } + + mpr_Return(eid, mprCreateIntegerVar(ret)); + talloc_free(path); + return 0; +} + /* return the current version */ @@ -153,7 +233,9 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) talloc_free(shared_init); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "nativeTypeOf", ejs_typeof_native, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "jsonrpc_include", ejs_jsonrpc_include, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 882910a2a8f6e84509062d19720f4999af4761c4 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 2 Oct 2006 02:38:02 +0000 Subject: r19020: move jsonrpc_include to a more appropriate location in the file, and call the setup function for parsing literals. (This used to be commit bb07f606dedde5c63f190229b8dbb85f3d1342f7) --- source4/scripting/ejs/smbcalls.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 85cc5f7027..839ec7b634 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -83,7 +83,7 @@ static int ejs_typeof_native(MprVarHandle eid, int argc, struct MprVar **argv) { MPR_TYPE_INT, "integer" }, { MPR_TYPE_INT64, "integer64" }, { MPR_TYPE_OBJECT, "object" }, - { MPR_TYPE_FUNCTION, "function" }, + { MPR_TYPE_FUNCTION, "js_function" }, { MPR_TYPE_STRING, "string" }, { MPR_TYPE_STRING_CFUNCTION, "string_c_function" }, { MPR_TYPE_PTR, "pointer" } @@ -152,10 +152,20 @@ static int ejs_libinclude(int eid, int argc, char **argv) } /* - jsonrpc_include() allows you to include jsonrpc files from a path - based at "jsonrpc base =" in smb.conf. + return the current version */ -static int ejs_jsonrpc_include(int eid, int argc, char **argv) +static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) +{ + mpr_ReturnString(eid, SAMBA_VERSION_STRING); + return 0; +} + + +/* + * jsonrpc_include() allows you to include jsonrpc files from a path based at + * "jsonrpc base =" in smb.conf. + */ +static int jsonrpc_include(int eid, int argc, char **argv) { int ret = -1; char *path; @@ -192,14 +202,7 @@ static int ejs_jsonrpc_include(int eid, int argc, char **argv) return 0; } -/* - return the current version -*/ -static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) -{ - mpr_ReturnString(eid, SAMBA_VERSION_STRING); - return 0; -} + static void (*ejs_exception_handler) (const char *) = NULL; @@ -222,6 +225,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) smb_setup_ejs_options(); smb_setup_ejs_credentials(); smb_setup_ejs_param(); + smb_setup_ejs_literal(); ejsnet_setup(); @@ -235,7 +239,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "nativeTypeOf", ejs_typeof_native, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "jsonrpc_include", ejs_jsonrpc_include, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "jsonrpc_include", jsonrpc_include, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 882d352151bd05c37e18de8f8f619787f831a311 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 2 Oct 2006 20:39:31 +0000 Subject: r19051: JSON-RPC server work-in-progress. It's almost working. (This used to be commit 6e9cb2ed1cf87aed322fd7821237d088c2fef340) --- source4/scripting/ejs/smbcalls.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 839ec7b634..815b3e2b5d 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -203,6 +203,38 @@ static int jsonrpc_include(int eid, int argc, char **argv) } +static int ejs_debug(int eid, int argc, char **argv) +{ + int i; + int level; + void *ctx = mprMemCtx(); + char *msg; + + + if (argc < 2) { + return -1; + } + + level = atoi(argv[0]); + + msg = talloc_zero_size(ctx, 1); + if (msg == NULL) { + DEBUG(0, ("out of memory in debug()\n")); + return 0; + } + + for (i = 1; i < argc; i++) { + msg = talloc_append_string(ctx, msg, argv[i]); + if (msg == NULL) { + DEBUG(0, ("out of memory in debug()\n")); + return 0; + } + } + + DEBUG(level, ("%s", msg)); + talloc_free(msg); + return 0; +} static void (*ejs_exception_handler) (const char *) = NULL; @@ -241,5 +273,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "jsonrpc_include", jsonrpc_include, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "debug", ejs_debug, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 4b17a6dfbbc2d6adafbc9103b97fd78c43c2efe4 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 3 Oct 2006 02:38:08 +0000 Subject: r19055: JSON-RPC is working! It passes the small qooxdoo JSON-RPC test suite perfectly. This check in covers the remaining fixes and enhancements to complete the server. In a subsequent check-in, I need to learn about the new qooxdoo packaging mechanism. Although it'd be nice to have the whole source tree, that's huge and needn't be in samba svn. It's now supposed to be very easy to package qooxdoo, so I'll figure out how that's done and then check in the relevant small number of files. Steps after that involve generating the stubs to allow various ejs functions to be called via JSON-RPC. Derrell (This used to be commit 5bfebbda7a5d28d4deb31c54a8feb24c4416cbf6) --- source4/scripting/ejs/smbcalls.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 815b3e2b5d..b0df390427 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -203,39 +203,6 @@ static int jsonrpc_include(int eid, int argc, char **argv) } -static int ejs_debug(int eid, int argc, char **argv) -{ - int i; - int level; - void *ctx = mprMemCtx(); - char *msg; - - - if (argc < 2) { - return -1; - } - - level = atoi(argv[0]); - - msg = talloc_zero_size(ctx, 1); - if (msg == NULL) { - DEBUG(0, ("out of memory in debug()\n")); - return 0; - } - - for (i = 1; i < argc; i++) { - msg = talloc_append_string(ctx, msg, argv[i]); - if (msg == NULL) { - DEBUG(0, ("out of memory in debug()\n")); - return 0; - } - } - - DEBUG(level, ("%s", msg)); - talloc_free(msg); - return 0; -} - static void (*ejs_exception_handler) (const char *) = NULL; _PUBLIC_ void ejs_exception(const char *reason) @@ -273,6 +240,5 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "jsonrpc_include", jsonrpc_include, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "debug", ejs_debug, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 1c681891b2d00a21efa02488d80bc48c3ddab783 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 7 Oct 2006 20:31:27 +0000 Subject: r19165: handle errors better for jsonrpc. generate an error object whenever possible (This used to be commit aa8e4227a11d997f7c4c5af2b7a3c7c371b8c1cd) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index b0df390427..62a956bb96 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -193,6 +193,7 @@ static int jsonrpc_include(int eid, int argc, char **argv) if (file_exist(path)) { ret = ejsEvalFile(eid, path, &result, &emsg); if (ret < 0) { + ejsSetErrorMsg(eid, "Could not eval file"); printf("file found; ret=%d (%s)\n", ret, emsg); } } -- cgit From 68453d1da2ad68c1e9cb5d42eb71822ae6f0117b Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 22 Oct 2006 02:57:28 +0000 Subject: r19449: ldbbrowse: installation hopefully works now. "Developer" installations ('configure.developer' or 'configure --enable-developer') may still have problems as I'm not sure I got all of the paths right for that. With the changes Tridge has made to the Main Menu in swat, given a non-developer installation, you should be able to get to ldbbrowse via: JSON/qooxdoo -> ldb browser Derrell (This used to be commit 2406af10791cd8545c598c8591a48de5515c7dc5) --- source4/scripting/ejs/smbcalls.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 62a956bb96..1aee4cd9e2 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -163,19 +163,19 @@ static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) /* * jsonrpc_include() allows you to include jsonrpc files from a path based at - * "jsonrpc base =" in smb.conf. + * "jsonrpc services directory =" in smb.conf. */ static int jsonrpc_include(int eid, int argc, char **argv) { int ret = -1; char *path; char *emsg; - const char *jsonrpc_base = lp_jsonrpc_base(); + const char *jsonrpc_services_dir = lp_jsonrpc_services_dir(); struct MprVar result; - if (jsonrpc_base == NULL || jsonrpc_base == NULL) { - ejsSetErrorMsg(eid, "js include path not set"); + if (jsonrpc_services_dir == NULL || jsonrpc_services_dir == NULL) { + ejsSetErrorMsg(eid, "'jsonrpc services directory' not set"); return -1; } @@ -184,7 +184,9 @@ static int jsonrpc_include(int eid, int argc, char **argv) return 0; } - path = talloc_asprintf(mprMemCtx(), "%s/%s", jsonrpc_base, argv[0]); + path = talloc_asprintf(mprMemCtx(), "%s/%s", + jsonrpc_services_dir, + argv[0]); if (path == NULL) { mpr_Return(eid, mprCreateIntegerVar(-1)); return 0; -- cgit From c448896c7eda9a71c7ecc7debd46e977b507c183 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 15 Jan 2007 02:23:40 +0000 Subject: r20786: Fix the build. (This used to be commit 42bb335bd50a5070ee59c9d9748db8a9e9d6a9b0) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1aee4cd9e2..b75024cb4a 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -23,6 +23,7 @@ #include "includes.h" #include "lib/appweb/ejs/ejs.h" +#include "scripting/ejs/ejsnet/proto.h" #include "scripting/ejs/smbcalls.h" #include "build.h" #include "version.h" -- cgit From 0ec7ff5b6b8c7d498037bb68fc9cfead9e44dfc0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 07:34:04 +0000 Subject: r20791: the ejsnet stuff can be a normal smbcalls module... mimir: when you want to register more functions please do that in the smb_setup_ejs_net() function metze (This used to be commit 5828632931376c3982bf0b6d110d217a8e05d60e) --- source4/scripting/ejs/smbcalls.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index b75024cb4a..40178d3754 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -230,8 +230,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) smb_setup_ejs_param(); smb_setup_ejs_literal(); - ejsnet_setup(); - shared_init = load_samba_modules(NULL, "smbcalls"); run_init_functions(static_init); -- cgit From 64f27395a10fbf9ad95921ff0a8481b7afb0d02d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 07:46:36 +0000 Subject: r20792: fix the build, sorry... metze (This used to be commit e2cdd882b5ab12396244a13e0e58d8ee52f234ab) --- source4/scripting/ejs/smbcalls.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 40178d3754..24f48f8b76 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -22,8 +22,6 @@ */ #include "includes.h" -#include "lib/appweb/ejs/ejs.h" -#include "scripting/ejs/ejsnet/proto.h" #include "scripting/ejs/smbcalls.h" #include "build.h" #include "version.h" -- cgit From fb1078dd1848220957815250aca195aaba85c614 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 21 May 2007 19:53:57 +0000 Subject: r23047: Allow local inclusion of js files as well as from predefined path(s). rafal (This used to be commit 278d26576a625d0fa161f492b902074ea82ef1a8) --- source4/scripting/ejs/smbcalls.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 24f48f8b76..9a4a9f9624 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -120,17 +120,34 @@ static int ejs_libinclude(int eid, int argc, char **argv) for (i = 0; i < argc; i++) { const char *script = argv[i]; + struct MprVar result; + char *path, *emsg; + int ret; + /* First, try to include file from current working directory. + This allows local includes which is handy sometimes. */ + path = talloc_asprintf(mprMemCtx(), "%s", script); + if (path == NULL) { + return -1; + } + + if (file_exist(path)) { + ret = ejsEvalFile(eid, path, &result, &emsg); + talloc_free(path); + if (ret < 0) { + ejsSetErrorMsg(eid, "%s: %s", script, emsg); + return -1; + } + continue; + } + + /* use specfied path to search for requested file */ for (j=0;js_include[j];j++) { - char *path; path = talloc_asprintf(mprMemCtx(), "%s/%s", js_include[j], script); if (path == NULL) { return -1; } if (file_exist(path)) { - int ret; - struct MprVar result; - char *emsg; ret = ejsEvalFile(eid, path, &result, &emsg); talloc_free(path); @@ -142,6 +159,7 @@ static int ejs_libinclude(int eid, int argc, char **argv) } talloc_free(path); } + if (js_include[j] == NULL) { ejsSetErrorMsg(eid, "unable to include '%s'", script); return -1; -- cgit From 5088c8add2f6dda66c17f4b238cd71ff7096e482 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Tue, 22 May 2007 06:34:14 +0000 Subject: r23065: revert local includes to prevent security problems (at least temporarily...) rafal (This used to be commit 0ecb8fd81ebbd7327aa5c6b9347aa4dcb1ba6421) --- source4/scripting/ejs/smbcalls.c | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 9a4a9f9624..04c534bdf5 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -124,23 +124,6 @@ static int ejs_libinclude(int eid, int argc, char **argv) char *path, *emsg; int ret; - /* First, try to include file from current working directory. - This allows local includes which is handy sometimes. */ - path = talloc_asprintf(mprMemCtx(), "%s", script); - if (path == NULL) { - return -1; - } - - if (file_exist(path)) { - ret = ejsEvalFile(eid, path, &result, &emsg); - talloc_free(path); - if (ret < 0) { - ejsSetErrorMsg(eid, "%s: %s", script, emsg); - return -1; - } - continue; - } - /* use specfied path to search for requested file */ for (j=0;js_include[j];j++) { path = talloc_asprintf(mprMemCtx(), "%s/%s", js_include[j], script); -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/scripting/ejs/smbcalls.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 04c534bdf5..bc7994a007 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -8,7 +8,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -17,8 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index bc7994a007..08b9eac5c1 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "param/param.h" #include "scripting/ejs/smbcalls.h" #include "build.h" #include "version.h" -- cgit From 15c1801a5c13479f1bf67e0e3c1ad7c0af8e3af7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 10 Sep 2007 03:44:47 +0000 Subject: r25051: Move SWAT back to the old-style form-submit modal. The Web 2.0, async client tools were really interesting, but without developer backing they remain impossible to support into a release. The most interesting app was the LDB browser, and I intend to replace this with phpLdapAdmin, preconfigured for Apache during provision. This also removes the need to 'compile' SWAT on SVN checkouts. Andrew Bartlett (This used to be commit cda965e908055d45b1c05bc29cc791f7238d2fae) --- source4/scripting/ejs/smbcalls.c | 46 ---------------------------------------- 1 file changed, 46 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 08b9eac5c1..3cb860b9e3 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -161,51 +161,6 @@ static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) } -/* - * jsonrpc_include() allows you to include jsonrpc files from a path based at - * "jsonrpc services directory =" in smb.conf. - */ -static int jsonrpc_include(int eid, int argc, char **argv) -{ - int ret = -1; - char *path; - char *emsg; - const char *jsonrpc_services_dir = lp_jsonrpc_services_dir(); - struct MprVar result; - - - if (jsonrpc_services_dir == NULL || jsonrpc_services_dir == NULL) { - ejsSetErrorMsg(eid, "'jsonrpc services directory' not set"); - return -1; - } - - if (argc != 1) { - mpr_Return(eid, mprCreateIntegerVar(-1)); - return 0; - } - - path = talloc_asprintf(mprMemCtx(), "%s/%s", - jsonrpc_services_dir, - argv[0]); - if (path == NULL) { - mpr_Return(eid, mprCreateIntegerVar(-1)); - return 0; - } - - if (file_exist(path)) { - ret = ejsEvalFile(eid, path, &result, &emsg); - if (ret < 0) { - ejsSetErrorMsg(eid, "Could not eval file"); - printf("file found; ret=%d (%s)\n", ret, emsg); - } - } - - mpr_Return(eid, mprCreateIntegerVar(ret)); - talloc_free(path); - return 0; -} - - static void (*ejs_exception_handler) (const char *) = NULL; _PUBLIC_ void ejs_exception(const char *reason) @@ -240,6 +195,5 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) ejsDefineCFunction(-1, "nativeTypeOf", ejs_typeof_native, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "jsonrpc_include", jsonrpc_include, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 3cb860b9e3..91e58873df 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -111,7 +111,7 @@ static int ejs_typeof_native(MprVarHandle eid, int argc, struct MprVar **argv) static int ejs_libinclude(int eid, int argc, char **argv) { int i, j; - const char **js_include = lp_js_include(); + const char **js_include = lp_js_include(global_loadparm); if (js_include == NULL || js_include[0] == NULL) { ejsSetErrorMsg(eid, "js include path not set"); -- cgit From 2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 18:52:55 +0000 Subject: r25446: Merge some changes I made on the way home from SFO: 2007-09-29 More higher-level passing around of lp_ctx. 2007-09-29 Fix warning. 2007-09-29 Pass loadparm contexts on a higher level. 2007-09-29 Avoid using global loadparm context. (This used to be commit 3468952e771ab31f90b6c374ade01c5550810f42) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 91e58873df..8a3ce245d2 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -184,7 +184,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) smb_setup_ejs_param(); smb_setup_ejs_literal(); - shared_init = load_samba_modules(NULL, "smbcalls"); + shared_init = load_samba_modules(NULL, global_loadparm, "smbcalls"); run_init_functions(static_init); run_init_functions(shared_init); -- cgit From be33f4c611d37ebba59ff618033dc73601339ad1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Dec 2007 23:54:30 -0600 Subject: r26576: Allow the static module loading code to be used for the Python modules. Simplify the way module initialization functions are handled. (This used to be commit ba8be2dfc0de4434c798663336b81f7f95cde520) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 8a3ce245d2..da13f1f6ef 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -173,7 +173,7 @@ _PUBLIC_ void ejs_exception(const char *reason) */ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) { - init_module_fn static_init[] = STATIC_smbcalls_MODULES; + init_module_fn static_init[] = { STATIC_smbcalls_MODULES, NULL }; init_module_fn *shared_init; ejs_exception_handler = exception_handler; -- cgit From c13ae707313c5bf9819a75c1699d099565d2494d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Dec 2007 01:28:22 -0600 Subject: r26580: Include sentinel in build.h, in case the list is empty. (This used to be commit f1997dabed584bdc864c4b7235c29603c312ef46) --- source4/scripting/ejs/smbcalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index da13f1f6ef..1f29fce002 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -173,7 +173,7 @@ _PUBLIC_ void ejs_exception(const char *reason) */ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) { - init_module_fn static_init[] = { STATIC_smbcalls_MODULES, NULL }; + init_module_fn static_init[] = { STATIC_smbcalls_MODULES }; init_module_fn *shared_init; ejs_exception_handler = exception_handler; -- cgit From b66ee2ed22754dd44b20c06e573072e328d9a3dd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 16 Feb 2008 18:38:02 +0100 Subject: Move responsibilities of build.h to makefile. (This used to be commit a43f6d37bce85748e9cf2675e5beced5db26f1c3) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1f29fce002..da35a6ba8c 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -23,7 +23,6 @@ #include "includes.h" #include "param/param.h" #include "scripting/ejs/smbcalls.h" -#include "build.h" #include "version.h" /* -- cgit From e11c61bc5cd487dce06fc38bb0ee8c4e24b04e8c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 18:21:44 +0100 Subject: Introduce mprLpCtx() similar to mprMemCtx() for loadparm_context used by all EJS code. (This used to be commit 184988866fe8e740f58e3683eefcaa70f8b51d11) --- source4/scripting/ejs/smbcalls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1f29fce002..63a80e17db 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -111,7 +111,7 @@ static int ejs_typeof_native(MprVarHandle eid, int argc, struct MprVar **argv) static int ejs_libinclude(int eid, int argc, char **argv) { int i, j; - const char **js_include = lp_js_include(global_loadparm); + const char **js_include = lp_js_include(mprLpCtx()); if (js_include == NULL || js_include[0] == NULL) { ejsSetErrorMsg(eid, "js include path not set"); @@ -184,7 +184,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) smb_setup_ejs_param(); smb_setup_ejs_literal(); - shared_init = load_samba_modules(NULL, global_loadparm, "smbcalls"); + shared_init = load_samba_modules(NULL, mprLpCtx(), "smbcalls"); run_init_functions(static_init); run_init_functions(shared_init); -- cgit From 22ef67dd136f0a67885a17be68909643dc97304d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 26 Feb 2008 01:20:55 +0100 Subject: Fix the build (again). (This used to be commit ef00f6b5817107738dc44367838095896af4e77d) --- source4/scripting/ejs/smbcalls.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index da35a6ba8c..ac1c20008b 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -172,6 +172,32 @@ _PUBLIC_ void ejs_exception(const char *reason) */ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) { + extern NTSTATUS ejs_init_security(void); + extern NTSTATUS ejs_init_initshutdown(void); + extern NTSTATUS smb_setup_ejs_reg(void); + extern NTSTATUS smb_setup_ejs_string(void); + extern NTSTATUS ejs_init_lsarpc(void); + extern NTSTATUS ejs_init_rpcecho(void); + extern NTSTATUS ejs_init_winreg(void); + extern NTSTATUS smb_setup_ejs_random(void); + extern NTSTATUS smb_setup_ejs_config(void); + extern NTSTATUS ejs_init_misc(void); + extern NTSTATUS ejs_init_netdfs(void); + extern NTSTATUS smb_setup_ejs_datablob(void); + extern NTSTATUS smb_setup_ejs_auth(void); + extern NTSTATUS smb_setup_ejs_nss(void); + extern NTSTATUS ejs_init_samr(void); + extern NTSTATUS ejs_init_wkssvc(void); + extern NTSTATUS smb_setup_ejs_system(void); + extern NTSTATUS smb_setup_ejs_ldb(void); + extern NTSTATUS ejs_init_svcctl(void); + extern NTSTATUS smb_setup_ejs_nbt(void); + extern NTSTATUS smb_setup_ejs_net(void); + extern NTSTATUS ejs_init_srvsvc(void); + extern NTSTATUS ejs_init_netlogon(void); + extern NTSTATUS ejs_init_drsuapi(void); + extern NTSTATUS ejs_init_irpc(void); + extern NTSTATUS ejs_init_eventlog(void); init_module_fn static_init[] = { STATIC_smbcalls_MODULES }; init_module_fn *shared_init; -- cgit From fd712bb878dcfbe8a50e48361c96cc04a3ddacf5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 May 2008 02:11:32 +0200 Subject: Remove unused cli ejs module. (This used to be commit 170d5aef80f37c26171a40e818cc8b557828d04b) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 98d6be07bf..bdf70ca831 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -203,7 +203,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) ejs_exception_handler = exception_handler; - smb_setup_ejs_cli(); smb_setup_ejs_options(); smb_setup_ejs_credentials(); smb_setup_ejs_param(); -- cgit From cbe439383a8f9322c3b0b51aca863cecd77cafcb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 May 2008 13:36:05 +0200 Subject: remove unused credentials ejs module. (This used to be commit 9861cae1aebdef41f098df71be4e5a33f6af9bf1) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index bdf70ca831..a90e1e62c8 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -204,7 +204,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) ejs_exception_handler = exception_handler; smb_setup_ejs_options(); - smb_setup_ejs_credentials(); smb_setup_ejs_param(); smb_setup_ejs_literal(); -- cgit From ec362bdbc06a83d4b4656e5c3dde90c49adb2a64 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 May 2008 13:40:17 +0200 Subject: Remove unused datablob and nbt ejs bindings. (This used to be commit f758553ac50d374f64a8763055dc4f12ab9b0c68) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index a90e1e62c8..d17f048887 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -191,7 +191,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) extern NTSTATUS smb_setup_ejs_system(void); extern NTSTATUS smb_setup_ejs_ldb(void); extern NTSTATUS ejs_init_svcctl(void); - extern NTSTATUS smb_setup_ejs_nbt(void); extern NTSTATUS smb_setup_ejs_net(void); extern NTSTATUS ejs_init_srvsvc(void); extern NTSTATUS ejs_init_netlogon(void); -- cgit From 335688f640ed3f2b8a26dcf949b6175e2a95e802 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 May 2008 13:43:54 +0200 Subject: Revert "remove unused credentials ejs module." This reverts commit 9861cae1aebdef41f098df71be4e5a33f6af9bf1. (This used to be commit a429dc730f97388f0b4478b44522b1fe53f8569a) --- source4/scripting/ejs/smbcalls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index d17f048887..880605bf10 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -203,6 +203,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) ejs_exception_handler = exception_handler; smb_setup_ejs_options(); + smb_setup_ejs_credentials(); smb_setup_ejs_param(); smb_setup_ejs_literal(); -- cgit From 1b6396f114f29cabe6b640118f3258e54ceeab32 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 May 2008 14:03:55 +0200 Subject: Remove unused param ejs bindings. (This used to be commit 4dd0d46e27696b6d29d4b6a63c56667ce5e03db6) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 880605bf10..8b1fe06c77 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -204,7 +204,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) smb_setup_ejs_options(); smb_setup_ejs_credentials(); - smb_setup_ejs_param(); smb_setup_ejs_literal(); shared_init = load_samba_modules(NULL, mprLpCtx(), "smbcalls"); -- cgit From 8f25f40a2efe9986e76e71d128bb29e2fb4cfd86 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 May 2008 14:10:34 +0200 Subject: Remove unused literal EJS bindings. (This used to be commit da3094d1ba86a8f4967ca1993383b0767439f79f) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting/ejs/smbcalls.c') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 8b1fe06c77..4314b51455 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -204,7 +204,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) smb_setup_ejs_options(); smb_setup_ejs_credentials(); - smb_setup_ejs_literal(); shared_init = load_samba_modules(NULL, mprLpCtx(), "smbcalls"); -- cgit