From 9aaeaf4deea7fbc6da57c447406075825b7beb75 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 6 Feb 2006 15:45:24 +0000 Subject: [PATCH] Added support httpd user-agent, IP address binding, closes #265 and #108 SVN-Revision: 3165 --- .../patches/320-httpd_address_binding.patch | 93 +++++++++++++++++++ .../patches/330-httpd_user_agent.patch | 29 ++++++ 2 files changed, 122 insertions(+) create mode 100644 openwrt/package/busybox/patches/320-httpd_address_binding.patch create mode 100644 openwrt/package/busybox/patches/330-httpd_user_agent.patch diff --git a/openwrt/package/busybox/patches/320-httpd_address_binding.patch b/openwrt/package/busybox/patches/320-httpd_address_binding.patch new file mode 100644 index 0000000000..2c2d517c60 --- /dev/null +++ b/openwrt/package/busybox/patches/320-httpd_address_binding.patch @@ -0,0 +1,93 @@ +--- busybox-1.1.0.orig/networking/httpd.c 2006-02-06 16:02:30.000000000 +0100 ++++ busybox-1.1.0/networking/httpd.c 2006-02-06 16:25:34.000000000 +0100 +@@ -109,6 +109,7 @@ + #include + #include /* for connect and socket*/ + #include /* for sockaddr_in */ ++#include /* for inet_aton */ + #include + #include + #include +@@ -201,8 +202,8 @@ + + void bb_show_usage(void) + { +- fprintf(stderr, "Usage: %s [-p ] [-c configFile] [-d/-e ] " +- "[-r realm] [-u user] [-h homedir]\n", bb_applet_name); ++ fprintf(stderr, "Usage: %s [-p ] [-l ] [-c configFile]" ++ "[-d/-e ] [-r realm] [-u user] [-h homedir]\n", bb_applet_name); + exit(1); + } + #endif +@@ -256,6 +257,7 @@ + #endif + unsigned port; /* server initial port and for + set env REMOTE_PORT */ ++ char *address; /* server initial address */ + union HTTPD_FOUND { + const char *found_mime_type; + const char *found_moved_temporarily; +@@ -942,7 +944,10 @@ + /* inet_addr() returns a value that is already in network order */ + memset(&lsocket, 0, sizeof(lsocket)); + lsocket.sin_family = AF_INET; +- lsocket.sin_addr.s_addr = INADDR_ANY; ++ if (inet_aton(config->address, &(lsocket.sin_addr)) == 1) { ++ if (config->address != NULL) lsocket.sin_addr.s_addr = ((struct in_addr *) ((gethostbyname(config->address))->h_addr))->s_addr; ++ else lsocket.sin_addr.s_addr = htons(INADDR_ANY); ++ } + lsocket.sin_port = htons(config->port) ; + fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd >= 0) { +@@ -1985,7 +1990,7 @@ + #define OPT_INC_3 ENABLE_FEATURE_HTTPD_AUTH_MD5 + + #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY +- "p:" ++ "p:l:" + #endif + #ifdef CONFIG_FEATURE_HTTPD_SETUID + "u:" +@@ -1999,7 +2004,8 @@ + #define OPT_REALM (1<<(2+OPT_INC_1+OPT_INC_2)) /* r */ + #define OPT_MD5 (1<<(2+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* m */ + #define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* p */ +-#define OPT_SETUID (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* u */ ++#define OPT_ADDRESS (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* l */ ++#define OPT_SETUID (1<<(5+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* u */ + + + #ifdef HTTPD_STANDALONE +@@ -2016,6 +2022,7 @@ + #endif + #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY + const char *s_port; ++ const char *s_addr; + int server; + #endif + +@@ -2035,6 +2042,7 @@ + + #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY + config->port = 80; ++ config->address = ""; + #endif + + config->ContentLength = -1; +@@ -2052,6 +2060,7 @@ + #endif + #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY + , &s_port ++ , &s_addr + #endif + #ifdef CONFIG_FEATURE_HTTPD_SETUID + , &s_uid +@@ -2077,6 +2086,8 @@ + #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY + if(opt & OPT_PORT) + config->port = bb_xgetlarg(s_port, 10, 1, 0xffff); ++ if (opt & OPT_ADDRESS) ++ if (s_addr) config->address = (char *) s_addr; + #ifdef CONFIG_FEATURE_HTTPD_SETUID + if(opt & OPT_SETUID) { + char *e; diff --git a/openwrt/package/busybox/patches/330-httpd_user_agent.patch b/openwrt/package/busybox/patches/330-httpd_user_agent.patch new file mode 100644 index 0000000000..7cf3f5337a --- /dev/null +++ b/openwrt/package/busybox/patches/330-httpd_user_agent.patch @@ -0,0 +1,29 @@ +--- busybox-1.1.0.orig/networking/httpd.c 2006-02-06 16:41:57.000000000 +0100 ++++ busybox-1.1.0/networking/httpd.c 2006-02-06 16:41:26.000000000 +0100 +@@ -247,6 +247,7 @@ + + #ifdef CONFIG_FEATURE_HTTPD_CGI + char *referer; ++ char *user_agent; + #endif + + const char *configFile; +@@ -1192,6 +1193,7 @@ + addEnv("SERVER", "PROTOCOL", "HTTP/1.0"); + addEnv("GATEWAY_INTERFACE", "", "CGI/1.1"); + addEnv("REMOTE", "ADDR", config->rmt_ip_str); ++ addEnv("HTTP","USER_AGENT", config->user_agent); + #ifdef CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV + addEnvPort("REMOTE"); + #endif +@@ -1737,6 +1739,10 @@ + for(test = buf + 8; isspace(*test); test++) + ; + config->referer = strdup(test); ++ } else if ((strncasecmp(buf, "User-Agent:",11) ==0)) { ++ for(test = buf + 11; isspace(*test); test++) ++ ; ++ config->user_agent = strdup(test); + } + #endif + -- 2.30.2