Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/source4/web_server
Files:
1 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/web_server/web_server.c

    r414 r740  
    2222
    2323#include "includes.h"
    24 #include "smbd/service_task.h"
    25 #include "smbd/service_stream.h"
    26 #include "smbd/service.h"
    2724#include "web_server/web_server.h"
     25#include "../lib/util/dlinklist.h"
     26#include "lib/tls/tls.h"
    2827#include "lib/events/events.h"
    29 #include "system/filesys.h"
    30 #include "system/network.h"
    3128#include "lib/socket/netif.h"
    32 #include "lib/tls/tls.h"
    33 #include "../lib/util/dlinklist.h"
    3429#include "param/param.h"
    3530
     
    301296{
    302297        NTSTATUS status;
    303         uint16_t port = lp_web_port(task->lp_ctx);
     298        uint16_t port = lpcfg_web_port(task->lp_ctx);
    304299        const struct model_ops *model_ops;
    305300        struct web_server_data *wdata;
     
    308303
    309304        /* run the web server as a single process */
    310         model_ops = process_model_startup(task->event_ctx, "single");
     305        model_ops = process_model_startup("single");
    311306        if (!model_ops) goto failed;
    312307
    313         if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
     308        /* startup the Python processor - unfortunately we can't do this
     309           per connection as that wouldn't allow for session variables */
     310        wdata = talloc_zero(task, struct web_server_data);
     311        if (wdata == NULL) goto failed;
     312
     313        task->private_data = wdata;
     314
     315        if (lpcfg_interfaces(task->lp_ctx) && lpcfg_bind_interfaces_only(task->lp_ctx)) {
    314316                int num_interfaces;
    315317                int i;
    316318                struct interface *ifaces;
    317319
    318                 load_interfaces(NULL, lp_interfaces(task->lp_ctx), &ifaces);
     320                load_interfaces(NULL, lpcfg_interfaces(task->lp_ctx), &ifaces);
    319321
    320322                num_interfaces = iface_count(ifaces);
    321323                for(i = 0; i < num_interfaces; i++) {
    322324                        const char *address = iface_n_ip(ifaces, i);
    323                         status = stream_setup_socket(task->event_ctx,
    324                                                      task->lp_ctx, model_ops,
     325                        status = stream_setup_socket(task,
     326                                                     task->event_ctx,
     327                                                     task->lp_ctx, model_ops,
    325328                                                     &web_stream_ops,
    326329                                                     "ipv4", address,
    327                                                      &port, lp_socket_options(task->lp_ctx),
     330                                                     &port, lpcfg_socket_options(task->lp_ctx),
    328331                                                     task);
    329332                        if (!NT_STATUS_IS_OK(status)) goto failed;
     
    332335                talloc_free(ifaces);
    333336        } else {
    334                 status = stream_setup_socket(task->event_ctx, task->lp_ctx,
    335                                              model_ops, &web_stream_ops,
    336                                              "ipv4", lp_socket_address(task->lp_ctx),
    337                                              &port, lp_socket_options(task->lp_ctx), task);
     337                status = stream_setup_socket(task, task->event_ctx,
     338                                             task->lp_ctx, model_ops,
     339                                             &web_stream_ops,
     340                                             "ipv4", lpcfg_socket_address(task->lp_ctx),
     341                                             &port, lpcfg_socket_options(task->lp_ctx),
     342                                             task);
    338343                if (!NT_STATUS_IS_OK(status)) goto failed;
    339344        }
    340345
    341         /* startup the esp processor - unfortunately we can't do this
    342            per connection as that wouldn't allow for session variables */
    343         wdata = talloc_zero(task, struct web_server_data);
    344         if (wdata == NULL)goto failed;
    345 
    346         task->private_data = wdata;
    347        
    348346        wdata->tls_params = tls_initialise(wdata, task->lp_ctx);
    349347        if (wdata->tls_params == NULL) goto failed;
     
    351349        if (!wsgi_initialize(wdata)) goto failed;
    352350
     351
    353352        return;
    354353
  • vendor/current/source4/web_server/web_server.h

    r414 r740  
    1717   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1818*/
     19
     20#ifndef __WEB_SERVER_H__
     21#define __WEB_SERVER_H__
    1922
    2023#include "smbd/process_model.h"
     
    6164};
    6265
     66bool wsgi_initialize(struct web_server_data *wdata);
     67void http_error(struct websrv_context *web, const char *status, const char *info);
     68void websrv_output_headers(struct websrv_context *web, const char *status, struct http_header *headers);
     69void websrv_output(struct websrv_context *web, void *data, size_t length);
     70NTSTATUS http_parse_header(struct websrv_context *web, const char *line);
    6371
    64 #include "web_server/proto.h"
    65 
     72#endif /* __WEB_SERVER_H__ */
  • vendor/current/source4/web_server/wsgi.c

    r414 r740  
    66   Implementation of the WSGI interface described in PEP0333
    77   (http://www.python.org/dev/peps/pep-0333)
    8    
     8
    99   This program is free software; you can redistribute it and/or modify
    1010   it under the terms of the GNU General Public License as published by
    1111   the Free Software Foundation; either version 3 of the License, or
    1212   (at your option) any later version.
    13    
     13
    1414   This program is distributed in the hope that it will be useful,
    1515   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717   GNU General Public License for more details.
    18    
     18
    1919   You should have received a copy of the GNU General Public License
    2020   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2121*/
    2222
     23#include <Python.h>
    2324#include "includes.h"
    2425#include "web_server/web_server.h"
    2526#include "../lib/util/dlinklist.h"
    26 #include "../lib/util/data_blob.h"
    2727#include "lib/tls/tls.h"
    28 #include <Python.h>
    29 
    30 #ifndef Py_RETURN_NONE
    31 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
     28#include "lib/tsocket/tsocket.h"
     29#include "scripting/python/modules.h"
     30
     31/* There's no Py_ssize_t in 2.4, apparently */
     32#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
     33typedef int Py_ssize_t;
     34typedef inquiry lenfunc;
     35typedef intargfunc ssizeargfunc;
    3236#endif
    3337
     
    4145        PyObject *response_header, *exc_info = NULL;
    4246        char *status;
    43         int i;
     47        Py_ssize_t i;
    4448        const char *kwnames[] = {
    4549                "status", "response_header", "exc_info", NULL
     
    109113        .tp_methods = web_request_methods,
    110114        .tp_basicsize = sizeof(web_request_Object),
    111         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     115        .tp_flags = Py_TPFLAGS_DEFAULT,
    112116};
    113117
     
    166170        .tp_basicsize = sizeof(error_Stream_Object),
    167171        .tp_methods = error_Stream_methods,
    168         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     172        .tp_flags = Py_TPFLAGS_DEFAULT,
    169173};
    170174
     
    193197        ret = PyString_FromStringAndSize((char *)self->web->input.partial.data+self->offset, size);
    194198        self->offset += size;
    195        
     199
    196200        return ret;
    197201}
     
    240244        .tp_basicsize = sizeof(input_Stream_Object),
    241245        .tp_methods = input_Stream_methods,
    242         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     246        .tp_flags = Py_TPFLAGS_DEFAULT,
    243247};
    244248
     
    304308                        PyDict_SetItemString(env, "CONTENT_TYPE", PyString_FromString(hdr->value));
    305309                } else {
    306                         asprintf(&name, "HTTP_%s", hdr->name);
     310                        if (asprintf(&name, "HTTP_%s", hdr->name) < 0) {
     311                                Py_DECREF(env);
     312                                Py_DECREF(inputstream);
     313                                PyErr_NoMemory();
     314                                return NULL;
     315                        }
    307316                        PyDict_SetItemString(env, name, PyString_FromString(hdr->value));
    308317                        free(name);
     
    325334        PyObject *py_environ, *result, *item, *iter;
    326335        PyObject *request_handler = (PyObject *)wdata->private_data;
    327         struct socket_address *socket_address;
    328 
     336        struct tsocket_address *my_address = web->conn->local_address;
     337        const char *addr = "0.0.0.0";
     338        uint16_t port = 0;
    329339        web_request_Object *py_web = PyObject_New(web_request_Object, &web_request_Type);
    330340        py_web->web = web;
    331341
    332         socket_address = socket_get_my_addr(web->conn->socket, web);
     342        if (tsocket_address_is_inet(my_address, "ip")) {
     343                addr = tsocket_address_inet_addr_string(my_address, wdata);
     344                port = tsocket_address_inet_port(my_address);
     345        }
     346
    333347        py_environ = create_environ(tls_enabled(web->conn->socket),
    334348                                    web->input.content_length,
    335349                                    web->input.headers,
    336350                                    web->input.post_request?"POST":"GET",
    337                                     socket_address->addr,
    338                                     socket_address->port,
     351                                    addr,
     352                                    port,
    339353                                    Py_InputHttpStream(web),
    340354                                    web->input.url
     
    368382bool wsgi_initialize(struct web_server_data *wdata)
    369383{
    370         PyObject *py_swat;
     384        PyObject *py_web_server;
    371385
    372386        Py_Initialize();
     387
     388        py_update_path(); /* Ensure that we have the Samba paths at
     389                           * the start of the sys.path() */
    373390
    374391        if (PyType_Ready(&web_request_Type) < 0)
     
    382399
    383400        wdata->http_process_input = wsgi_process_http_input;
    384         py_swat = PyImport_Import(PyString_FromString("swat"));
    385         if (py_swat == NULL) {
    386                 DEBUG(0, ("Unable to find SWAT\n"));
     401        py_web_server = PyImport_ImportModule("samba.web_server");
     402        if (py_web_server == NULL) {
     403                DEBUG(0, ("Unable to find web server\n"));
    387404                return false;
    388405        }
    389         wdata->private_data = py_swat;
     406        wdata->private_data = py_web_server;
    390407        return true;
    391408}
Note: See TracChangeset for help on using the changeset viewer.