r19449: ldbbrowse: installation hopefully works now. "Developer" installations
authorDerrell Lipman <derrell@samba.org>
Sun, 22 Oct 2006 02:57:28 +0000 (02:57 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:21:33 +0000 (14:21 -0500)
('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

source/build/smb_build/makefile.pm
source/dynconfig.c
source/dynconfig.h
source/dynconfig.mk
source/main.mk
source/param/loadparm.c
source/script/installjsonrpc.sh [new file with mode: 0644]
source/script/installswat.sh
source/scripting/ejs/smbcalls.c
source/web_server/http.c
swat/apps/samba/utils/ldbbrowse.html

index ead5592968d2a0503197a75d38f2fd2b5988204e..780ba99f0398741faaf3bc9cfa48d19fa31fc1d1 100644 (file)
@@ -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}
index 5b1074382cfc691ac5ec78a7e6ce6937bfa48afe..34a8cbec9928076619213ede5229d0b73f0ae226 100644 (file)
@@ -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;
 
index 312283c5fb05af1bbb8cc0e706ae3ab7c3cf4b45..c0854b99512cde6aee3bc0dd6c10c2d25f5b2cff 100644 (file)
@@ -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;
index 76479af0fa7cdabfb87a00793de502f985a37510..ed901a838daa5ded371fe86b1cfe870cdc3f3e22 100644 (file)
@@ -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)\"
 
index 0edf57859fa9d8e369e73f4b4481fde471f83760..378152c40f06eb9b8b9f24e6111de84c2795c0ca 100644 (file)
@@ -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)
index 1e5df4fcbe375666bdca1b00f9fbec3e7fcb636d..c781a00ae5c6c31be0454d2b8aac3a7f2d231096 100644 (file)
@@ -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/source/script/installjsonrpc.sh b/source/script/installjsonrpc.sh
new file mode 100644 (file)
index 0000000..b91f6bf
--- /dev/null
@@ -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
+
index 72dfc2f456325c97713958e23b0cad27030c34aa..549c11da350b3870dc70b47b713608a7e12c9526 100644 (file)
@@ -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
 
index 62a956bb96e301e0d25fc2119925418a501ea44f..1aee4cd9e2381ed9bfadab5f7485637a6ecc9d2b 100644 (file)
@@ -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;
index 4aef4a1dc881ada2f265c8e38808d192d71d8897..210151f10f5ec8c1e63f215625ef3a757bd943e3 100644 (file)
@@ -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,
index 81b74c44d2b71c62743286d01d3d3b2b54f4486d..1e6f21ee1163c276a5153a137cfbae8f44832797 100644 (file)
@@ -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