summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-04-28 14:52:40 +0200
committerStefan Metzmacher <metze@samba.org>2010-04-28 15:45:02 +0200
commit6129aa0cf5567c793ed65d1402a7e7fd7e5f6a92 (patch)
treeff45e892b30650d4c091c7519f4d6eea19c9031a /source4
parenta53b09141cd57d7dc94bd0d0e05d7d25ee110857 (diff)
downloadsamba-6129aa0cf5567c793ed65d1402a7e7fd7e5f6a92.tar.gz
samba-6129aa0cf5567c793ed65d1402a7e7fd7e5f6a92.tar.bz2
samba-6129aa0cf5567c793ed65d1402a7e7fd7e5f6a92.zip
s4:web_server: use tsocket_address functions to get the local ip and port
metze (cherry picked from commit 9a1a00199c2603376eacfdba7e7d0d55bc64f405)
Diffstat (limited to 'source4')
-rw-r--r--source4/web_server/config.mk2
-rw-r--r--source4/web_server/wscript_build2
-rw-r--r--source4/web_server/wsgi.c16
3 files changed, 13 insertions, 7 deletions
diff --git a/source4/web_server/config.mk b/source4/web_server/config.mk
index ff587508fc..74ecdb5f19 100644
--- a/source4/web_server/config.mk
+++ b/source4/web_server/config.mk
@@ -5,7 +5,7 @@
[MODULE::WEB]
INIT_FUNCTION = server_service_web_init
SUBSYSTEM = service
-PRIVATE_DEPENDENCIES = LIBTLS smbcalls process_model LIBPYTHON
+PRIVATE_DEPENDENCIES = LIBTLS smbcalls process_model LIBPYTHON LIBTSOCKET
# End SUBSYSTEM WEB
#######################
diff --git a/source4/web_server/wscript_build b/source4/web_server/wscript_build
index 5343c2f508..b7ff4413fb 100644
--- a/source4/web_server/wscript_build
+++ b/source4/web_server/wscript_build
@@ -3,7 +3,7 @@
bld.SAMBA_PYTHON('WEB_WSGI',
source='wsgi.c',
- deps='talloc'
+ deps='talloc LIBTSOCKET'
)
diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c
index 4f1a75e010..7ee70e1107 100644
--- a/source4/web_server/wsgi.c
+++ b/source4/web_server/wsgi.c
@@ -26,6 +26,7 @@
#include "../lib/util/dlinklist.h"
#include "../lib/util/data_blob.h"
#include "lib/tls/tls.h"
+#include "lib/tsocket/tsocket.h"
typedef struct {
PyObject_HEAD
@@ -320,18 +321,23 @@ static void wsgi_process_http_input(struct web_server_data *wdata,
{
PyObject *py_environ, *result, *item, *iter;
PyObject *request_handler = (PyObject *)wdata->private_data;
- struct socket_address *socket_address;
-
+ struct tsocket_address *my_address = web->conn->local_address;
+ const char *addr = "0.0.0.0";
+ uint16_t port = 0;
web_request_Object *py_web = PyObject_New(web_request_Object, &web_request_Type);
py_web->web = web;
- socket_address = socket_get_my_addr(web->conn->socket, web);
+ if (tsocket_address_is_inet(my_address, "ip")) {
+ addr = tsocket_address_inet_addr_string(my_address, wdata);
+ port = tsocket_address_inet_port(my_address);
+ }
+
py_environ = create_environ(tls_enabled(web->conn->socket),
web->input.content_length,
web->input.headers,
web->input.post_request?"POST":"GET",
- socket_address->addr,
- socket_address->port,
+ addr,
+ port,
Py_InputHttpStream(web),
web->input.url
);