summaryrefslogtreecommitdiff
path: root/source4/scripting/libjs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/libjs')
-rw-r--r--source4/scripting/libjs/auth.js18
-rw-r--r--source4/scripting/libjs/base.js53
-rw-r--r--source4/scripting/libjs/encoder.js116
-rw-r--r--source4/scripting/libjs/management.js157
-rw-r--r--source4/scripting/libjs/samr.js170
-rw-r--r--source4/scripting/libjs/server_call.js83
-rw-r--r--source4/scripting/libjs/winreg.js291
7 files changed, 0 insertions, 888 deletions
diff --git a/source4/scripting/libjs/auth.js b/source4/scripting/libjs/auth.js
deleted file mode 100644
index 3fe81d0ea7..0000000000
--- a/source4/scripting/libjs/auth.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- auth js library functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-
-/*
- get a list of domains for SWAT authentication
-*/
-function getDomainList()
-{
- var ret = new Array(2);
- var lp = loadparm_init();
- ret[0] = "System User";
- ret[1] = lp.get("workgroup");
- return ret;
-}
diff --git a/source4/scripting/libjs/base.js b/source4/scripting/libjs/base.js
index d861073a07..790dfeb3e0 100644
--- a/source4/scripting/libjs/base.js
+++ b/source4/scripting/libjs/base.js
@@ -21,48 +21,6 @@ function printf()
}
/*
- helper function to setup a rpc io object, ready for input
-*/
-function irpcObj()
-{
- var o = new Object();
- o.input = new Object();
- return o;
-}
-
-/*
- check that a status result is OK
-*/
-function check_status_ok(status)
-{
- if (status.is_ok != true) {
- printVars(status);
- }
- assert(status.is_ok == true);
-}
-
-/*
- check that two arrays are equal
-*/
-function check_array_equal(a1, a2)
-{
- assert(a1.length == a2.length);
- for (i=0; i<a1.length; i++) {
- assert(a1[i] == a2[i]);
- }
-}
-
-/*
- check that an array is all zeros
-*/
-function check_array_zero(a)
-{
- for (i=0; i<a.length; i++) {
- assert(a[i] == 0);
- }
-}
-
-/*
substitute strings of the form ${NAME} in str, replacing
with substitutions from subobj
*/
@@ -90,14 +48,3 @@ function substitute_var(str, subobj)
}
return join("", list);
}
-
-/*
- return "s" if a number should be shown as plural
-*/
-function plural(n)
-{
- if (n == 1) {
- return "";
- }
- return "s";
-}
diff --git a/source4/scripting/libjs/encoder.js b/source4/scripting/libjs/encoder.js
deleted file mode 100644
index 6cb780c00d..0000000000
--- a/source4/scripting/libjs/encoder.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- server side js functions for encoding/decoding objects into linear strings
-
- Copyright Andrew Tridgell 2005
- released under the GNU GPL Version 3 or later
-*/
-/*
- usage:
-
- enc = encodeObject(obj);
- obj = decodeObject(enc);
-
- The encoded format of the object is a string that is safe to
- use in URLs
-
- Note that only data elements are encoded, not functions
-*/
-
-function __count_members(o) {
- var i, count = 0;
- for (i in o) {
- count++;
- }
- if (o.length != undefined) {
- count++;
- }
- return count;
-}
-
-function __replace(str, old, rep) {
- var s = string_init();
- var a = s.split(old, str);
- var j = s.join(rep, a);
- return s.join(rep, a);
-}
-
-function encodeElement(e, name) {
- var t = typeof(e);
- var r;
- var s = string_init();
- if (t == 'object' && e == null) {
- t = 'null';
- }
- if (t == 'object') {
- r = s.sprintf("%s:%s:%s", name, t, encodeObject(e));
- } else if (t == "string") {
- var enc = s.encodeURIComponent(e);
- var rep = __replace(enc, '%', '#');
- r = s.sprintf("%s:%s:%s:",
- name, t, __replace(s.encodeURIComponent(e),'%','#'));
- } else if (t == "boolean" || t == "number") {
- r = s.sprintf("%s:%s:%s:", name, t, "" + e);
- } else if (t == "undefined" || t == "null") {
- r = s.sprintf("%s:%s:", name, t);
- } else if (t == "pointer") {
- r = s.sprintf("%s:string:(POINTER):", name);
- } else {
- println("Unable to linearise type " + t);
- r = "";
- }
- return r;
-}
-
-function encodeObject(o) {
- var s = string_init();
- var i, r = s.sprintf("%u:", __count_members(o));
- for (i in o) {
- r = r + encodeElement(o[i], i);
- }
- if (o.length != undefined) {
- r = r + encodeElement(o.length, 'length');
- }
- return r;
-}
-
-function decodeObjectArray(a) {
- var s = string_init();
- var o = new Object();
- var i, count = a[a.i]; a.i++;
- for (i=0;i<count;i++) {
- var name = a[a.i]; a.i++;
- var type = a[a.i]; a.i++;
- var value;
- if (type == 'object') {
- o[name] = decodeObjectArray(a);
- } else if (type == "string") {
- value = s.decodeURIComponent(__replace(a[a.i],'#','%')); a.i++;
- o[name] = value;
- } else if (type == "boolean") {
- value = a[a.i]; a.i++;
- if (value == 'true') {
- o[name] = true;
- } else {
- o[name] = false;
- }
- } else if (type == "undefined") {
- o[name] = undefined;
- } else if (type == "null") {
- o[name] = null;
- } else if (type == "number") {
- value = a[a.i]; a.i++;
- o[name] = value + 0;
- } else {
- println("Unable to delinearise type " + t);
- assert(t == "supported type");
- }
- }
- return o;
-}
-
-function decodeObject(str) {
- var s = string_init();
- var a = s.split(':', str);
- a.i = 0;
- return decodeObjectArray(a);
-}
diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js
deleted file mode 100644
index 4a43275156..0000000000
--- a/source4/scripting/libjs/management.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- backend code for Samba4 management
- Copyright Andrew Tridgell 2005
- Released under the GNU GPL version 3 or later
-*/
-
-
-/*
- return a list of current sessions
-*/
-function smbsrv_sessions()
-{
- var irpc = irpc_init();
- status = irpc.connect("smb_server");
- if (status.is_ok != true) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.level = irpc.SMBSRV_INFO_SESSIONS;
- status = irpc.smbsrv_information(io);
- if (status.is_ok != true) {
- return undefined;
- }
-
- /* gather the results into a single array */
- var i, count=0, ret = new Array(0);
- for (i=0;i<io.results.length;i++) {
- var sessions = io.results[i].info.sessions.sessions;
- var j;
- for (j=0;j<sessions.length;j++) {
- ret[count] = sessions[j];
- count++;
- }
- }
- return ret;
-}
-
-/*
- return a list of current tree connects
-*/
-function smbsrv_tcons()
-{
- var irpc = irpc_init();
- status = irpc.connect("smb_server");
- if (status.is_ok != true) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.level = irpc.SMBSRV_INFO_TCONS;
- status = irpc.smbsrv_information(io);
- if (status.is_ok != true) {
- return undefined;
- }
-
- /* gather the results into a single array */
- var i, count=0, ret = new Object();
- for (i=0;i<io.results.length;i++) {
- var tcons = io.results[i].info.tcons.tcons;
- var j;
- for (j=0;j<tcons.length;j++) {
- ret[count] = tcons[j];
- count++;
- }
- }
- ret.length = count;
- return ret;
-}
-
-/*
- return nbtd statistics
-*/
-function nbtd_statistics()
-{
- var irpc = irpc_init();
- status = irpc.connect("nbt_server");
- if (status.is_ok != true) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.level = irpc.NBTD_INFO_STATISTICS;
- status = irpc.nbtd_information(io);
- if (status.is_ok != true) {
- return undefined;
- }
- return io.results[0].info.stats;
-}
-
-/*
- see if a service is enabled
-*/
-function service_enabled(name)
-{
- var lp = loadparm_init();
- var services = lp.get("server services");
- var i;
- for (i=0;i<services.length;i++) {
- if (services[i] == name) {
- return true;
- }
- }
- return false;
-}
-
-/*
- show status of a server
-*/
-function server_status(name)
-{
- var i;
- var io;
- var irpc = irpc_init();
-
- if (!service_enabled(name)) {
- return "DISABLED";
- }
-
- status = irpc.connect(name + "_server");
- if (status.is_ok != true) {
- return "DOWN";
- }
-
- var io = irpcObj();
- status = irpc.irpc_uptime(io);
- if (status.is_ok != true) {
- return "NOT RESPONDING";
- }
-
- return "RUNNING";
-}
-
-/*
- show status of a stream server
-*/
-function stream_server_status(name)
-{
- var irpc = irpc_init();
-
- if (!service_enabled(name)) {
- return "DISABLED";
- }
- status = irpc.connect(name + "_server");
- if (status.is_ok != true) {
- return "0 connections";
- }
-
- var io = irpcObj();
- status = irpc.irpc_uptime(io);
- if (status.is_ok != true) {
- return "NOT RESPONDING";
- }
-
- var n = io.results.length;
- return sprintf("%u connection%s", n, plural(n));
-}
diff --git a/source4/scripting/libjs/samr.js b/source4/scripting/libjs/samr.js
deleted file mode 100644
index 6e8c70af3c..0000000000
--- a/source4/scripting/libjs/samr.js
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- samr rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-if (global["HAVE_SAMR_JS"] != undefined) {
- return;
-}
-HAVE_SAMR_JS=1
-
-/*
- return a list of names and indexes from a samArray
-*/
-function samArray(output)
-{
- var list = new Array(output.num_entries);
- if (output.sam == NULL) {
- return list;
- }
- var i, entries = output.sam.entries;
- for (i=0;i<output.num_entries;i++) {
- list[i] = new Object();
- list[i].name = entries[i].name;
- list[i].idx = entries[i].idx;
- }
- return list;
-}
-
-/*
- connect to the sam database
-*/
-function samrConnect(conn)
-{
- security_init(conn);
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = conn.samr_Connect2(io);
- check_status_ok(status);
- return io.output.connect_handle;
-}
-
-/*
- close a handle
-*/
-function samrClose(conn, handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- var status = conn.samr_Close(io);
- check_status_ok(status);
-}
-
-/*
- get the sid for a domain
-*/
-function samrLookupDomain(conn, handle, domain)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.domain_name = domain;
- var status = conn.samr_LookupDomain(io);
- check_status_ok(status);
- return io.output.sid;
-}
-
-/*
- open a domain by sid
-*/
-function samrOpenDomain(conn, handle, sid)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.sid = sid;
- var status = conn.samr_OpenDomain(io);
- check_status_ok(status);
- return io.output.domain_handle;
-}
-
-/*
- open a user by rid
-*/
-function samrOpenUser(conn, handle, rid)
-{
- var io = irpcObj();
- io.input.domain_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.rid = rid;
- var status = conn.samr_OpenUser(io);
- check_status_ok(status);
- return io.output.user_handle;
-}
-
-/*
- return a list of all users
-*/
-function samrEnumDomainUsers(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainUsers(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of all groups
-*/
-function samrEnumDomainGroups(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainGroups(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of domains
-*/
-function samrEnumDomains(conn, handle)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.resume_handle = 0;
- io.input.buf_size = -1;
- var status = conn.samr_EnumDomains(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return information about a user
-*/
-function samrQueryUserInfo(conn, user_handle, level)
-{
- var r, io = irpcObj();
- io.input.user_handle = user_handle;
- io.input.level = level;
- var status = conn.samr_QueryUserInfo(io);
- check_status_ok(status);
- return io.output.info.info3;
-}
-
-
-/*
- fill a user array with user information from samrQueryUserInfo
-*/
-function samrFillUserInfo(conn, dom_handle, users, level)
-{
- var i;
- for (i=0;i<users.length;i++) {
- var r, user_handle, info;
- user_handle = samrOpenUser(conn, dom_handle, users[i].idx);
- info = samrQueryUserInfo(conn, user_handle, level);
- info.name = users[i].name;
- info.idx = users[i].idx;
- users[i] = info;
- samrClose(conn, user_handle);
- }
-}
-
diff --git a/source4/scripting/libjs/server_call.js b/source4/scripting/libjs/server_call.js
deleted file mode 100644
index 46414a90dd..0000000000
--- a/source4/scripting/libjs/server_call.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- server side js functions for handling async calls from js clients
-
- Copyright Andrew Tridgell 2005
- released under the GNU GPL Version 3 or later
-*/
-
-libinclude("encoder.js");
-
-/*
- register a new call
-*/
-function __register_call(name, func)
-{
- var c = this;
- c.calls[name] = func;
-}
-
-/*
- run a call sent from the client, and output the returned object (if any)
-*/
-function __run_call() {
- var c = this;
- var name = form['ajaj_func'];
- if (name == undefined) {
- /* no function to run */
- return;
- }
- var args = form['ajaj_args'];
- if (args == undefined) {
- println("no function arguments given in run_call");
- exit(0);
- }
- args = decodeObject(args);
- if (c.calls[name] == undefined) {
- println("undefined remote call " + name);
- exit(0);
- }
- var f = c.calls[name];
- var res;
- /* oh what a hack - should write a varargs ejs helper */
- if (args.length == 0) {
- res = f();
- } else if (args.length == 1) {
- res = f(args[0]);
- } else if (args.length == 2) {
- res = f(args[0], args[1]);
- } else if (args.length == 3) {
- res = f(args[0], args[1], args[2]);
- } else if (args.length == 4) {
- res = f(args[0], args[1], args[2], args[3]);
- } else if (args.length == 5) {
- res = f(args[0], args[1], args[2], args[3], args[4]);
- } else if (args.length == 6) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5]);
- } else if (args.length == 7) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
- } else if (args.length == 8) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
- } else {
- println("too many arguments for remote call: " + name);
- exit(0);
- }
- var repobj = new Object();
- repobj.res = res;
- write(encodeObject(repobj));
- exit(0);
-}
-
-
-
-/*
- initialise a server call object
-*/
-function servCallObj()
-{
- var c = new Object();
- c.add = __register_call;
- c.run = __run_call;
- c.calls = new Object();
- return c;
-}
-
diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js
deleted file mode 100644
index 9db415694d..0000000000
--- a/source4/scripting/libjs/winreg.js
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- winreg rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-libinclude("base.js");
-
-/*
- close a handle
-*/
-function __winreg_close(handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- this.winreg_CloseKey(io);
-}
-
-
-/*
- open a hive
-*/
-function __winreg_open_hive(hive)
-{
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status;
- if (hive == "HKLM") {
- status = this.winreg_OpenHKLM(io);
- } else if (hive == "HKCR") {
- status = this.winreg_OpenHKCR(io);
- } else if (hive == "HKPD") {
- status = this.winreg_OpenHKPD(io);
- } else if (hive == "HKU") {
- status = this.winreg_OpenHKU(io);
- } else {
- this._last_error = "Unknown hive " + hive;
- return undefined;
- }
- if (!status.is_ok) {
- return undefined;
- }
- return io.output.handle;
-}
-
-/*
- open a handle to a path
-*/
-function __winreg_open_path(path)
-{
- var s = string_init();
- var i, components = s.split('\\', path);
-
- /* cope with a leading slash */
- if (components[0] == '') {
- for (i=0;i<(components.length-1);i++) {
- components[i] = components[i+1];
- }
- delete(components[i]);
- }
-
- if (components.length == 0) {
- return undefined;
- }
-
- var handle = this.open_hive(components[0]);
- if (handle == undefined) {
- return undefined;
- }
-
- if (components.length == 1) {
- return handle;
- }
-
- var hpath = components[1];
-
- for (i=2;i<components.length;i++) {
- hpath = hpath + "\\" + components[i];
- }
-
- io = irpcObj();
- io.input.parent_handle = handle;
- io.input.keyname = hpath;
- io.input.unknown = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = this.winreg_OpenKey(io);
-
- this.close(handle);
-
- if (!status.is_ok) {
- return undefined;
- }
- if (io.output.result != "WERR_OK") {
- return undefined;
- }
-
- return io.output.handle;
-}
-
-/*
- return a list of keys for a winreg server given a path
- usage:
- list = reg.enum_path(path);
-*/
-function __winreg_enum_path(path)
-{
- var list = new Array(0);
-
- if (path == null || path == "\\" || path == "") {
- return new Array("HKLM", "HKU");
- }
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 32;
- io.input.name.name = NULL;
- io.input.keyclass = new Object();
- io.input.keyclass.length = 0;
- io.input.keyclass.size = 1024;
- io.input.keyclass.name = NULL;
- io.input.last_changed_time = 0;
-
- var idx = 0;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumKey(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.name.size = io.input.name.size * 2;
- idx--;
- if (io.input.name.size > 32000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- list[list.length] = out.name.name;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- return a list of values for a winreg server given a path
- usage:
- list = reg.enum_values(path);
-
- each returned list element is an object containing a name, a
- type and a value
-*/
-function __winreg_enum_values(path)
-{
- var data = datablob_init();
- var list = new Array(0);
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 128;
- io.input.name.name = "";
- io.input.type = 0;
- io.input.value = new Array(0);
- io.input.size = 1024;
- io.input.length = 0;
-
- var idx;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumValue(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.size = io.input.size * 2;
- io.input.name.size = io.input.name.size * 2;
- idx--;
- /* limit blobs to 1M */
- if (io.input.size > 1000000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- var el = new Object();
- el.name = out.name.name;
- el.type = out.type;
- el.rawvalue = out.value;
- el.value = data.regToVar(el.rawvalue, el.type);
- el.size = out.size;
- list[list.length] = el;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- create a new key
- ok = reg.create_key(path, key);
-*/
-function __winreg_create_key(path, key)
-{
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = key;
- io.input.keyclass = NULL;
- io.input.options = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.secdesc = NULL;
- io.input.action_taken = 0;
-
- var status = this.winreg_CreateKey(io);
- this.close(handle);
- if (!status.is_ok) {
- return false;
- }
- if (io.output.result != "WERR_OK") {
- return false;
- }
- this.close(io.output.new_handle);
- return true;
-}
-
-
-/*
- return a string for a winreg type
-*/
-function __winreg_typestring(type)
-{
- return this.typenames[type];
-}
-
-/*
- initialise the winreg lib, returning an object
-*/
-function winregObj()
-{
- var reg = winreg_init();
- security_init(reg);
-
- reg.typenames = new Array("REG_NONE", "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY",
- "REG_DWORD", "REG_DWORD_BIG_ENDIAN", "REG_LINK", "REG_MULTI_SZ",
- "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR",
- "REG_RESOURCE_REQUIREMENTS_LIST", "REG_QWORD");
-
- reg.close = __winreg_close;
- reg.open_hive = __winreg_open_hive;
- reg.open_path = __winreg_open_path;
- reg.enum_path = __winreg_enum_path;
- reg.enum_values = __winreg_enum_values;
- reg.create_key = __winreg_create_key;
- reg.typestring = __winreg_typestring;
-
- return reg;
-}