Added support for user-agent and IP address binding (yes it now works), close #108...
authorFlorian Fainelli <florian@openwrt.org>
Mon, 6 Feb 2006 15:36:49 +0000 (15:36 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Mon, 6 Feb 2006 15:36:49 +0000 (15:36 +0000)
SVN-Revision: 3164

openwrt/package/busybox/patches/320-httpd_user_agent.patch [new file with mode: 0644]
openwrt/package/busybox/patches/330-httpd_address_binding.patch [new file with mode: 0644]

diff --git a/openwrt/package/busybox/patches/320-httpd_user_agent.patch b/openwrt/package/busybox/patches/320-httpd_user_agent.patch
new file mode 100644 (file)
index 0000000..4226bf3
--- /dev/null
@@ -0,0 +1,30 @@
+--- busybox-1.00.orig/networking/httpd.c       2004-10-08 10:03:29.000000000 +0200
++++ busybox-1.00/networking/httpd.c    2006-02-06 14:04:23.000000000 +0100
+@@ -224,6 +224,7 @@
+ #ifdef CONFIG_FEATURE_HTTPD_CGI
+   char *referer;
++  char *user_agent;
+ #endif
+   const char *configFile;
+@@ -1174,6 +1175,8 @@
+ #endif
+       if(config->referer)
+       addEnv("HTTP", "REFERER", config->referer);
++      if(config->user_agent)
++      addEnv("HTTP", "USER_AGENT",config->referer);
+       /* set execve argp[0] without path */
+       argp[0] = strrchr( purl, '/' ) + 1;
+@@ -1682,6 +1685,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
diff --git a/openwrt/package/busybox/patches/330-httpd_address_binding.patch b/openwrt/package/busybox/patches/330-httpd_address_binding.patch
new file mode 100644 (file)
index 0000000..8ad8856
--- /dev/null
@@ -0,0 +1,95 @@
+--- busybox-1.00.orig/networking/httpd.c       2006-02-06 15:46:15.000000000 +0100
++++ busybox-1.00/networking/httpd.c    2006-02-06 15:49:06.000000000 +0100
+@@ -109,6 +109,7 @@
+ #include <sys/types.h>
+ #include <sys/socket.h>    /* for connect and socket*/
+ #include <netinet/in.h>    /* for sockaddr_in       */
++#include <arpa/inet.h>     /* for inet_aton        */
+ #include <sys/time.h>
+ #include <sys/stat.h>
+ #include <sys/wait.h>
+@@ -183,8 +184,8 @@
+ void bb_show_usage(void)
+ {
+-  fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] "
+-                "[-r realm] [-u user] [-h homedir]\n", bb_applet_name);
++  fprintf(stderr, "Usage: %s [-p <port>] [-l <IP address>] [-c configFile] 
++                [-d/-e <string>] [-r realm] [-u user] [-h homedir]\n", bb_applet_name);
+   exit(1);
+ }
+ #endif
+@@ -235,6 +236,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;
+@@ -911,7 +913,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) {
+@@ -1943,7 +1948,7 @@
+ #define OPT_INC_2 0
+ #endif
+ #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+-                              "p:v"
++                              "p:l:v"
+ #ifdef CONFIG_FEATURE_HTTPD_SETUID
+                               "u:"
+ #endif
+@@ -1957,8 +1962,9 @@
+ #define OPT_REALM       (1<<(3+OPT_INC_1))
+ #define OPT_MD5         (1<<(4+OPT_INC_1))
+ #define OPT_PORT        (1<<(3+OPT_INC_1+OPT_INC_2))
+-#define OPT_DEBUG       (1<<(4+OPT_INC_1+OPT_INC_2))
+-#define OPT_SETUID      (1<<(5+OPT_INC_1+OPT_INC_2))
++#define OPT_ADDRESS   (1<<(4+OPT_INC_1+OPT_INC_2))
++#define OPT_DEBUG       (1<<(5+OPT_INC_1+OPT_INC_2))
++#define OPT_SETUID      (1<<(6+OPT_INC_1+OPT_INC_2))
+ #ifdef HTTPD_STANDALONE
+@@ -1975,6 +1981,7 @@
+ #endif
+ #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+   const char *s_port;
++  const char *s_addr;
+ #endif
+ #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+@@ -1997,6 +2004,7 @@
+ #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+   config->port = 80;
++  config->address = "";
+ #endif
+   config->ContentLength = -1;
+@@ -2014,6 +2022,7 @@
+ #endif
+ #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+                       , &s_port
++                      , &s_addr
+ #ifdef CONFIG_FEATURE_HTTPD_SETUID
+                       , &s_uid
+ #endif
+@@ -2039,6 +2048,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)
++      config->address = (char *) s_addr;
+     config->debugHttpd = opt & OPT_DEBUG;
+ #ifdef CONFIG_FEATURE_HTTPD_SETUID
+     if(opt & OPT_SETUID) {