summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/ejsnet/net_ctx.c16
-rw-r--r--source4/scripting/ejs/ejsnet/net_user.c14
-rw-r--r--source4/scripting/ejs/ejsrpc.c18
-rw-r--r--source4/scripting/ejs/ejsrpc.h4
-rw-r--r--source4/scripting/ejs/literal.c24
-rw-r--r--source4/scripting/ejs/mprutil.c2
-rw-r--r--source4/scripting/ejs/smbcalls.c51
-rw-r--r--source4/scripting/ejs/smbcalls.h1
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c26
-rw-r--r--source4/scripting/ejs/smbcalls_cli.c25
-rw-r--r--source4/scripting/ejs/smbcalls_config.c49
-rw-r--r--source4/scripting/ejs/smbcalls_creds.c18
-rw-r--r--source4/scripting/ejs/smbcalls_data.c12
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c6
-rw-r--r--source4/scripting/ejs/smbcalls_param.c18
-rw-r--r--source4/scripting/ejs/smbcalls_reg.c2
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c9
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c2
-rw-r--r--source4/scripting/ejs/smbcalls_string.c14
-rw-r--r--source4/scripting/ejs/smbcalls_sys.c4
-rw-r--r--source4/scripting/ejs/smbscript.c8
21 files changed, 124 insertions, 199 deletions
diff --git a/source4/scripting/ejs/ejsnet/net_ctx.c b/source4/scripting/ejs/ejsnet/net_ctx.c
index 411c98cc72..97a05ab88f 100644
--- a/source4/scripting/ejs/ejsnet/net_ctx.c
+++ b/source4/scripting/ejs/ejsnet/net_ctx.c
@@ -68,7 +68,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
talloc_free(ctx);
return -1;
}
- cli_credentials_set_conf(creds);
+ cli_credentials_set_conf(creds, global_loadparm);
cli_credentials_set_anonymous(creds);
mprCreds = mprCredentials(creds);
@@ -78,7 +78,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
get credential values from credentials object
*/
mprCreds = *(argv[0]);
- creds = mprGetPtr(&mprCreds, "creds");
+ creds = (struct cli_credentials *)mprGetPtr(&mprCreds, "creds");
if (creds == NULL) {
ejsSetErrorMsg(eid, "invalid credentials parameter");
talloc_free(ctx);
@@ -122,7 +122,7 @@ static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv)
struct libnet_context *ctx;
struct libnet_Join *join;
NTSTATUS status;
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
mem_ctx = talloc_new(mprMemCtx());
join = talloc(mem_ctx, struct libnet_Join);
@@ -166,9 +166,9 @@ static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv)
MprVar error_string = mprString(join->out.error_string);
mprSetPropertyValue(argv[0], "error_string", error_string);
- mpr_Return(eid, mprCreateBoolVar(False));
+ mpr_Return(eid, mprCreateBoolVar(false));
} else {
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
}
talloc_free(mem_ctx);
return 0;
@@ -181,7 +181,7 @@ static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv)
struct libnet_context *ctx;
struct libnet_samsync_ldb *samsync;
NTSTATUS status;
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
mem_ctx = talloc_new(mprMemCtx());
samsync = talloc(mem_ctx, struct libnet_samsync_ldb);
@@ -214,9 +214,9 @@ static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv)
MprVar error_string = mprString(samsync->out.error_string);
mprSetPropertyValue(argv[0], "error_string", error_string);
- mpr_Return(eid, mprCreateBoolVar(False));
+ mpr_Return(eid, mprCreateBoolVar(false));
} else {
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
}
talloc_free(mem_ctx);
return 0;
diff --git a/source4/scripting/ejs/ejsnet/net_user.c b/source4/scripting/ejs/ejsnet/net_user.c
index 8c9ab9f0eb..34524cc0fa 100644
--- a/source4/scripting/ejs/ejsnet/net_user.c
+++ b/source4/scripting/ejs/ejsnet/net_user.c
@@ -45,7 +45,7 @@ int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv)
struct MprVar obj;
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
return 0;
@@ -128,14 +128,14 @@ static int ejs_net_createuser(MprVarHandle eid, int argc, char **argv)
}
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
goto done;
}
/* domain where the account is to be created */
- userman_domain = mprGetThisPtr(eid, "domain");
+ userman_domain = (const char *)mprGetThisPtr(eid, "domain");
if (userman_domain == NULL) {
ejsSetErrorMsg(eid, "domain property returns null pointer");
goto done;
@@ -197,7 +197,7 @@ static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv)
}
/* domain where the account is to be deleted */
- userman_domain = mprGetThisPtr(eid, "domain");
+ userman_domain = (struct libnet_context *)mprGetThisPtr(eid, "domain");
if (!userman_domain) {
ejsSetErrorMsg(eid, "domain property returns null pointer");
goto done;
@@ -253,14 +253,14 @@ static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv)
}
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
goto done;
}
/* domain where the user account is to be queried */
- userman_domain = mprGetThisPtr(eid, "domain");
+ userman_domain = (struct libnet_context *)mprGetThisPtr(eid, "domain");
if (userman_domain == NULL) {
ejsSetErrorMsg(eid, "domain property returns null pointer");
return -1;
@@ -331,7 +331,7 @@ static int ejs_net_userlist(MprVarHandle eid, int argc, struct MprVar **argv)
}
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
goto done;
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index 966c803a30..3769607949 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -311,16 +311,16 @@ NTSTATUS ejs_push_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
return mprSetVar(v, name, mprCreatePtrVar(NULL));
}
-BOOL ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
+bool ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
{
NTSTATUS status = mprGetVar(&v, name);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
if (v->type == MPR_TYPE_PTR && v->ptr == NULL) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
@@ -372,16 +372,16 @@ NTSTATUS ejs_push_DATA_BLOB(struct ejs_rpc *ejs,
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS ejs_pull_BOOL(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, BOOL *r)
+NTSTATUS ejs_pull_bool(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, bool *r)
{
NDR_CHECK(mprGetVar(&v, name));
*r = mprVarToBool(v);
return NT_STATUS_OK;
}
-NTSTATUS ejs_push_BOOL(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const BOOL *r)
+NTSTATUS ejs_push_bool(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const bool *r)
{
return mprSetVar(v, name, mprCreateBoolVar(*r));
}
@@ -417,7 +417,7 @@ NTSTATUS ejs_push_array_uint8(struct ejs_rpc *ejs,
const uint8_t *r, uint32_t length)
{
DATA_BLOB blob;
- blob.data = discard_const(r);
+ blob.data = (uint8_t *)discard_const(r);
blob.length = length;
mprSetVar(v, name, mprDataBlob(blob));
return NT_STATUS_OK;
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index ef920b816a..6723fb4107 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -113,9 +113,9 @@ NTSTATUS ejs_pull_DATA_BLOB(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, DATA_BLOB *r);
NTSTATUS ejs_push_DATA_BLOB(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const DATA_BLOB *r);
-NTSTATUS ejs_pull_BOOL(struct ejs_rpc *ejs,
+NTSTATUS ejs_pull_bool(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, bool *r);
-NTSTATUS ejs_push_BOOL(struct ejs_rpc *ejs,
+NTSTATUS ejs_push_bool(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const bool *r);
NTSTATUS ejs_pull_array_uint8(struct ejs_rpc *ejs,
diff --git a/source4/scripting/ejs/literal.c b/source4/scripting/ejs/literal.c
index d50e5afdb9..8307c211d3 100644
--- a/source4/scripting/ejs/literal.c
+++ b/source4/scripting/ejs/literal.c
@@ -132,27 +132,11 @@ static void *append_string(void *ctx,
char *append,
int size)
{
- char c;
- char *end_p = append + size;
- void *ret;
+ if (!orig) {
+ return talloc_strndup(ctx, append, size);
+ }
- /*
- * We need to null terminate the string to be copied. Save character at
- * the size limit of the source string.
- */
- c = *end_p;
-
- /* Temporarily null-terminate it */
- *end_p = '\0';
-
- /* Append the requested data */
- ret = talloc_append_string(ctx, orig, append);
-
- /* Restore the original character in place of our temporary null byte */
- *end_p = c;
-
- /* Give 'em what they came for */
- return ret;
+ return talloc_strndup_append(orig, append, size);
}
diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c
index b8271d97c5..9143947fb8 100644
--- a/source4/scripting/ejs/mprutil.c
+++ b/source4/scripting/ejs/mprutil.c
@@ -134,7 +134,7 @@ struct MprVar mprString(const char *s)
if (s == NULL) {
return mprCreatePtrVar(NULL);
}
- return mprCreateStringVar(s, True);
+ return mprCreateStringVar(s, true);
}
/*
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index bc7994a007..8a3ce245d2 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"
@@ -110,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");
@@ -160,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)
@@ -228,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);
@@ -239,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);
}
diff --git a/source4/scripting/ejs/smbcalls.h b/source4/scripting/ejs/smbcalls.h
index 77d9dd3381..3aaf324b6e 100644
--- a/source4/scripting/ejs/smbcalls.h
+++ b/source4/scripting/ejs/smbcalls.h
@@ -38,4 +38,5 @@ struct ldb_context;
struct ldb_message;
struct cli_credentials;
+#include "param/param.h"
#include "scripting/ejs/proto.h"
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index 2624084f02..b4848d4323 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -30,9 +30,11 @@
#include "libcli/security/security.h"
static int ejs_doauth(MprVarHandle eid,
- TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username,
- const char *password, const char *domain, const char *workstation,
- struct socket_address *remote_host, const char **auth_types)
+ TALLOC_CTX *tmp_ctx, struct MprVar *auth,
+ const char *username, const char *password,
+ const char *domain, const char *workstation,
+ struct socket_address *remote_host,
+ const char **auth_types)
{
struct auth_usersupplied_info *user_info = NULL;
struct auth_serversupplied_info *server_info = NULL;
@@ -54,7 +56,7 @@ static int ejs_doauth(MprVarHandle eid,
} else {
/* Hope we can find the event context somewhere up there... */
ev = event_context_find(tmp_ctx);
- msg = messaging_client_init(tmp_ctx, ev);
+ msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, global_loadparm), ev);
}
if (auth_types) {
@@ -63,19 +65,19 @@ static int ejs_doauth(MprVarHandle eid,
nt_status = auth_context_create(tmp_ctx, ev, msg, &auth_context);
}
if (!NT_STATUS_IS_OK(nt_status)) {
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
mprSetPropertyValue(auth, "report", mprString("Auth System Failure"));
goto done;
}
user_info = talloc(tmp_ctx, struct auth_usersupplied_info);
if (!user_info) {
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
mprSetPropertyValue(auth, "report", mprString("talloc failed"));
goto done;
}
- user_info->mapped_state = True;
+ user_info->mapped_state = true;
user_info->client.account_name = username;
user_info->mapped.account_name = username;
user_info->client.domain_name = domain;
@@ -102,14 +104,14 @@ static int ejs_doauth(MprVarHandle eid,
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "report",
mprString(talloc_strdup(mprMemCtx(), get_friendly_nt_error_msg(nt_status))));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
goto done;
}
nt_status = auth_generate_session_info(tmp_ctx, server_info, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "report", mprString("Session Info generation failed"));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
goto done;
}
@@ -130,13 +132,13 @@ static int ejs_doauth(MprVarHandle eid,
if (security_token_is_anonymous(session_info->security_token)) {
mprSetPropertyValue(auth, "report", mprString("Anonymous login not permitted"));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
goto done;
}
if (!set) {
mprSetPropertyValue(auth, "report", mprString("Session Info generation failed"));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
}
session_info_obj = mprInitObject(eid, "session_info", 0, NULL);
@@ -181,7 +183,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- remote_host = mprGetPtr(argv[1], "socket_address");
+ remote_host = (struct socket_address *)mprGetPtr(argv[1], "socket_address");
if (remote_host == NULL) {
ejsSetErrorMsg(eid, "userAuth requires a socket address second parameter");
return -1;
diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c
index e94207bf36..e08a098833 100644
--- a/source4/scripting/ejs/smbcalls_cli.c
+++ b/source4/scripting/ejs/smbcalls_cli.c
@@ -27,6 +27,7 @@
#include "libcli/smb_composite/smb_composite.h"
#include "libcli/libcli.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
#if 0
@@ -60,7 +61,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv)
return -1;
}
- transport = smbcli_transport_init(sock, sock, False);
+ transport = smbcli_transport_init(sock, sock, false);
if (!transport) {
ejsSetErrorMsg(eid, "transport init failed");
@@ -191,7 +192,7 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv)
/* Do session setup */
- session = smbcli_session_init(transport, transport, False);
+ session = smbcli_session_init(transport, transport, false);
if (!session) {
ejsSetErrorMsg(eid, "session init failed");
@@ -251,7 +252,7 @@ static int ejs_cli_tree_connect(MprVarHandle eid, int argc, MprVar **argv)
}
session = argv[0]->ptr;
- tree = smbcli_tree_init(session, session, False);
+ tree = smbcli_tree_init(session, session, false);
if (!tree) {
ejsSetErrorMsg(eid, "tree init failed");
@@ -430,7 +431,7 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
/* Set up credentials */
creds = cli_credentials_init(NULL);
- cli_credentials_set_conf(creds);
+ cli_credentials_set_conf(creds, global_loadparm);
cli_credentials_parse_string(creds, argv[1], CRED_SPECIFIED);
/* Do connect */
@@ -441,8 +442,8 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
io.in.service = sharename;
io.in.service_type = "?????";
io.in.credentials = creds;
- io.in.fallback_to_anonymous = False;
- io.in.workgroup = lp_workgroup();
+ io.in.fallback_to_anonymous = false;
+ io.in.workgroup = lp_workgroup(global_loadparm);
result = smb_composite_connect(&io, mem_ctx, NULL);
tree = io.out.tree;
@@ -483,7 +484,7 @@ static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = talloc_check_name(argv[0]->ptr, "struct smbcli_tree");
+ tree = talloc_get_type(argv[0]->ptr, struct smbcli_tree);
result = smb_tree_disconnect(tree);
@@ -512,7 +513,7 @@ static int ejs_mkdir(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -546,7 +547,7 @@ static int ejs_rmdir(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -580,7 +581,7 @@ static int ejs_rename(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -619,7 +620,7 @@ static int ejs_unlink(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -666,7 +667,7 @@ static int ejs_list(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 6f15ee5a4a..1c76757659 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -25,6 +25,7 @@
#include "param/loadparm.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
/*
return a list of defined services
@@ -35,8 +36,8 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
const char **list = NULL;
if (argc != 0) return -1;
- for (i=0;i<lp_numservices();i++) {
- list = str_list_add(list, lp_servicename(i));
+ for (i=0;i<lp_numservices(global_loadparm);i++) {
+ list = str_list_add(list, lp_servicename(lp_servicebynum(global_loadparm, i)));
}
talloc_steal(mprMemCtx(), list);
mpr_Return(eid, mprList("services", list));
@@ -45,27 +46,6 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
/*
- return a list of parameter categories
-*/
-static int ejs_lpCategories(MprVarHandle eid, int argc, char **argv)
-{
- struct parm_struct *parm_table = lp_parm_table();
- int i;
- const char **list = NULL;
- if (argc != 0) return -1;
-
- for (i=0;parm_table[i].label;i++) {
- if (parm_table[i].class == P_SEPARATOR) {
- list = str_list_add(list, parm_table[i].label);
- }
- }
- talloc_steal(mprMemCtx(), list);
- mpr_Return(eid, mprList("categories", list));
- return 0;
-}
-
-
-/*
allow access to loadparm variables from inside ejs scripts in web apps
can be called in 4 ways:
@@ -86,9 +66,10 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
if (argc < 1) return -1;
if (argc == 2) {
+ struct loadparm_service *service;
/* its a share parameter */
- int snum = lp_servicenumber(argv[0]);
- if (snum == -1) {
+ service = lp_service(global_loadparm, argv[0]);
+ if (service == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
@@ -103,7 +84,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(snum, type, option);
+ value = lp_get_parametric(global_loadparm, service, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -117,7 +98,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(snum, parm);
+ parm_ptr = lp_parm_ptr(service, parm);
} else if (strchr(argv[0], ':')) {
/* its a global parametric option */
const char *type = talloc_strndup(mprMemCtx(),
@@ -128,7 +109,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(-1, type, option);
+ value = lp_get_parametric(global_loadparm, NULL, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -142,7 +123,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(-1, parm);
+ parm_ptr = lp_parm_ptr(NULL, parm);
}
if (parm == NULL || parm_ptr == NULL) {
@@ -157,7 +138,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_ReturnString(eid, *(char **)parm_ptr);
break;
case P_BOOL:
- mpr_Return(eid, mprCreateBoolVar(*(BOOL *)parm_ptr));
+ mpr_Return(eid, mprCreateBoolVar(*(bool *)parm_ptr));
break;
case P_INTEGER:
case P_OCTAL:
@@ -176,9 +157,6 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
case P_LIST:
mpr_Return(eid, mprList(parm->label, *(const char ***)parm_ptr));
break;
- case P_SEP:
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
}
return 0;
}
@@ -198,7 +176,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
return -1;
}
- mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(argv[0], argv[1])));
+ mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(global_loadparm, argv[0], argv[1])));
return 0;
}
@@ -209,7 +187,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
{
- BOOL ret = lp_load();
+ bool ret = lp_load(lp_configfile(global_loadparm));
if (ret) {
unload_interfaces();
}
@@ -228,7 +206,6 @@ static int ejs_loadparm_init(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetStringCFunction(obj, "set", ejs_lpSet);
mprSetStringCFunction(obj, "reload", ejs_lpReload);
mprSetStringCFunction(obj, "services", ejs_lpServices);
- mprSetStringCFunction(obj, "categories", ejs_lpCategories);
return 0;
}
diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c
index 0feead201e..781843371a 100644
--- a/source4/scripting/ejs/smbcalls_creds.c
+++ b/source4/scripting/ejs/smbcalls_creds.c
@@ -30,7 +30,7 @@
*/
static struct cli_credentials *ejs_creds_get_credentials(int eid)
{
- struct cli_credentials *creds = mprGetThisPtr(eid, "creds");
+ struct cli_credentials *creds = (struct cli_credentials *)mprGetThisPtr(eid, "creds");
if (creds == NULL) {
ejsSetErrorMsg(eid, "NULL ejs credentials");
}
@@ -61,7 +61,7 @@ static int ejs_creds_set_domain(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_domain(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -90,7 +90,7 @@ static int ejs_creds_set_username(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_username(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -119,7 +119,7 @@ static int ejs_creds_set_password(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_password(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -136,7 +136,7 @@ static int ejs_creds_set_realm(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_realm(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -165,7 +165,7 @@ static int ejs_creds_set_workstation(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_workstation(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -193,9 +193,9 @@ static int ejs_creds_set_machine_account(MprVarHandle eid, int argc, struct MprV
}
if (NT_STATUS_IS_OK(cli_credentials_set_machine_account(creds))) {
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
} else {
- mpr_Return(eid, mprCreateBoolVar(False));
+ mpr_Return(eid, mprCreateBoolVar(false));
}
return 0;
}
@@ -248,7 +248,7 @@ static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv
return -1;
}
- cli_credentials_set_conf(creds);
+ cli_credentials_set_conf(creds, global_loadparm);
return ejs_credentials_obj(obj, creds);
}
diff --git a/source4/scripting/ejs/smbcalls_data.c b/source4/scripting/ejs/smbcalls_data.c
index 60dadc5165..a98266c3da 100644
--- a/source4/scripting/ejs/smbcalls_data.c
+++ b/source4/scripting/ejs/smbcalls_data.c
@@ -107,7 +107,7 @@ failed:
static int ejs_blobCompare(MprVarHandle eid, int argc, struct MprVar **argv)
{
DATA_BLOB *blob1, *blob2;
- BOOL ret = False;
+ bool ret = false;
if (argc != 2) {
ejsSetErrorMsg(eid, "blobCompare invalid arguments");
@@ -118,24 +118,24 @@ static int ejs_blobCompare(MprVarHandle eid, int argc, struct MprVar **argv)
blob2 = mprToDataBlob(argv[1]);
if (blob1 == blob2) {
- ret = True;
+ ret = true;
goto done;
}
if (blob1 == NULL || blob2 == NULL) {
- ret = False;
+ ret = false;
goto done;
}
if (blob1->length != blob2->length) {
- ret = False;
+ ret = false;
goto done;
}
if (memcmp(blob1->data, blob2->data, blob1->length) != 0) {
- ret = False;
+ ret = false;
goto done;
}
- ret = True;
+ ret = true;
done:
mpr_Return(eid, mprCreateBoolVar(ret));
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index 7b143ae4d9..04162830b4 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -34,7 +34,7 @@
*/
static struct ldb_context *ejs_get_ldb_context(int eid)
{
- struct ldb_context *ldb = mprGetThisPtr(eid, "db");
+ struct ldb_context *ldb = (struct ldb_context *)mprGetThisPtr(eid, "db");
if (ldb == NULL) {
ejsSetErrorMsg(eid, "invalid ldb connection");
}
@@ -452,7 +452,7 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv)
dbfile = argv[0];
- ldb = ldb_wrap_connect(mprMemCtx(), dbfile,
+ ldb = ldb_wrap_connect(mprMemCtx(), global_loadparm, dbfile,
session_info, creds,
0, (const char **)(argv+1));
if (ldb == NULL) {
@@ -483,7 +483,7 @@ static int ejs_ldbClose(MprVarHandle eid, int argc, struct MprVar **argv)
}
mprSetThisPtr(eid, "db", NULL);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
diff --git a/source4/scripting/ejs/smbcalls_param.c b/source4/scripting/ejs/smbcalls_param.c
index afdee28a65..830c45d978 100644
--- a/source4/scripting/ejs/smbcalls_param.c
+++ b/source4/scripting/ejs/smbcalls_param.c
@@ -20,9 +20,9 @@
*/
#include "includes.h"
+#include "param/param.h"
#include "scripting/ejs/smbcalls.h"
#include "lib/appweb/ejs/ejs.h"
-#include "param/param.h"
/*
get parameter
@@ -39,7 +39,7 @@ static int ejs_param_get(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
if (argc == 2) {
@@ -72,7 +72,7 @@ static int ejs_param_get_list(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
if (argc == 2) {
@@ -107,7 +107,7 @@ static int ejs_param_set(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
@@ -148,17 +148,17 @@ static int ejs_param_data(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
ret = mprObject("array");
for (sec = ctx->sections; sec; sec = sec->next) {
struct MprVar ps = mprObject("array");
- struct param *p;
+ struct param_opt *p;
for (p = sec->parameters; p; p = p->next) {
- mprSetVar(&ps, p->name, mprString(p->value));
+ mprSetVar(&ps, p->key, mprString(p->value));
}
mprSetVar(&ret, sec->name, ps);
@@ -184,7 +184,7 @@ static int ejs_param_load(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
ret = param_read(ctx, argv[0]);
@@ -209,7 +209,7 @@ static int ejs_param_save(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
ret = param_write(ctx, argv[0]);
diff --git a/source4/scripting/ejs/smbcalls_reg.c b/source4/scripting/ejs/smbcalls_reg.c
index 4d84587fa4..d4b13cc2ca 100644
--- a/source4/scripting/ejs/smbcalls_reg.c
+++ b/source4/scripting/ejs/smbcalls_reg.c
@@ -32,7 +32,7 @@
*/
static struct registry_context *ejs_get_reg_context(int eid)
{
- struct registry_context *rctx = mprGetThisPtr(eid, "registry");
+ struct registry_context *rctx = (struct registry_context *)mprGetThisPtr(eid, "registry");
if (rctx == NULL) {
ejsSetErrorMsg(eid, "unable to find registry");
}
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 4addd473da..5d7c674208 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -78,7 +78,9 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
/* create a messaging context, looping as we have no way to
allocate temporary server ids automatically */
for (i=0;i<10000;i++) {
- p->msg_ctx = messaging_init(p, cluster_id(EJS_ID_BASE + i), ev);
+ p->msg_ctx = messaging_init(p,
+ lp_messaging_path(p, global_loadparm),
+ cluster_id(EJS_ID_BASE + i), ev);
if (p->msg_ctx) break;
}
if (p->msg_ctx == NULL) {
@@ -144,7 +146,8 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
credentials = mprGetProperty(this, "credentials", NULL);
if (credentials) {
- creds = mprGetPtr(credentials, "creds");
+ creds = (struct cli_credentials *)
+ mprGetPtr(credentials, "creds");
} else {
creds = cmdline_credentials;
}
@@ -188,7 +191,7 @@ static int ejs_irpc_call(int eid, struct MprVar *io,
int i, count;
struct MprVar *results;
- p = mprGetThisPtr(eid, "irpc");
+ p = (struct ejs_irpc_connection *)mprGetThisPtr(eid, "irpc");
ejs = talloc(mprMemCtx(), struct ejs_rpc);
if (ejs == NULL) {
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
index 3c550e57cd..7c9ef50cf5 100644
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ b/source4/scripting/ejs/smbcalls_samba3.c
@@ -433,7 +433,7 @@ static int ejs_find_domainsecrets(MprVarHandle eid, int argc, struct MprVar **ar
return -1;
}
- samba3 = mprGetThisPtr(eid, "samba3");
+ samba3 = (struct samba3 *)mprGetThisPtr(eid, "samba3");
mprAssert(samba3);
sec = samba3_find_domainsecrets(samba3, mprToString(argv[0]));
diff --git a/source4/scripting/ejs/smbcalls_string.c b/source4/scripting/ejs/smbcalls_string.c
index b83178dbba..541303ff2d 100644
--- a/source4/scripting/ejs/smbcalls_string.c
+++ b/source4/scripting/ejs/smbcalls_string.c
@@ -238,7 +238,7 @@ static int ejs_join(MprVarHandle eid, int argc, struct MprVar **argv)
goto failed;
}
for (i=1;list[i];i++) {
- ret = talloc_asprintf_append(ret, "%s%s", separator, list[i]);
+ ret = talloc_asprintf_append_buffer(ret, "%s%s", separator, list[i]);
if (ret == NULL) {
goto failed;
}
@@ -275,7 +275,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
ret = talloc_strdup(tmp_ctx, "");
/* avoid all the format string warnings */
- _asprintf_append = (_asprintf_append_t)talloc_asprintf_append;
+ _asprintf_append = (_asprintf_append_t)talloc_asprintf_append_buffer;
/*
hackity hack ...
@@ -284,7 +284,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
char *fmt2;
int len, len_count=0;
char *tstr;
- ret = talloc_asprintf_append(ret, "%*.*s",
+ ret = talloc_asprintf_append_buffer(ret, "%*.*s",
(int)(p-format), (int)(p-format),
format);
if (ret == NULL) goto failed;
@@ -299,7 +299,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
tstr--;
}
if (strcmp(tstr, "%") == 0) {
- ret = talloc_asprintf_append(ret, "%%");
+ ret = talloc_asprintf_append_buffer(ret, "%%");
if (ret == NULL) {
goto failed;
}
@@ -372,7 +372,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
format += len+1;
}
- ret = talloc_asprintf_append(ret, "%s", format);
+ ret = talloc_asprintf_append_buffer(ret, "%s", format);
mpr_Return(eid, mprString(ret));
talloc_free(tmp_ctx);
return 0;
@@ -437,7 +437,7 @@ static int ejs_encodeURIComponent(MprVarHandle eid, int argc, char **argv)
if (!isalnum(s[i])) count++;
}
- ret = talloc_size(mprMemCtx(), i + count*2 + 1);
+ ret = talloc_array(mprMemCtx(), char, i + count*2 + 1);
if (ret == NULL) {
return -1;
}
@@ -470,7 +470,7 @@ static int ejs_decodeURIComponent(MprVarHandle eid, int argc, char **argv)
s = argv[0];
- ret = talloc_size(mprMemCtx(), strlen(s) + 1);
+ ret = talloc_array(mprMemCtx(), char, strlen(s) + 1);
if (ret == NULL) {
return -1;
}
diff --git a/source4/scripting/ejs/smbcalls_sys.c b/source4/scripting/ejs/smbcalls_sys.c
index 96e665ab3a..10de8e162e 100644
--- a/source4/scripting/ejs/smbcalls_sys.c
+++ b/source4/scripting/ejs/smbcalls_sys.c
@@ -294,7 +294,7 @@ static int ejs_sys_file_load(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_sys_file_save(MprVarHandle eid, int argc, char **argv)
{
- BOOL ret;
+ bool ret;
if (argc != 2) {
ejsSetErrorMsg(eid, "sys_file_save invalid arguments");
return -1;
@@ -311,7 +311,7 @@ static int ejs_sys_file_save(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_sys_mkdir(MprVarHandle eid, int argc, struct MprVar **argv)
{
- BOOL ret;
+ bool ret;
char *name;
if (argc != 2) {
ejsSetErrorMsg(eid, "sys_mkdir invalid arguments, need mkdir(dirname, mode)");
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index c97bc1ff8d..29ce763f96 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -26,10 +26,11 @@
#include "scripting/ejs/smbcalls.h"
#include "auth/gensec/gensec.h"
#include "ldb/include/ldb.h"
+#include "dynconfig.h"
static EjsId eid;
-static void smbscript_ejs_exception(const char *reason)
+_NORETURN_ static void smbscript_ejs_exception(const char *reason)
{
Ejs *ep = ejsPtr(eid);
ejsSetErrorMsg(eid, "%s", reason);
@@ -52,7 +53,9 @@ int main(int argc, const char **argv)
fault_setup(argv[0]);
if (getenv("SMB_CONF_PATH")) {
- lp_set_cmdline("config file", getenv("SMB_CONF_PATH"));
+ lp_load(getenv("SMB_CONF_PATH"));
+ } else {
+ lp_load(dyn_CONFIGFILE);
}
ldb_global_init();
@@ -60,7 +63,6 @@ int main(int argc, const char **argv)
gensec_init();
mprSetCtx(mem_ctx);
- lp_load();
if (argc < 2) {
fprintf(stderr, "You must supply a script name\n");