svn commit: samba r19449 - in branches/SAMBA_4_0: source source/build/smb_build source/param source/script source/scripting/ejs source/web_server swat/apps/samba/utils

derrell at samba.org derrell at samba.org
Sun Oct 22 02:57:30 GMT 2006


Author: derrell
Date: 2006-10-22 02:57:28 +0000 (Sun, 22 Oct 2006)
New Revision: 19449

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19449

Log:
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

Added:
   branches/SAMBA_4_0/source/script/installjsonrpc.sh
Modified:
   branches/SAMBA_4_0/source/build/smb_build/makefile.pm
   branches/SAMBA_4_0/source/dynconfig.c
   branches/SAMBA_4_0/source/dynconfig.h
   branches/SAMBA_4_0/source/dynconfig.mk
   branches/SAMBA_4_0/source/main.mk
   branches/SAMBA_4_0/source/param/loadparm.c
   branches/SAMBA_4_0/source/script/installswat.sh
   branches/SAMBA_4_0/source/scripting/ejs/smbcalls.c
   branches/SAMBA_4_0/source/web_server/http.c
   branches/SAMBA_4_0/swat/apps/samba/utils/ldbbrowse.html


Changeset:
Modified: branches/SAMBA_4_0/source/build/smb_build/makefile.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/makefile.pm	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/build/smb_build/makefile.pm	2006-10-22 02:57:28 UTC (rev 19449)
@@ -86,6 +86,7 @@
 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}

Modified: branches/SAMBA_4_0/source/dynconfig.c
===================================================================
--- branches/SAMBA_4_0/source/dynconfig.c	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/dynconfig.c	2006-10-22 02:57:28 UTC (rev 19449)
@@ -80,6 +80,9 @@
 /** 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;
 

Modified: branches/SAMBA_4_0/source/dynconfig.h
===================================================================
--- branches/SAMBA_4_0/source/dynconfig.h	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/dynconfig.h	2006-10-22 02:57:28 UTC (rev 19449)
@@ -37,6 +37,7 @@
 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;

Modified: branches/SAMBA_4_0/source/dynconfig.mk
===================================================================
--- branches/SAMBA_4_0/source/dynconfig.mk	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/dynconfig.mk	2006-10-22 02:57:28 UTC (rev 19449)
@@ -8,7 +8,8 @@
 	 -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 @@
 	 -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)\"
 

Modified: branches/SAMBA_4_0/source/main.mk
===================================================================
--- branches/SAMBA_4_0/source/main.mk	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/main.mk	2006-10-22 02:57:28 UTC (rev 19449)
@@ -60,6 +60,7 @@
 	@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 @@
 
 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)

Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/param/loadparm.c	2006-10-22 02:57:28 UTC (rev 19449)
@@ -114,7 +114,7 @@
 	char *szWINS_URL;
 	char *szPrivateDir;
 	char **jsInclude;
-	char *jsonrpcBase;
+	char *jsonrpcServicesDir;
 	char **szPasswordServers;
 	char *szSocketOptions;
 	char *szRealm;
@@ -543,7 +543,7 @@
 	{"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 @@
 	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_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)

Added: branches/SAMBA_4_0/source/script/installjsonrpc.sh
===================================================================
--- branches/SAMBA_4_0/source/script/installjsonrpc.sh	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/script/installjsonrpc.sh	2006-10-22 02:57:28 UTC (rev 19449)
@@ -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
+

Modified: branches/SAMBA_4_0/source/script/installswat.sh
===================================================================
--- branches/SAMBA_4_0/source/script/installswat.sh	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/script/installswat.sh	2006-10-22 02:57:28 UTC (rev 19449)
@@ -34,16 +34,5 @@
 ======================================================================
 EOF
 
-cd $SRCDIR/.. || exit 1
-
-installdir `find services -name '*.esp'`
-
-cat << EOF
-======================================================================
-The JSON-RPC services have been installed. 
-======================================================================
-EOF
-
-
 exit 0
 

Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbcalls.c	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls.c	2006-10-22 02:57:28 UTC (rev 19449)
@@ -163,19 +163,19 @@
 
 /*
  * 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 @@
 		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;

Modified: branches/SAMBA_4_0/source/web_server/http.c
===================================================================
--- branches/SAMBA_4_0/source/web_server/http.c	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/source/web_server/http.c	2006-10-22 02:57:28 UTC (rev 19449)
@@ -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 @@
 /*
   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 @@
 		}
 	}
 
-	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 @@
 /*
   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 @@
 	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 @@
 	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 @@
 	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 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 @@
 	}
 
         /* 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 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 @@
 	.setHeader       = http_setHeader,
 	.redirect        = http_redirect,
 	.setResponseCode = http_setResponseCode,
-	.readFile        = http_readFile,
+	.readFile        = http_readFileFromSwatDir,
 	.mapToStorage    = http_mapToStorage,
 	.setCookie       = http_setCookie,
 	.createSession   = http_createSession,

Modified: branches/SAMBA_4_0/swat/apps/samba/utils/ldbbrowse.html
===================================================================
--- branches/SAMBA_4_0/swat/apps/samba/utils/ldbbrowse.html	2006-10-21 17:00:47 UTC (rev 19448)
+++ branches/SAMBA_4_0/swat/apps/samba/utils/ldbbrowse.html	2006-10-22 02:57:28 UTC (rev 19449)
@@ -248,66 +248,76 @@
                 // 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]
-                                              ] );
+                                                  o[field]
+                                                  ] );
                             }
                         }
-                        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,
-                                              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
             {



More information about the samba-cvs mailing list