The branch, master has been updated
       via  e665fce web_server: Display trivial placeholder page if SWAT could 
not be found.
       via  7982f68 web_server: Fix initialization.
       via  04abf2c web_server: Avoid references to swat. Load samba.web_server 
instead.
       via  2f7d4a4 param: Load web service by default.
      from  93d9641 s4:dsdb_find_nc_root - fix it up to let the provisioning 
work correctly

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e665fce31c29f502dc6a21559c4766ab627fb35a
Author: Jelmer Vernooij <jel...@samba.org>
Date:   Mon Jan 17 00:43:04 2011 +0100

    web_server: Display trivial placeholder page if SWAT could not be found.
    
    Autobuild-User: Jelmer Vernooij <jel...@samba.org>
    Autobuild-Date: Mon Jan 17 01:27:10 CET 2011 on sn-devel-104

commit 7982f683ee4ae3bb693745c895b1b11586bf32d0
Author: Jelmer Vernooij <jel...@samba.org>
Date:   Mon Jan 17 00:30:49 2011 +0100

    web_server: Fix initialization.

commit 04abf2cc8dfda2a969cd2c1257d5d5a41979a0d2
Author: Jelmer Vernooij <jel...@samba.org>
Date:   Mon Jan 17 00:25:42 2011 +0100

    web_server: Avoid references to swat. Load samba.web_server instead.

commit 2f7d4a41904d0bcc54da3462f20a3a2f18f6fc40
Author: Jelmer Vernooij <jel...@samba.org>
Date:   Mon Jan 17 00:25:29 2011 +0100

    param: Load web service by default.

-----------------------------------------------------------------------

Summary of changes:
 source4/param/loadparm.c                           |    2 +-
 .../python/samba/web_server}/__init__.py           |   31 ++++++++++++++------
 source4/web_server/web_server.c                    |    9 ++++--
 source4/web_server/wsgi.c                          |   13 +++++---
 4 files changed, 37 insertions(+), 18 deletions(-)
 rename source4/{web_server/swat => 
scripting/python/samba/web_server}/__init__.py (66%)


Changeset truncated at 500 lines:

diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 531789e..8e487fc 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -2395,7 +2395,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX 
*mem_ctx)
        lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
 
        lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper 
srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup 
unixinfo browser eventlog6");
-       lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl 
ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
+       lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl 
ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate web");
        lpcfg_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
        /* the winbind method for domain controllers is for both RODC
           auth forwarding and for trusted domains */
diff --git a/source4/web_server/swat/__init__.py 
b/source4/scripting/python/samba/web_server/__init__.py
similarity index 66%
rename from source4/web_server/swat/__init__.py
rename to source4/scripting/python/samba/web_server/__init__.py
index ea28e94..da528f4 100644
--- a/source4/web_server/swat/__init__.py
+++ b/source4/scripting/python/samba/web_server/__init__.py
@@ -5,32 +5,45 @@
 # Copyright © Jelmer Vernooij <jel...@samba.org> 2008
 #
 # Implementation of SWAT that uses WSGI
-#   
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-#   
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-#   
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-def __call__(environ, start_response):
+
+
+def render_placeholder(environ, start_response):
     status = '200 OK'
     response_headers = [('Content-type','text/html')]
     start_response(status, response_headers)
-    yield '<table>\n'
 
-    for key, value in environ.items():
-        if isinstance(value, str):
-            yield '\t<tr><td><b>%s</b></td><td>%s</td></tr>\n' % (key, value)
+    yield "<!doctype html>\n"
+    yield "<html>\n"
+    yield "  <title>The Samba web service</title>\n"
+    yield "</html>\n"
+
+    yield "<body>\n"
+    yield "<p>Welcome to this Samba web server.</p>\n"
+    yield "<p>This page is a simple placeholder. You probably want to install "
+    yield "SWAT. More information can be found "
+    yield "<a href='http://wiki.samba.org/index.php/SWAT'>on the wiki</a>.</p>"
+    yield "</p>\n"
+    yield "</body>\n"
+    yield "</html>\n"
+
+
+__call__ = render_placeholder
 
-    yield '</table>\n'
 
 if __name__ == '__main__':
     from wsgiref import simple_server
diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c
index 8e81685..b2f6f5f 100644
--- a/source4/web_server/web_server.c
+++ b/source4/web_server/web_server.c
@@ -310,6 +310,8 @@ static void websrv_task_init(struct task_server *task)
        wdata = talloc_zero(task, struct web_server_data);
        if (wdata == NULL) goto failed;
 
+       task->private_data = wdata;
+
        if (lpcfg_interfaces(task->lp_ctx) && 
lpcfg_bind_interfaces_only(task->lp_ctx)) {
                int num_interfaces;
                int i;
@@ -326,7 +328,7 @@ static void websrv_task_init(struct task_server *task)
                                                     &web_stream_ops, 
                                                     "ipv4", address, 
                                                     &port, 
lpcfg_socket_options(task->lp_ctx),
-                                                    wdata);
+                                                    task);
                        if (!NT_STATUS_IS_OK(status)) goto failed;
                }
 
@@ -337,15 +339,16 @@ static void websrv_task_init(struct task_server *task)
                                             &web_stream_ops,
                                             "ipv4", 
lpcfg_socket_address(task->lp_ctx),
                                             &port, 
lpcfg_socket_options(task->lp_ctx),
-                                            wdata);
+                                            task);
                if (!NT_STATUS_IS_OK(status)) goto failed;
        }
-       
+
        wdata->tls_params = tls_initialise(wdata, task->lp_ctx);
        if (wdata->tls_params == NULL) goto failed;
 
        if (!wsgi_initialize(wdata)) goto failed;
 
+
        return;
 
 failed:
diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c
index 1c105d0..2f47af2 100644
--- a/source4/web_server/wsgi.c
+++ b/source4/web_server/wsgi.c
@@ -26,6 +26,7 @@
 #include "../lib/util/dlinklist.h"
 #include "lib/tls/tls.h"
 #include "lib/tsocket/tsocket.h"
+#include "scripting/python/modules.h"
 
 /* There's no Py_ssize_t in 2.4, apparently */
 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
@@ -380,10 +381,12 @@ static void wsgi_process_http_input(struct 
web_server_data *wdata,
 
 bool wsgi_initialize(struct web_server_data *wdata)
 {
-       PyObject *py_swat;
+       PyObject *py_web_server;
 
        Py_Initialize();
 
+       py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+
        if (PyType_Ready(&web_request_Type) < 0)
                return false;
 
@@ -394,11 +397,11 @@ bool wsgi_initialize(struct web_server_data *wdata)
                return false;
 
        wdata->http_process_input = wsgi_process_http_input;
-       py_swat = PyImport_Import(PyString_FromString("swat"));
-       if (py_swat == NULL) {
-               DEBUG(0, ("Unable to find SWAT\n"));
+       py_web_server = PyImport_ImportModule("samba.web_server");
+       if (py_web_server == NULL) {
+               DEBUG(0, ("Unable to find web server\n"));
                return false;
        }
-       wdata->private_data = py_swat;
+       wdata->private_data = py_web_server;
        return true;
 }


-- 
Samba Shared Repository

Reply via email to