summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/smb_build/makefile.pm1
-rw-r--r--source4/dynconfig.c3
-rw-r--r--source4/dynconfig.h1
-rw-r--r--source4/dynconfig.mk9
-rw-r--r--source4/main.mk2
-rw-r--r--source4/param/loadparm.c7
-rw-r--r--source4/script/installjsonrpc.sh32
-rw-r--r--source4/script/installswat.sh11
-rw-r--r--source4/scripting/ejs/smbcalls.c12
-rw-r--r--source4/web_server/http.c43
-rw-r--r--swat/apps/samba/utils/ldbbrowse.html96
11 files changed, 141 insertions, 76 deletions
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index ead5592968..780ba99f03 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -86,6 +86,7 @@ INCLUDEDIR = $self->{config}->{includedir}
CONFIGDIR = $self->{config}->{sysconfdir}
DATADIR = $self->{config}->{datadir}
SWATDIR = $self->{config}->{datadir}/swat
+SERVICESDIR = $self->{config}->{datadir}/services
JSDIR = $self->{config}->{datadir}/js
SETUPDIR = $self->{config}->{datadir}/setup
VARDIR = $self->{config}->{localstatedir}
diff --git a/source4/dynconfig.c b/source4/dynconfig.c
index 5b1074382c..34a8cbec99 100644
--- a/source4/dynconfig.c
+++ b/source4/dynconfig.c
@@ -80,6 +80,9 @@ _PUBLIC_ const char *dyn_PRIVATE_DIR = PRIVATE_DIR;
/** SWAT data file (images, etc) directory */
_PUBLIC_ const char *dyn_SWATDIR = SWATDIR;
+/** JSON-RPC Services script directory */
+_PUBLIC_ const char *dyn_SERVICESDIR = SERVICESDIR;
+
/** SETUP files (source files used by the provision) */
_PUBLIC_ const char *dyn_SETUPDIR = SETUPDIR;
diff --git a/source4/dynconfig.h b/source4/dynconfig.h
index 312283c5fb..c0854b9951 100644
--- a/source4/dynconfig.h
+++ b/source4/dynconfig.h
@@ -37,6 +37,7 @@ extern const char *dyn_LOCKDIR;
extern const char *dyn_PIDDIR;
extern const char *dyn_PRIVATE_DIR;
extern const char *dyn_SWATDIR;
+extern const char *dyn_SERVICESDIR;
extern const char *dyn_JSDIR;
extern const char *dyn_SETUPDIR;
extern const char *dyn_WINBINDD_SOCKET_DIR;
diff --git a/source4/dynconfig.mk b/source4/dynconfig.mk
index 76479af0fa..ed901a838d 100644
--- a/source4/dynconfig.mk
+++ b/source4/dynconfig.mk
@@ -8,7 +8,8 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
-DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DDATADIR=\"$(DATADIR)\" \
-DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
-DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
- -DSWATDIR=\"$(SWATDIR)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
+ -DSWATDIR=\"$(SWATDIR)\" -DSERVICESDIR=\"$(SERVICESDIR)\" \
+ -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
-DMODULESDIR=\"$(MODULESDIR)\" -DJSDIR=\"$(JSDIR)\" \
-DTORTUREDIR=\"$(TORTUREDIR)\" \
-DSETUPDIR=\"$(SETUPDIR)\" -DWINBINDD_SOCKET_DIR=\"$(WINBINDD_SOCKET_DIR)\"
@@ -25,9 +26,11 @@ DEVEL_PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" -DBINDIR=\"$(builddir)/bin\" \
-DPIDDIR=\"$(PIDDIR)\" -DDATADIR=\"$(srcdir)/codepages\" \
-DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
-DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
- -DSWATDIR=\"$(srcdir)/../swat\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
+ -DSWATDIR=\"$(srcdir)/../../swat\" \
+ -DSERVICESDIR=\"$(srcdir)/../../services\"\
+ -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
-DMODULESDIR=\"$(builddir)/bin/modules\" \
- -DJSDIR=\"$(srcdir)/scripting/libjs\" \
+ -DJSDIR=\"$(srcdir)/../scripting/libjs\" \
-DSETUPDIR=\"$(srcdir)/setup\" -DTORTUREDIR=\"$(srcdir)/bin/torture\" \
-DWINBINDD_SOCKET_DIR=\"$(WINBINDD_SOCKET_DIR)\"
diff --git a/source4/main.mk b/source4/main.mk
index 0edf57859f..378152c40f 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -60,6 +60,7 @@ showlayout:
@echo ' setupdir: $(SETUPDIR)'
@echo ' jsdir: $(JSDIR)'
@echo ' swatdir: $(SWATDIR)'
+ @echo ' servicesdir: $(SERVICESDIR)'
@echo ' mandir: $(MANDIR)'
@echo ' torturedir: $(TORTUREDIR)'
@echo ' datadir: $(DATADIR)'
@@ -153,6 +154,7 @@ installdat: installdirs
installswat: installdirs
@$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
+ @$(SHELL) $(srcdir)/script/installjsonrpc.sh $(DESTDIR)$(SERVICESDIR) $(srcdir)
installman: manpages installdirs
@$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 1e5df4fcbe..c781a00ae5 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -114,7 +114,7 @@ typedef struct
char *szWINS_URL;
char *szPrivateDir;
char **jsInclude;
- char *jsonrpcBase;
+ char *jsonrpcServicesDir;
char **szPasswordServers;
char *szSocketOptions;
char *szRealm;
@@ -543,7 +543,7 @@ static struct parm_struct parm_table[] = {
{"modules dir", P_STRING, P_GLOBAL, &Globals.szModulesDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"js include", P_LIST, P_GLOBAL, &Globals.jsInclude, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"jsonrpc base", P_STRING, P_GLOBAL, &Globals.jsonrpcBase, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"jsonrpc services directory", P_STRING, P_GLOBAL, &Globals.jsonrpcServicesDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"setup directory", P_STRING, P_GLOBAL, &Globals.szSetupDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, FLAG_DEVELOPER},
@@ -707,6 +707,7 @@ static void init_globals(void)
do_parameter("kpasswd port", "464", NULL);
do_parameter("web port", "901", NULL);
do_parameter("swat directory", dyn_SWATDIR, NULL);
+ do_parameter("jsonrpc services directory", dyn_SERVICESDIR, NULL);
do_parameter("nt status support", "True", NULL);
@@ -913,7 +914,7 @@ _PUBLIC_ FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
_PUBLIC_ FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
_PUBLIC_ FN_GLOBAL_LIST(lp_js_include, &Globals.jsInclude)
-_PUBLIC_ FN_GLOBAL_STRING(lp_jsonrpc_base, &Globals.jsonrpcBase)
+_PUBLIC_ FN_GLOBAL_STRING(lp_jsonrpc_services_dir, &Globals.jsonrpcServicesDir)
_PUBLIC_
_PUBLIC_
_PUBLIC_ FN_LOCAL_STRING(lp_servicename, szService)
diff --git a/source4/script/installjsonrpc.sh b/source4/script/installjsonrpc.sh
new file mode 100644
index 0000000000..b91f6bf3bb
--- /dev/null
+++ b/source4/script/installjsonrpc.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+SERVICESDIR=$1
+SRCDIR=$2
+
+echo Installing JSON-RPC services in $SERVICESDIR
+
+cd $SRCDIR/../services || exit 1
+
+mkdir -p $SERVICESDIR || exit 1
+
+installdir() {
+ for f in $*; do
+ dname=`dirname $f`
+ echo "Installing $f in $dname"
+ test -d $SERVICESDIR/$dname || mkdir -p $SERVICESDIR/$dname || exit 1
+ cp $f $SERVICESDIR/$dname/ || exit 1
+ chmod 0644 $SERVICESDIR/$f || exit 1
+ done
+}
+
+installdir `find . -name '*.esp'`
+
+cat << EOF
+======================================================================
+The JSON-RPC services have been installed.
+======================================================================
+EOF
+
+
+exit 0
+
diff --git a/source4/script/installswat.sh b/source4/script/installswat.sh
index 72dfc2f456..549c11da35 100644
--- a/source4/script/installswat.sh
+++ b/source4/script/installswat.sh
@@ -34,16 +34,5 @@ The swat files have been installed.
======================================================================
EOF
-cd $SRCDIR/.. || exit 1
-
-installdir `find services -name '*.esp'`
-
-cat << EOF
-======================================================================
-The JSON-RPC services have been installed.
-======================================================================
-EOF
-
-
exit 0
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;
diff --git a/source4/web_server/http.c b/source4/web_server/http.c
index 4aef4a1dc8..210151f10f 100644
--- a/source4/web_server/http.c
+++ b/source4/web_server/http.c
@@ -36,7 +36,7 @@
#define SWAT_SESSION_KEY "SwatSessionId"
#define HTTP_PREAUTH_URI "/scripting/preauth.esp"
#define JSONRPC_REQUEST "/services"
-#define JSONRPC_SERVER "/services/request.esp"
+#define JSONRPC_SERVER "/request.esp"
/* state of the esp subsystem for a specific request */
struct esp_state {
@@ -105,7 +105,9 @@ static void http_output_headers(struct websrv_context *web)
/*
return the local path for a URL
*/
-static const char *http_local_path(struct websrv_context *web, const char *url)
+static const char *http_local_path(struct websrv_context *web,
+ const char *url,
+ const char *base_dir)
{
int i;
char *path;
@@ -120,7 +122,7 @@ static const char *http_local_path(struct websrv_context *web, const char *url)
}
}
- path = talloc_asprintf(web, "%s/%s", lp_swat_directory(), url+1);
+ path = talloc_asprintf(web, "%s/%s", base_dir, url+1);
if (path == NULL) return NULL;
if (directory_exist(path)) {
@@ -132,14 +134,18 @@ static const char *http_local_path(struct websrv_context *web, const char *url)
/*
called when esp wants to read a file to support include() calls
*/
-static int http_readFile(EspHandle handle, char **buf, int *len, const char *path)
+static int http_readFile(EspHandle handle,
+ char **buf,
+ int *len,
+ const char *path,
+ const char *base_dir)
{
struct websrv_context *web = talloc_get_type(handle, struct websrv_context);
int fd = -1;
struct stat st;
*buf = NULL;
- path = http_local_path(web, path);
+ path = http_local_path(web, path, base_dir);
if (path == NULL) goto failed;
fd = open(path, O_RDONLY);
@@ -164,6 +170,16 @@ failed:
return -1;
}
+static int http_readFileFromSwatDir(EspHandle handle,
+ char **buf,
+ int *len,
+ const char *path)
+{
+ return http_readFile(handle, buf, len, path, lp_swat_directory());
+}
+
+
+
/*
called when esp wants to find the real path of a file
*/
@@ -374,7 +390,7 @@ static void http_simple_request(struct websrv_context *web)
const char *path;
struct stat st;
- path = http_local_path(web, url);
+ path = http_local_path(web, url, lp_swat_directory());
if (path == NULL) goto invalid;
/* looks ok */
@@ -502,7 +518,7 @@ static void esp_request(struct esp_state *esp, const char *url)
int res;
char *emsg = NULL, *buf;
- if (http_readFile(web, &buf, &size, url) != 0) {
+ if (http_readFile(web, &buf, &size, url, lp_swat_directory()) != 0) {
http_error_unix(web, url);
return;
}
@@ -529,7 +545,9 @@ static void esp_request(struct esp_state *esp, const char *url)
static void jsonrpc_request(struct esp_state *esp)
{
struct websrv_context *web = esp->web;
- const char *path = http_local_path(web, JSONRPC_SERVER);
+ const char *path = http_local_path(web,
+ JSONRPC_SERVER,
+ lp_jsonrpc_services_dir());
MprVar *global;
MprVar v;
MprVar temp;
@@ -558,7 +576,8 @@ static void jsonrpc_request(struct esp_state *esp)
}
/* Call the server request script */
- if (http_readFile(web, &buf, &size, JSONRPC_SERVER) != 0) {
+ if (http_readFile(web, &buf, &size,
+ JSONRPC_SERVER, lp_jsonrpc_services_dir()) != 0) {
http_error_unix(web, JSONRPC_SERVER);
return;
}
@@ -601,7 +620,9 @@ static void jsonrpc_request(struct esp_state *esp)
*/
static BOOL http_preauth(struct esp_state *esp)
{
- const char *path = http_local_path(esp->web, HTTP_PREAUTH_URI);
+ const char *path = http_local_path(esp->web,
+ HTTP_PREAUTH_URI,
+ lp_swat_directory());
int i;
if (path == NULL) {
http_error(esp->web, 500, "Internal server error");
@@ -814,7 +835,7 @@ static const struct Esp esp_control = {
.setHeader = http_setHeader,
.redirect = http_redirect,
.setResponseCode = http_setResponseCode,
- .readFile = http_readFile,
+ .readFile = http_readFileFromSwatDir,
.mapToStorage = http_mapToStorage,
.setCookie = http_setCookie,
.createSession = http_createSession,
diff --git a/swat/apps/samba/utils/ldbbrowse.html b/swat/apps/samba/utils/ldbbrowse.html
index 81b74c44d2..1e6f21ee11 100644
--- a/swat/apps/samba/utils/ldbbrowse.html
+++ b/swat/apps/samba/utils/ldbbrowse.html
@@ -248,65 +248,75 @@ function buildPageSearch(page)
// Track the maximum length of the attribute values
var maxLen = 0;
- for (var i = 0; i < result.length; i++)
+ if (result && result["length"])
{
- var o = result[i];
- if (typeof(o) != "object")
+ len = result["length"];
+ for (var i = 0; i < result["length"]; i++)
{
- alert("Found unexpected result, type " +
- typeof(o) +
- ", " +
- o +
- "\n");
- continue;
- }
- for (var field in o)
- {
- // skip dn and distinguishedName fields;
- // they're shown in each row anyway.
- if (field == "dn" || field == "distinguishedName")
+ var o = result[i];
+ if (typeof(o) != "object")
{
+ alert("Found unexpected result, type " +
+ typeof(o) +
+ ", " +
+ o +
+ "\n");
continue;
}
-
- // If it's multi-valued (type is an array)...
- if (typeof(o[field]) == "object")
+ for (var field in o)
{
- // ... then add each value with same name
- var a = o[field];
- for (var i = 0; i < a.length; i++)
+ // skip dn and distinguishedName fields;
+ // they're shown in each row anyway.
+ if (field == "dn" || field == "distinguishedName")
{
- if (a[i].length > maxLen)
+ continue;
+ }
+
+ // If it's multi-valued (type is an array)...
+ if (typeof(o[field]) == "object")
+ {
+ // ... then add each value with same name
+ var a = o[field];
+ for (var i = 0; i < a.length; i++)
{
- maxLen = a[i].length;
+ if (a[i].length > maxLen)
+ {
+ maxLen = a[i].length;
+ }
+ rowData.push( [
+ o["dn"],
+ field,
+ a[i]
+ ] );
+ }
+ }
+ else // single-valued
+ {
+ // ... add its name and value to the table
+ // dataset
+ if (o[field].length > maxLen)
+ {
+ maxLen = o[field].length;
}
rowData.push( [
o["dn"],
field,
- a[i]
- ] );
- }
- }
- else // single-valued
- {
- // ... add its name and value to the table dataset
- if (o[field].length > maxLen)
- {
- maxLen = o[field].length;
+ o[field]
+ ] );
}
- rowData.push( [
- o["dn"],
- field,
- o[field]
- ] );
}
- }
- // Adjust the width of the value column based on maxLen
- table.setColumnWidth(2, maxLen * 7);
+ // Adjust the width of the value column based on
+ // maxLen
+ table.setColumnWidth(2, maxLen * 7);
- // Tell the table to use the new data
- tableModel.setData(rowData);
+ // Tell the table to use the new data
+ tableModel.setData(rowData);
+ }
+ }
+ else
+ {
+ alert("No rows returned.");
}
}
else