summaryrefslogtreecommitdiff
path: root/source4/web_server
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-01-09 22:12:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:49:57 -0500
commitf55ea8bb3dca868e21663cd90eaea7a35cd7886c (patch)
tree80aab2a3f10310e1946821603752cd407e435214 /source4/web_server
parent806b3fdbc12b3284ab9872a4ecae3a7ee34ea171 (diff)
downloadsamba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.tar.gz
samba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.tar.bz2
samba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.zip
r12804: This patch reworks the Samba4 sockets layer to use a socket_address
structure that is more generic than just 'IP/port'. It now passes make test, and has been reviewed and updated by metze. (Thankyou *very* much). This passes 'make test' as well as kerberos use (not currently in the testsuite). The original purpose of this patch was to have Samba able to pass a socket address stucture from the BSD layer into the kerberos routines and back again. It also removes nbt_peer_addr, which was being used for a similar purpose. It is a large change, but worthwhile I feel. Andrew Bartlett (This used to be commit 88198c4881d8620a37086f80e4da5a5b71c5bbb2)
Diffstat (limited to 'source4/web_server')
-rw-r--r--source4/web_server/http.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/source4/web_server/http.c b/source4/web_server/http.c
index 18a1f61c1c..8779007f86 100644
--- a/source4/web_server/http.c
+++ b/source4/web_server/http.c
@@ -225,9 +225,10 @@ static void http_redirect(EspHandle handle, int code, char *url)
/* form the full url, unless it already looks like a url */
if (strchr(url, ':') == NULL) {
if (host == NULL) {
+ struct socket_address *socket_address = socket_get_my_addr(web->conn->socket, web);
+ if (socket_address == NULL) goto internal_error;
host = talloc_asprintf(web, "%s:%u",
- socket_get_my_addr(web->conn->socket, web),
- socket_get_my_port(web->conn->socket));
+ socket_address->addr, socket_address->port);
}
if (host == NULL) goto internal_error;
if (url[0] != '/') {
@@ -399,6 +400,8 @@ static void http_setup_arrays(struct esp_state *esp)
struct websrv_context *web = esp->web;
struct esp_data *edata = talloc_get_type(web->task->private, struct esp_data);
struct EspRequest *req = esp->req;
+ struct socket_address *socket_address = socket_get_my_addr(web->conn->socket, esp);
+ struct socket_address *peer_address = socket_get_my_addr(web->conn->socket, esp);
char *p;
#define SETVAR(type, name, value) do { \
@@ -414,8 +417,9 @@ static void http_setup_arrays(struct esp_state *esp)
p = strrchr(web->input.url, '/');
SETVAR(ESP_REQUEST_OBJ, "SCRIPT_NAME", p+1);
SETVAR(ESP_REQUEST_OBJ, "SCRIPT_FILENAME", web->input.url);
- p = socket_get_peer_addr(web->conn->socket, esp);
- SETVAR(ESP_REQUEST_OBJ, "REMOTE_ADDR", p);
+ if (peer_address) {
+ SETVAR(ESP_REQUEST_OBJ, "REMOTE_ADDR", peer_address->addr);
+ }
p = socket_get_peer_name(web->conn->socket, esp);
SETVAR(ESP_REQUEST_OBJ, "REMOTE_HOST", p);
SETVAR(ESP_REQUEST_OBJ, "REMOTE_USER", "");
@@ -433,12 +437,15 @@ static void http_setup_arrays(struct esp_state *esp)
SETVAR(ESP_HEADERS_OBJ, "COOKIE", web->input.cookie);
SETVAR(ESP_HEADERS_OBJ, "USER_AGENT", web->input.user_agent);
- SETVAR(ESP_SERVER_OBJ, "SERVER_ADDR", socket_get_my_addr(web->conn->socket, esp));
- SETVAR(ESP_SERVER_OBJ, "SERVER_NAME", socket_get_my_addr(web->conn->socket, esp));
- SETVAR(ESP_SERVER_OBJ, "SERVER_HOST", socket_get_my_addr(web->conn->socket, esp));
+ if (socket_address) {
+ SETVAR(ESP_SERVER_OBJ, "SERVER_ADDR", socket_address->addr);
+ SETVAR(ESP_SERVER_OBJ, "SERVER_NAME", socket_address->addr);
+ SETVAR(ESP_SERVER_OBJ, "SERVER_HOST", socket_address->addr);
+ SETVAR(ESP_SERVER_OBJ, "SERVER_PORT",
+ talloc_asprintf(esp, "%u", socket_address->port));
+ }
+
SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory());
- SETVAR(ESP_SERVER_OBJ, "SERVER_PORT",
- talloc_asprintf(esp, "%u", socket_get_my_port(web->conn->socket)));
SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->tls)?"https":"http");
SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SWAT");
SETVAR(ESP_SERVER_OBJ, "GATEWAY_INTERFACE", "CGI/1.1");