summaryrefslogtreecommitdiffstats
path: root/source/web_server
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-10-22 02:57:28 +0000
committerDerrell Lipman <derrell@samba.org>2006-10-22 02:57:28 +0000
commit7868f4f054f5baefe3c1428fb8e384215a4c5568 (patch)
tree53b708cfcf78c3efd21415e8cbd4f412083220dc /source/web_server
parent9a2e5dd63e4ecf1abcbcbe26ec82954d0451aca5 (diff)
downloadsamba-7868f4f054f5baefe3c1428fb8e384215a4c5568.tar.gz
samba-7868f4f054f5baefe3c1428fb8e384215a4c5568.tar.xz
samba-7868f4f054f5baefe3c1428fb8e384215a4c5568.zip
r19449: 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
Diffstat (limited to 'source/web_server')
-rw-r--r--source/web_server/http.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/source/web_server/http.c b/source/web_server/http.c
index 4aef4a1dc88..210151f10f5 100644
--- a/source/web_server/http.c
+++ b/source/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,