summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-12-31 20:05:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:30:39 -0500
commit43470b5ec3d451aa75acf2cda40cf2dcc019efab (patch)
treeb5050af45bd3c56a33332b6cbb0a5e0ff69ab6b3
parent4024697a0b7b97acdc5c411ab9fe8c894c66752e (diff)
downloadsamba-43470b5ec3d451aa75acf2cda40cf2dcc019efab.tar.gz
samba-43470b5ec3d451aa75acf2cda40cf2dcc019efab.tar.bz2
samba-43470b5ec3d451aa75acf2cda40cf2dcc019efab.zip
r20444: WEB Application framework / SWAT.
We're now at the stage where the web application framework should build and install automatically. Derrell (This used to be commit 0201baef46c1701007e0a4cdd95edee287939318)
-rw-r--r--source4/build/smb_build/makefile.pm2
-rw-r--r--source4/dynconfig.c4
-rw-r--r--source4/dynconfig.h2
-rw-r--r--source4/dynconfig.mk2
-rw-r--r--source4/lib/appweb/ejs/config.h2
-rw-r--r--source4/main.mk8
-rw-r--r--source4/param/loadparm.c8
-rw-r--r--source4/script/installswat.sh38
-rw-r--r--source4/script/installwebapps.sh52
-rw-r--r--source4/scripting/ejs/smbcalls_config.c2
-rw-r--r--source4/web_server/http.c38
-rw-r--r--webapps/images/logo.pngbin0 -> 9329 bytes
-rw-r--r--webapps/login.esp59
-rw-r--r--webapps/scripting/common.js125
-rw-r--r--webapps/scripting/footer_columns.esp7
-rw-r--r--webapps/scripting/footer_desktop.esp6
-rw-r--r--webapps/scripting/footer_plain.esp7
-rw-r--r--webapps/scripting/forms.js112
-rw-r--r--webapps/scripting/header_columns.esp81
-rw-r--r--webapps/scripting/header_desktop.esp20
-rw-r--r--webapps/scripting/header_plain.esp25
-rw-r--r--webapps/scripting/preauth.esp49
-rw-r--r--webapps/style/columns.css73
-rw-r--r--webapps/style/common.css265
-rw-r--r--webapps/style/swat.css40
-rw-r--r--webapps/style/wide.css113
-rw-r--r--webapps/swat/Makefile6
27 files changed, 1071 insertions, 75 deletions
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index b52a08712a..e3853e8534 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -85,7 +85,7 @@ MODULESDIR = $self->{config}->{modulesdir}
INCLUDEDIR = $self->{config}->{includedir}
CONFIGDIR = $self->{config}->{sysconfdir}
DATADIR = $self->{config}->{datadir}
-SWATDIR = $self->{config}->{datadir}/swat
+WEBAPPSDIR = $self->{config}->{datadir}/webapps
SERVICESDIR = $self->{config}->{datadir}/services
JSDIR = $self->{config}->{datadir}/js
SETUPDIR = $self->{config}->{datadir}/setup
diff --git a/source4/dynconfig.c b/source4/dynconfig.c
index 4517a4f551..7a95cc59f7 100644
--- a/source4/dynconfig.c
+++ b/source4/dynconfig.c
@@ -74,8 +74,8 @@ _PUBLIC_ const char *dyn_PIDDIR = PIDDIR;
/** Private data directory; holds ldb files and the like */
_PUBLIC_ const char *dyn_PRIVATE_DIR = PRIVATE_DIR;
-/** SWAT data file (images, etc) directory */
-_PUBLIC_ const char *dyn_SWATDIR = SWATDIR;
+/** WEBAPPS directory */
+_PUBLIC_ const char *dyn_WEBAPPSDIR = WEBAPPSDIR;
/** JSON-RPC Services script directory */
_PUBLIC_ const char *dyn_SERVICESDIR = SERVICESDIR;
diff --git a/source4/dynconfig.h b/source4/dynconfig.h
index d3badc73e5..da1fe68467 100644
--- a/source4/dynconfig.h
+++ b/source4/dynconfig.h
@@ -35,7 +35,7 @@ extern const char *dyn_MODULESDIR;
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_WEBAPPSDIR;
extern const char *dyn_SERVICESDIR;
extern const char *dyn_JSDIR;
extern const char *dyn_SETUPDIR;
diff --git a/source4/dynconfig.mk b/source4/dynconfig.mk
index abbe5077a0..873ea5b45a 100644
--- a/source4/dynconfig.mk
+++ b/source4/dynconfig.mk
@@ -13,7 +13,7 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
-DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DDATADIR=\"$(DATADIR)\" \
-DLOGFILEBASE=\"$(LOGFILEBASE)\" \
-DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
- -DSWATDIR=\"$(SWATDIR)\" -DSERVICESDIR=\"$(SERVICESDIR)\" \
+ -DWEBAPPSDIR=\"$(WEBAPPSDIR)\" -DSERVICESDIR=\"$(SERVICESDIR)\" \
-DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
-DMODULESDIR=\"$(MODULESDIR)\" -DJSDIR=\"$(JSDIR)\" \
-DTORTUREDIR=\"$(TORTUREDIR)\" \
diff --git a/source4/lib/appweb/ejs/config.h b/source4/lib/appweb/ejs/config.h
index feec3c9e5b..8c06d28147 100644
--- a/source4/lib/appweb/ejs/config.h
+++ b/source4/lib/appweb/ejs/config.h
@@ -1,5 +1,5 @@
#define BLD_PRODUCT "Samba4"
-#define BLD_NAME "Samba4 SWAT"
+#define BLD_NAME "Samba4 WEB Applications"
#define BLD_VERSION "4"
#define BLD_NUMBER "1"
#define BLD_TYPE "DEBUG"
diff --git a/source4/main.mk b/source4/main.mk
index 2c15cf8912..e59c280f5e 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -59,7 +59,7 @@ showlayout:
@echo ' logfilebase: $(LOGFILEBASE)'
@echo ' setupdir: $(SETUPDIR)'
@echo ' jsdir: $(JSDIR)'
- @echo ' swatdir: $(SWATDIR)'
+ @echo ' webappsdir: $(WEBAPPSDIR)'
@echo ' servicesdir: $(SERVICESDIR)'
@echo ' mandir: $(MANDIR)'
@echo ' torturedir: $(TORTUREDIR)'
@@ -84,7 +84,7 @@ showflags:
# The permissions to give the executables
INSTALLPERMS = 0755
-install: showlayout installbin installdat installswat installmisc installlib \
+install: showlayout installbin installdat installwebapps installmisc installlib \
installheader installpc installplugins
# DESTDIR is used here to prevent packagers wasting their time
@@ -145,8 +145,8 @@ installheader: headers installdirs
installdat: installdirs
@$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
-installswat: installdirs
- @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
+installwebapps: installdirs
+ @$(SHELL) $(srcdir)/script/installwebapps.sh $(DESTDIR)$(WEBAPPSDIR) $(srcdir)
@$(SHELL) $(srcdir)/script/installjsonrpc.sh $(DESTDIR)$(SERVICESDIR) $(srcdir)
installman: manpages installdirs
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 5094a7f565..93d9d79ece 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -132,7 +132,7 @@ typedef struct
char *szWinbindSeparator;
char *szWinbinddSocketDirectory;
int bWinbindSealedPipes;
- char *swat_directory;
+ char *webapps_directory;
int tls_enabled;
char *tls_keyfile;
char *tls_certfile;
@@ -442,7 +442,7 @@ static struct parm_struct parm_table[] = {
{"tls cafile", P_STRING, P_GLOBAL, &Globals.tls_cafile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"tls crlfile", P_STRING, P_GLOBAL, &Globals.tls_crlfile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"tls dh params file", P_STRING, P_GLOBAL, &Globals.tls_dhpfile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"swat directory", P_STRING, P_GLOBAL, &Globals.swat_directory, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"web application directory", P_STRING, P_GLOBAL, &Globals.webapps_directory, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_DEVELOPER},
{"server max protocol", P_ENUM, P_GLOBAL, &Globals.srv_maxprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
{"server min protocol", P_ENUM, P_GLOBAL, &Globals.srv_minprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
@@ -694,7 +694,7 @@ static void init_globals(void)
do_parameter("krb5 port", "88", NULL);
do_parameter("kpasswd port", "464", NULL);
do_parameter("web port", "901", NULL);
- do_parameter("swat directory", dyn_SWATDIR, NULL);
+ do_parameter("web application directory", dyn_WEBAPPSDIR, NULL);
do_parameter("jsonrpc services directory", dyn_SERVICESDIR, NULL);
do_parameter("nt status support", "True", NULL);
@@ -821,7 +821,7 @@ _PUBLIC_ FN_GLOBAL_INTEGER(lp_krb5_port, &Globals.krb5_port)
_PUBLIC_ FN_GLOBAL_INTEGER(lp_kpasswd_port, &Globals.kpasswd_port)
_PUBLIC_ FN_GLOBAL_INTEGER(lp_web_port, &Globals.web_port)
_PUBLIC_ FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
-_PUBLIC_ FN_GLOBAL_STRING(lp_swat_directory, &Globals.swat_directory)
+_PUBLIC_ FN_GLOBAL_STRING(lp_webapps_directory, &Globals.webapps_directory)
_PUBLIC_ FN_GLOBAL_BOOL(lp_tls_enabled, &Globals.tls_enabled)
_PUBLIC_ FN_GLOBAL_STRING(lp_tls_keyfile, &Globals.tls_keyfile)
_PUBLIC_ FN_GLOBAL_STRING(lp_tls_certfile, &Globals.tls_certfile)
diff --git a/source4/script/installswat.sh b/source4/script/installswat.sh
deleted file mode 100644
index 549c11da35..0000000000
--- a/source4/script/installswat.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-SWATDIR=$1
-SRCDIR=$2
-
-echo Installing swat files in $SWATDIR
-
-cd $SRCDIR/../swat || exit 1
-
-mkdir -p $SWATDIR || exit 1
-
-installdir() {
- for f in $*; do
- dname=`dirname $f`
- echo "Installing $f in $dname"
- test -d $SWATDIR/$dname || mkdir -p $SWATDIR/$dname || exit 1
- cp $f $SWATDIR/$dname/ || exit 1
- chmod 0644 $SWATDIR/$f || exit 1
- done
-}
-
-installdir `find . -name '*.html'`
-installdir `find . -name '*.js'`
-installdir `find . -name '*.esp'`
-installdir `find . -name '*.css'`
-installdir `find . -name '*.png'`
-installdir `find . -name '*.ico'`
-installdir `find . -name '*.gif'`
-installdir `find . -name '*.ejs'`
-
-cat << EOF
-======================================================================
-The swat files have been installed.
-======================================================================
-EOF
-
-exit 0
-
diff --git a/source4/script/installwebapps.sh b/source4/script/installwebapps.sh
new file mode 100644
index 0000000000..c763d6b089
--- /dev/null
+++ b/source4/script/installwebapps.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+WEBAPPSDIR=$1
+SRCDIR=$2
+
+echo Installing web application files in $WEBAPPSDIR
+
+cd $SRCDIR/../webapps/swat || exit 1
+make build || exit 1
+
+mkdir -p $WEBAPPSDIR || exit 1
+
+installdir() {
+ for f in $*; do
+ dname=`dirname $f`
+ echo "Installing $f in $dname"
+ test -d $WEBAPPSDIR/$dname || mkdir -p $WEBAPPSDIR/$dname || exit 1
+ cp $f $WEBAPPSDIR/$dname/ || exit 1
+ chmod 0644 $WEBAPPSDIR/$f || exit 1
+ done
+}
+
+# install our web application
+cd build
+installdir `find . -type f -print`
+cd ..
+
+# install all .esp files (there are none in the webapp build dir)
+installdir `find . -name '*.esp'`
+
+# install .js and .esp files from the scripting dir
+cd ..
+installdir `find scripting -name '*.js'`
+installdir `find scripting -name '*.esp'`
+
+# install .css files from the style dir
+installdir `find style -name '*.css'`
+
+# install files from the images dir
+installdir `find images -type f -print`
+
+# install the login script, for authentication of static pages
+installdir `find . -name 'login.esp'`
+
+cat << EOF
+======================================================================
+The web application files have been installed.
+======================================================================
+EOF
+
+exit 0
+
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 5da0dd14f0..6ee9c8305b 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -67,7 +67,7 @@ static int ejs_lpCategories(MprVarHandle eid, int argc, char **argv)
/*
- allow access to loadparm variables from inside ejs scripts in swat
+ allow access to loadparm variables from inside ejs scripts in web apps
can be called in 4 ways:
diff --git a/source4/web_server/http.c b/source4/web_server/http.c
index 210151f10f..83bc38dbc0 100644
--- a/source4/web_server/http.c
+++ b/source4/web_server/http.c
@@ -33,10 +33,10 @@
#include "lib/tls/tls.h"
#include "scripting/ejs/smbcalls.h"
-#define SWAT_SESSION_KEY "SwatSessionId"
-#define HTTP_PREAUTH_URI "/scripting/preauth.esp"
-#define JSONRPC_REQUEST "/services"
-#define JSONRPC_SERVER "/request.esp"
+#define SAMBA_SESSION_KEY "SambaSessionId"
+#define HTTP_PREAUTH_URI "/scripting/preauth.esp"
+#define JSONRPC_REQUEST "/services"
+#define JSONRPC_SERVER "/request.esp"
/* state of the esp subsystem for a specific request */
struct esp_state {
@@ -126,7 +126,7 @@ static const char *http_local_path(struct websrv_context *web,
if (path == NULL) return NULL;
if (directory_exist(path)) {
- path = talloc_asprintf_append(path, "/index.esp");
+ path = talloc_asprintf_append(path, "/index.html");
}
return path;
}
@@ -170,12 +170,12 @@ failed:
return -1;
}
-static int http_readFileFromSwatDir(EspHandle handle,
- char **buf,
- int *len,
- const char *path)
+static int http_readFileFromWebappsDir(EspHandle handle,
+ char **buf,
+ int *len,
+ const char *path)
{
- return http_readFile(handle, buf, len, path, lp_swat_directory());
+ return http_readFile(handle, buf, len, path, lp_webapps_directory());
}
@@ -325,7 +325,7 @@ static void http_createSession(EspHandle handle, int timeout)
struct websrv_context *web = talloc_get_type(handle, struct websrv_context);
if (web->session) {
web->session->lifetime = timeout;
- http_setCookie(web, SWAT_SESSION_KEY, web->session->id,
+ http_setCookie(web, SAMBA_SESSION_KEY, web->session->id,
web->session->lifetime, "/", 0);
}
}
@@ -390,7 +390,7 @@ static void http_simple_request(struct websrv_context *web)
const char *path;
struct stat st;
- path = http_local_path(web, url, lp_swat_directory());
+ path = http_local_path(web, url, lp_webapps_directory());
if (path == NULL) goto invalid;
/* looks ok */
@@ -472,9 +472,9 @@ static void http_setup_arrays(struct esp_state *esp)
talloc_asprintf(esp, "%u", socket_address->port));
}
- SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory());
+ SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_webapps_directory());
SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->conn->socket)?"https":"http");
- SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SWAT");
+ SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SAMBA");
SETVAR(ESP_SERVER_OBJ, "GATEWAY_INTERFACE", "CGI/1.1");
SETVAR(ESP_SERVER_OBJ, "TLS_SUPPORT", tls_support(edata->tls_params)?"True":"False");
}
@@ -518,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, lp_swat_directory()) != 0) {
+ if (http_readFile(web, &buf, &size, url, lp_webapps_directory()) != 0) {
http_error_unix(web, url);
return;
}
@@ -622,7 +622,7 @@ static BOOL http_preauth(struct esp_state *esp)
{
const char *path = http_local_path(esp->web,
HTTP_PREAUTH_URI,
- lp_swat_directory());
+ lp_webapps_directory());
int i;
if (path == NULL) {
http_error(esp->web, 500, "Internal server error");
@@ -674,7 +674,7 @@ static const char *http_unescape(TALLOC_CTX *mem_ctx, const char *p)
*/
static void esp_putvar(struct esp_state *esp, const char *var, const char *value)
{
- if (strcasecmp(var, SWAT_SESSION_KEY) == 0) {
+ if (strcasecmp(var, SAMBA_SESSION_KEY) == 0) {
/* special case support for browsers without cookie
support */
esp->web->input.session_key = talloc_strdup(esp, value);
@@ -773,7 +773,7 @@ static int session_destructor(struct session_data *s)
*/
static void http_setup_session(struct esp_state *esp)
{
- const char *session_key = SWAT_SESSION_KEY;
+ const char *session_key = SAMBA_SESSION_KEY;
char *p;
const char *cookie = esp->web->input.cookie;
const char *key = NULL;
@@ -835,7 +835,7 @@ static const struct Esp esp_control = {
.setHeader = http_setHeader,
.redirect = http_redirect,
.setResponseCode = http_setResponseCode,
- .readFile = http_readFileFromSwatDir,
+ .readFile = http_readFileFromWebappsDir,
.mapToStorage = http_mapToStorage,
.setCookie = http_setCookie,
.createSession = http_createSession,
diff --git a/webapps/images/logo.png b/webapps/images/logo.png
new file mode 100644
index 0000000000..6df4ace659
--- /dev/null
+++ b/webapps/images/logo.png
Binary files differ
diff --git a/webapps/login.esp b/webapps/login.esp
new file mode 100644
index 0000000000..ffbeee8d5e
--- /dev/null
+++ b/webapps/login.esp
@@ -0,0 +1,59 @@
+<% page_header("plain", "Samba WEB Application Login", "");
+ libinclude("auth.js");
+ include("/scripting/forms.js");
+
+if (request['SESSION_EXPIRED'] == "True") {
+ write("<b>Your session has expired - please authenticate again<br /></b>\n");
+}
+
+var f = FormObj("login", 3, 1);
+f.element[0].label = "Username";
+f.element[0].value = form['Username'];
+f.element[1].label = "Password";
+f.element[1].value = form['Password'];
+f.element[1].type = "password";
+f.element[2].label = "Domain";
+f.element[2].type = "select";
+f.element[2].list = getDomainList();
+f.submit[0] = "Login";
+
+f.display();
+%>
+
+<%
+ if (request.REQUEST_METHOD == "POST") {
+ var creds = credentials_init();
+ creds.set_username(form.Username);
+ creds.set_password(form.Password);
+ creds.set_domain(form.Domain);
+ creds.set_workstation(request['REMOTE_HOST']);
+
+ auth = userAuth(creds, request['REMOTE_SOCKET_ADDRESS']);
+ if (auth == undefined) {
+ write("<b>Invalid login - please try again<br /></b>\n");
+ } else if (auth.result) {
+ session.AUTHENTICATED = true;
+ session.authinfo = new Object();
+
+ session.authinfo.username = auth.username;
+ session.authinfo.domain = auth.domain;
+ session.authinfo.credentials = creds;
+ session.authinfo.session_info = auth.session_info;
+
+ /* if the user was asking for the login page, then now
+ redirect them to the main page. Otherwise just
+ redirect them to the current page, which will now
+ show its true content */
+ if (request.REQUEST_URI == "/login.esp") {
+ redirect(session_uri("/"));
+ } else {
+ redirect(session_uri(request.REQUEST_URI));
+ }
+ } else if (auth.report == undefined) {
+ write("<b>Login failed - please try again<br /></b>\n");
+ } else {
+ write("<b>Login failed: " + auth.report + " - please try again<br /></b>\n");
+ }
+ }
+%>
+<% page_footer(); %>
diff --git a/webapps/scripting/common.js b/webapps/scripting/common.js
new file mode 100644
index 0000000000..523e6fed2f
--- /dev/null
+++ b/webapps/scripting/common.js
@@ -0,0 +1,125 @@
+/*
+ js functions and code common to static pages
+*/
+
+/* define some global variables for this request */
+global.page = new Object();
+
+/* fill in some defaults */
+global.page.title = "Samba Web Administration Tool";
+
+libinclude("base.js");
+
+/* to cope with browsers that don't support cookies we append the sessionid
+ to the URI */
+global.SESSIONURI = "";
+if (request['COOKIE_SUPPORT'] != "True") {
+ global.SESSIONURI="?SwatSessionId=" + request['SESSION_ID'];
+}
+
+/*
+ possibly adjust a local URI to have the session id appended
+ used for browsers that don't support cookies
+*/
+function session_uri(uri) {
+ return uri + global.SESSIONURI;
+}
+
+/*
+ like printf, but to the web page
+*/
+function writef()
+{
+ write(vsprintf(arguments));
+}
+
+/*
+ like writef with a <br>
+*/
+function writefln()
+{
+ write(vsprintf(arguments));
+ write("<br/>\n");
+}
+
+
+/* if the browser was too dumb to set the HOST header, then
+ set it now */
+if (headers['HOST'] == undefined) {
+ headers['HOST'] = server['SERVER_HOST'] + ":" + server['SERVER_PORT'];
+}
+
+/*
+ show the page header. page types include "plain" and "column"
+*/
+function page_header(pagetype, title, menu) {
+ global.page.pagetype = pagetype;
+ global.page.title = title;
+ global.page.menu = menu;
+ include("/scripting/header_" + pagetype + ".esp");
+}
+
+/*
+ show the page footer, getting the page type from page.pagetype
+ set in page_header()
+*/
+function page_footer() {
+ include("/scripting/footer_" + global.page.pagetype + ".esp");
+}
+
+
+/*
+ display a table element
+*/
+function table_element(i, o) {
+ write("<tr><td>" + i + "</td><td>");
+ if (typeof(o[i]) == "object") {
+ var j, first;
+ first = true;
+ for (j in o[i]) {
+ if (first == false) {
+ write("<br />");
+ }
+ write(o[i][j]);
+ first = false;
+ }
+ } else {
+ write(o[i]);
+ }
+ write("</td></tr>\n");
+}
+
+/*
+ display a ejs object as a table. The header is optional
+*/
+function simple_table(v) {
+ if (v.length == 0) {
+ return;
+ }
+ write("<table class=\"data\">\n");
+ var r;
+ for (r in v) {
+ table_element(r, v);
+ }
+ write("</table>\n");
+}
+
+/*
+ display an array of objects, with the header for each element from the given
+ attribute
+*/
+function multi_table(array, header) {
+ var i, n;
+ write("<table class=\"data\">\n");
+ for (i=0;i<array.length;i++) {
+ var r, v = array[i];
+ write('<tr><th colspan="2">' + v[header] + "</th></tr>\n");
+ for (r in v) {
+ if (r != header) {
+ table_element(r, v);
+ }
+ }
+ }
+ write("</table>\n");
+}
+
diff --git a/webapps/scripting/footer_columns.esp b/webapps/scripting/footer_columns.esp
new file mode 100644
index 0000000000..7b5baaf0c8
--- /dev/null
+++ b/webapps/scripting/footer_columns.esp
@@ -0,0 +1,7 @@
+<%
+ /* footer for columns page type */
+%>
+</div>
+</div>
+</body>
+</html>
diff --git a/webapps/scripting/footer_desktop.esp b/webapps/scripting/footer_desktop.esp
new file mode 100644
index 0000000000..5e563dab88
--- /dev/null
+++ b/webapps/scripting/footer_desktop.esp
@@ -0,0 +1,6 @@
+<%
+ /* footer for desktop page type */
+%>
+
+</body>
+</html>
diff --git a/webapps/scripting/footer_plain.esp b/webapps/scripting/footer_plain.esp
new file mode 100644
index 0000000000..31ef8dd4ee
--- /dev/null
+++ b/webapps/scripting/footer_plain.esp
@@ -0,0 +1,7 @@
+<%
+ /* footer for plain page type */
+%>
+</div>
+</div>
+</body>
+</html>
diff --git a/webapps/scripting/forms.js b/webapps/scripting/forms.js
new file mode 100644
index 0000000000..2de9e34462
--- /dev/null
+++ b/webapps/scripting/forms.js
@@ -0,0 +1,112 @@
+/*
+ js functions for forms
+*/
+
+
+/*
+ display a simple form from a ejs Form object
+ caller should fill in
+ f.name = form name
+ f.action = action to be taken on submit (optional, defaults to current page)
+ f.class = css class (optional, defaults to 'form')
+ f.submit = an array of submit labels
+ f.add(name, label, [type], [value]) =
+ Add another element
+ f.element[i].label = element label
+ f.element[i].name = element name (defaults to label)
+ f.element[i].type = element type (defaults to text)
+ f.element[i].value = current value (optional, defaults to "")
+ */
+function form_display() {
+ var f = this;
+ var i, size = 20;
+ write('<form name="' + f.name +
+ '" method="post" action="' + f.action +
+ '" class="' + f.class + '">\n');
+ if (f.element.length > 0) {
+ write("<table>\n");
+ }
+ for (i in f.element) {
+ var e = f.element[i];
+ if (e.name == undefined) {
+ e.name = e.label;
+ }
+ if (e.value == undefined) {
+ e.value = "";
+ }
+ if (strlen(e.value) > size) {
+ size = strlen(e.value) + 4;
+ }
+ }
+ for (i in f.element) {
+ var e = f.element[i];
+ write("<tr>");
+ write("<td>" + e.label + "</td>");
+ if (e.type == "select") {
+ write('<td><select name="' + e.name + '">\n');
+ for (s in e.list) {
+ if (e.value == e.list[s]) {
+ write('<option selected=selected>' + e.list[s] + '</option>\n');
+ } else {
+ write('<option>' + e.list[s] + '</option>\n');
+ }
+ }
+ write('</select></td>\n');
+ } else {
+ var sizestr = "";
+ if (e.type == "text" || e.type == "password") {
+ sizestr = sprintf('size="%d"', size);
+ }
+ writef('<td><input name="%s" type="%s" value="%s" %s /></td>\n',
+ e.name, e.type, e.value, sizestr);
+ }
+ write("</tr>");
+ }
+ if (f.element.length > 0) {
+ write("</table>\n");
+ }
+ for (i in f.submit) {
+ write('<input name="submit" type="submit" value="' + f.submit[i] + '" />\n');
+ }
+ write("</form>\n");
+}
+
+function __addMethod(name, label)
+{
+ var f = this;
+ var i = f.element.length;
+ f.element[i] = new Object();
+ f.element[i].name = name;
+ f.element[i].label = label;
+ f.element[i].type = "text";
+ f.element[i].value = "";
+ if (arguments.length > 2) {
+ f.element[i].type = arguments[2];
+ }
+ if (arguments.length > 3) {
+ f.element[i].value = arguments[3];
+ }
+}
+
+/*
+ create a Form object with the defaults filled in, ready for display()
+ */
+function FormObj(name, num_elements, num_submits)
+{
+ var f = new Object();
+ f.name = name;
+ f.element = new Array(num_elements);
+ f.submit = new Array(num_submits);
+ f.action = session_uri(request.REQUEST_URI);
+ f.class = "defaultform";
+ f.add = __addMethod;
+ for (i in f.element) {
+ f.element[i] = new Object();
+ f.element[i].type = "text";
+ f.element[i].value = "";
+ }
+ f.display = form_display;
+
+ return f;
+}
+
diff --git a/webapps/scripting/header_columns.esp b/webapps/scripting/header_columns.esp
new file mode 100644
index 0000000000..a8ffed984e
--- /dev/null
+++ b/webapps/scripting/header_columns.esp
@@ -0,0 +1,81 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+ <title>@@global.page.title</title>
+
+<link rel="stylesheet" href="/style/common.css" type="text/css" media="all" />
+<link rel="stylesheet" href="/style/columns.css" type="text/css" media="all" />
+<link rel="stylesheet" href="/style/swat.css" type="text/css" media="all" />
+
+<!--[if gte IE 5.5]>
+ <style type="text/css">
+ /*<![CDATA[*/
+ .logo_hack {
+filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/logo.png',sizingMethod='scale');
+ }
+ /*]]>*/
+ </style>
+<![endif]-->
+
+<!--[if lte IE 5]>
+ <style type="text/css">
+ /*<![CDATA[*/
+ .logo_hack {
+ background-image:url(/images/logo.gif);
+ background-position:center;
+ background-repeat:no-repeat;
+ top:23.5px;
+ left:-10px;
+ }
+ /*]]>*/
+ </style>
+<![endif]-->
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv="Content-Language" content="en-us" />
+
+</head>
+
+
+<body>
+
+<div id="banner">
+ <div class="stripe"></div>
+ <div class="logout">
+ <b>logged in as @@session.authinfo.username</b>
+ <form method="post" action="/logout.esp@@global.SESSIONURI">
+ <input type="submit" value="Logout" />
+ </form>
+ </div>
+</div>
+
+<div id="logo">
+ <div class="logo_hack"><a href="/@@global.SESSIONURI"><img src="/images/linkpad.gif" alt="SWAT" /></a></div>
+</div>
+
+<div class="slogan">
+ <h4>Samba Web Administration Tool</h4>
+</div>
+
+<div id="nav">
+ <%
+ include("/menu.js");
+ if (form['menu']) {
+ global.page.menu = form['menu'];
+ }
+ swat_menus[global.page.menu].display();
+ if (global.page.menu != "main") {
+ write('<a href="/">Main Menu</a>');
+ }
+ %>
+</div>
+
+<div id="links">
+ <% swat_menus.docs.display(); %>
+</div>
+
+
+<div id="content">
+ <div id="middle" class="center">
diff --git a/webapps/scripting/header_desktop.esp b/webapps/scripting/header_desktop.esp
new file mode 100644
index 0000000000..cf8268f535
--- /dev/null
+++ b/webapps/scripting/header_desktop.esp
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv="Content-Language" content="en-us" />
+
+ <title>@@global.page.title</title>
+
+<style type="text/css" media="screen">
+body {
+ background-color:#3A6EA5;
+}
+</style>
+
+</head>
+
+<body>
+
diff --git a/webapps/scripting/header_plain.esp b/webapps/scripting/header_plain.esp
new file mode 100644
index 0000000000..ae11b6fc50
--- /dev/null
+++ b/webapps/scripting/header_plain.esp
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+ <title>@@global.page.title</title>
+
+<link rel="stylesheet" href="/style/common.css" type="text/css" media="all" />
+<link rel="stylesheet" href="/style/columns.css" type="text/css" media="all" />
+<link rel="stylesheet" href="/style/swat.css" type="text/css" media="all" />
+</head>
+
+
+<body>
+
+<div id="banner">
+ <div class="stripe"></div>
+</div>
+
+<div class="slogan">
+ <h4>Samba Web Administration Tool</h4>
+</div>
+
+<div id="content">
+ <div class="center">
diff --git a/webapps/scripting/preauth.esp b/webapps/scripting/preauth.esp
new file mode 100644
index 0000000000..84534cacef
--- /dev/null
+++ b/webapps/scripting/preauth.esp
@@ -0,0 +1,49 @@
+<%
+include("/scripting/common.js");
+
+/*
+ check if a uri is one of the 'always allowed' pages, even when not logged in
+ This allows the login page to use the same style sheets and images
+*/
+function always_allowed(uri) {
+ var str = string_init();
+
+ /* allow the primary web application to do its own authentication */
+ var s = str.split('/', uri);
+ if (s[0] == "" && (s.length == 1 || /* no path provided */
+ s[1] == 'index.html' ||
+ s[1] == "script" ||
+ s[1] == "resource")) {
+ return true;
+ }
+
+ var s = str.split('.', uri);
+ if (s.length < 2) {
+ return false;
+ }
+
+ var ext = s[s.length-1];
+ var allowed = new Array("ico", "gif", "png","css", "js");
+ for (i in allowed) {
+ if (allowed[i] == ext) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+/* this script is called on every web request. If it produces any
+ output at all then that output is returned and the requested page
+ is not given or processed.
+*/
+if (server['SERVER_PROTOCOL'] == "http" &&
+ server['TLS_SUPPORT'] == "True") {
+ write("redirect to https");
+ redirect("https://" + headers['HOST'] + request['REQUEST_URI']);
+} else if (always_allowed(request['REQUEST_URI']) != true &&
+ session['AUTHENTICATED'] == undefined) {
+ /* present the login page */
+ include("/login.esp");
+}
+%>
diff --git a/webapps/style/columns.css b/webapps/style/columns.css
new file mode 100644
index 0000000000..e78da9b3d7
--- /dev/null
+++ b/webapps/style/columns.css
@@ -0,0 +1,73 @@
+/*
+ columns.css
+ Copyright (C) 2004-2005 Deryck Hodge <deryck@samba.org>
+
+ Creates a puesdo-three-column view.
+
+ You may freely use and modify the styles here, but if you
+ intend to recreate the samba.org look exactly, please ask
+ permission first.
+*/
+
+
+/* Middle content column
+***********************************************************/
+#content {
+ position:absolute;
+ top:100px;
+ margin:0 20% 0 175px;
+ padding-top:30px;
+ padding-left:35px;
+ padding-bottom:50px;
+ padding-right:15px;
+ background-color:#FFF;
+ border-left:1px solid #FFFF64;
+ border-right:1px solid #FFFF64;
+}
+* html #content {
+ width:51%;
+ margin-right:0;
+}
+#content ul {
+ list-style-type:none;
+}
+
+
+/* Misc
+************************************************************/
+.headline {
+ margin-left:20px;
+ font-style:italic;
+}
+.plugs {
+ font-style:italic;
+ text-align:center;
+ border-top:2px groove #3878CD;
+ border-bottom:2px groove #3878CD;
+ padding:10px;
+ margin-top:100px;
+}
+.plugs p {
+ padding:30px;
+}
+.plugs img {
+ float:left;
+}
+.request {
+ margin-top:50px;
+ font-style:italic;
+ font-size:small;
+}
+#noswp img {
+ border:1px solid #3868CD;
+ width:370px;
+ height:90px;
+}
+#noswp a:hover {
+ background-color:transparent;
+}
+#noswp {
+ width:auto;
+ text-align:center;
+ margin:10px 0 25px 0;
+}
diff --git a/webapps/style/common.css b/webapps/style/common.css
new file mode 100644
index 0000000000..614beaaa8e
--- /dev/null
+++ b/webapps/style/common.css
@@ -0,0 +1,265 @@
+/*
+ common.css
+ Copyright (C) 2004-2005 Deryck Hodge <deryck@samba.org>
+
+ Basic styles common to all of samba.org, including VirtualHosts
+ bugzilla.samba.org, build.samba.org, and news.samba.org.
+
+ You may freely use and modify the styles here, but if you
+ intend to recreate the samba.org look exactly, please ask
+ permission first.
+*/
+
+
+/* Base elements
+***********************************************************/
+body {
+ margin:0;
+ padding:0;
+ background-color:#E5E9F5;
+ font-family:Lucidasans, Helvetica, Verdana, sans-serif;
+ font-size:medium;
+ color:#000;
+}
+body#news {
+ background:none;
+ background-color:#FFF;
+}
+blockquote {
+ margin:35px;
+ padding:15px;
+ border-left:2px groove #CCC;
+ border-top:2px groove #CCC;
+}
+img {
+ border:0;
+}
+
+
+
+/* Headings
+***********************************************************/
+h1 {
+ font-size:x-large;
+}
+h2 {
+ text-align:left;
+ color:#FFFF64;
+ font-size:large;
+ background-color:#3878CD;
+ margin-top:60px;
+ margin-bottom:15px;
+ padding:2px;
+ padding-left:5px;
+}
+h3 {
+ font-size:medium;
+}
+h5 {
+ font-size:small;
+ text-align:right;
+ display:inline;
+}
+* html h5 {
+ padding-right:4px;
+}
+h6 {
+ font-size:small;
+ text-align:right;
+ text-align:right;
+}
+h6 a {
+ margin-right:3px;
+}
+
+
+/* Lists
+***********************************************************/
+ol li {
+ margin-bottom:12px;
+}
+
+
+/* Tables
+***********************************************************/
+table.real thead {
+ background-color: #E5E9F5;
+}
+table.real th,
+table.real td {
+ border: 1px solid #3878CD;
+ padding: 2px;
+}
+table.real {
+ border: 2px solid #3878CD;
+ background-color: #F5F8FF;
+}
+a:link:hover {
+ color:#CC0033;
+ background-color:#FFFF64;
+}
+
+
+/* Header
+***********************************************************/
+#banner {
+ position:absolute;
+ top:0;
+ left:0;
+ height:95px;
+ width:100%;
+ padding-top:4px;
+ z-index:1;
+}
+.srch {
+ text-align:right;
+ margin:0 5px 0 0;
+}
+.srch form {
+ display:inline;
+}
+
+
+/* Slogan ("Opening windows to a wider world")
+***********************************************************/
+.slogan {
+ position:absolute;
+ left:187px;
+ z-index:1;
+}
+html>body .slogan { /**** Opera needs its own rule *********/
+ top:100px;
+}
+:root .slogan { /**** Undo the Opera rule for all other browsers ****/
+ top:80px;
+}
+* html .slogan { /** Then, give IE 5/6 its own rule ****** */
+ top:100px;
+}
+
+
+/* Logo (with hacks for PNG transparency across browsers)
+***********************************************************/
+#logo>.logo_hack {
+ background-image:url(/images/logo.png);
+ background-position:center;
+ background-repeat:no-repeat;
+}
+.logo_hack {
+ position:absolute;
+ top:25px;
+ left:0;
+ width:250px;
+ height:119px;
+ padding:0;
+ margin:0;
+ z-index:1;
+}
+.logo_hack a:hover {
+ background:transparent;
+}
+
+
+/* Nav menu
+***********************************************************/
+#nav {
+ position:absolute;
+ top:152px;
+ left:20px;
+ width:180px;
+ background-color:#F5F8FF;
+ border:2px groove #3878CD;
+ padding:0;
+ padding-bottom:5px;
+ margin:0;
+ z-index:1;
+}
+#nav ul {
+ list-style-type:none;
+ text-align:center;
+ padding:0;
+ margin:0;
+}
+#nav a,
+#nav a:link,
+#nav a:visited {
+ display:block;
+ height:20px;
+ font-size:small;
+ color:#2B5C9F;
+}
+#nav a:hover {
+ color:#FFF;
+ background-color:#3878CD;
+}
+#nav a:active {
+ color:#FFFF64;
+ background-color:#3878CD;
+ font-size:14px;
+}
+#nav img {
+ padding:0;
+ margin:0;
+ width:180px;
+ height:30px;
+}
+
+
+/* links menu
+***********************************************************/
+#links {
+ position:absolute;
+ top:152px;
+ left:81%;
+ width:180px;
+ padding:0;
+ width:18%;
+ background-color:#F5F8FF;
+ border:2px groove #3878CD;
+ padding:0;
+ padding-bottom:5px;
+ margin:0;
+ z-index:1;
+}
+#links ul {
+ list-style-type:none;
+ text-align:center;
+ padding:0;
+ margin:0;
+}
+#links a,
+#links a:link,
+#links a:visited {
+ display:block;
+ height:20px;
+ font-size:small;
+ color:#2B5C9F;
+}
+#links a:hover {
+ color:#FFF;
+ background-color:#3878CD;
+}
+#links a:active {
+ color:#FFFF64;
+ background-color:#3878CD;
+ font-size:14px;
+}
+#links img {
+ padding:0;
+ margin:0;
+ width:180px;
+ height:30px;
+}
+
+
+/* Text and alignment formats
+***********************************************************/
+.punch {
+ font-weight:bold;
+}
+.tilt {
+ font-style:italic;
+}
+.colophon {
+ margin-left:20px;
+}
diff --git a/webapps/style/swat.css b/webapps/style/swat.css
new file mode 100644
index 0000000000..c41e4eaf10
--- /dev/null
+++ b/webapps/style/swat.css
@@ -0,0 +1,40 @@
+/*
+ swat.css
+
+ Styles added to the samba.org stylesheets
+ specifically for SWAT.
+*/
+
+
+/* Forms
+***********************************************************/
+.logout {
+ text-align:right;
+}
+.logout form {
+ display:inline;
+}
+
+
+/* Tables
+***********************************************************/
+table.data {
+ border: 2px;
+}
+table.data th {
+ margin-top:20px;
+ text-align:left;
+ background-color: #F5C915;
+}
+table.data tr {
+ background-color: #E5C995;
+ text-align:left;
+}
+
+/* Temp fix for content sections that don't span the window.
+ This is not cross-browser and won't be the final way I handle
+ this, but I can't stand looking at small boxes while I work. :-) */
+#content {
+ min-width:55%;
+ min-height:800px;
+}
diff --git a/webapps/style/wide.css b/webapps/style/wide.css
new file mode 100644
index 0000000000..0107b33698
--- /dev/null
+++ b/webapps/style/wide.css
@@ -0,0 +1,113 @@
+/*
+ wide.css
+ Copyright (C) 2004-2005 Deryck Hodge <deryck@samba.org>
+
+ An alternate two-column "wide" style for those pages
+ with lots and lots of text (download, devel, etc.)
+
+ You may freely use and modify the styles here, but if you
+ intend to recreate the samba.org look exactly, please ask
+ permission first.
+*/
+
+
+/* Primary content section
+***********************************************************/
+#content {
+ position:absolute;
+ top:100px;
+ clear:left;
+ margin:0 1% 0 175px;
+ padding-top:30px;
+ padding-left:35px;
+ padding-bottom:50px;
+ padding-right:15px;
+ background-color:#FFF;
+ border-left:1px solid #FFFF64;
+ border-right:1px solid #FFFF64;
+}
+* html #content {
+ width:70%;
+}
+#content h4 {
+ font-weight:bold;
+ margin:50px 10px 15px 0;
+}
+pre {
+ margin:15px 0 30px 5px;
+}
+
+
+/* Team section
+***********************************************************/
+.teampic {
+ text-align:center;
+}
+.teampic img {
+ width:431px;
+ height:300px;
+}
+
+
+/* Release history/Release notes
+***********************************************************/
+.notes {
+ position:absolute;
+ top:265px;
+ left:0;
+}
+.notes h6 {
+ text-align:left;
+ margin:10px 5px;
+}
+.notes ul {
+ list-style-type:none;
+ text-align:left;
+ padding-left:12px;
+ margin:0 0 0 10px;
+ font-size:10px;
+}
+.intro {
+ margin-top:30px;
+}
+.headline {
+ margin-left:20px;
+ font-style:italic;
+}
+.latest ul {
+ list-style-type:none;
+ margin-left:40px;
+}
+
+
+/* Support providers pages
+***********************************************************/
+#countries {
+ float:left;
+ margin:240px 0 0 5px;
+ padding:0;
+ background-color:#E5E9F5;
+}
+#countries ul {
+ list-style-type:none;
+}
+#countries a {
+ font-size:small;
+}
+#countries h4 {
+ margin-top:10px;
+ margin-left:1px;
+ font-size:small;
+}
+.disclaimer {
+ margin:30px;
+ font-style:italic;
+}
+.info {
+ margin:75px 15px 15px 15px;
+ padding:10px;
+ font-size:small;
+ border-top:1px dotted #3878CD;
+ border-bottom:1px dotted #3878CD;
+}
+
diff --git a/webapps/swat/Makefile b/webapps/swat/Makefile
index aa17420c73..bf8af850ff 100644
--- a/webapps/swat/Makefile
+++ b/webapps/swat/Makefile
@@ -227,16 +227,16 @@ fix-build-rights:
info-build:
@echo "****************************************************************************"
- @echo " GENERATING SWAT BUILD"
+ @echo " GENERATING SWAT WEB APPLICATION BUILD"
@echo "****************************************************************************"
info-source:
@echo "****************************************************************************"
- @echo " GENERATING SWAT SOURCE"
+ @echo " GENERATING SWAT WEB APPLICATION SOURCE"
@echo "****************************************************************************"
###################################################################################
-# INSTALL TARGETS
+# INSTALL TARGETS (for developer use only)
###################################################################################
install: