fix typo
[openwrt.git] / package / busybox / patches / 320-httpd_address_binding.patch
1
2 Copyright (C) 2006 OpenWrt.org
3
4 --- busybox-1.1.1/networking/httpd.c 2006-03-22 22:16:19.000000000 +0100
5 +++ busybox-1.1.1.new/networking/httpd.c 2006-04-01 19:41:42.150744624 +0200
6 @@ -110,6 +110,7 @@
7 #include <sys/types.h>
8 #include <sys/socket.h> /* for connect and socket*/
9 #include <netinet/in.h> /* for sockaddr_in */
10 +#include <arpa/inet.h>
11 #include <sys/time.h>
12 #include <sys/stat.h>
13 #include <sys/wait.h>
14 @@ -204,8 +205,8 @@
15
16 void bb_show_usage(void)
17 {
18 - fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] "
19 - "[-r realm] [-u user] [-h homedir]\n", bb_applet_name);
20 + fprintf(stderr, "Usage: %s [-p <port>] [-l <IP address>] [-c configFile]"
21 + "[-d/-e <string>] [-r realm] [-u user] [-h homedir]\n", bb_applet_name);
22 exit(1);
23 }
24 #endif
25 @@ -255,6 +256,7 @@
26 #endif
27 unsigned port; /* server initial port and for
28 set env REMOTE_PORT */
29 + char *address;
30 union HTTPD_FOUND {
31 const char *found_mime_type;
32 const char *found_moved_temporarily;
33 @@ -958,7 +960,10 @@
34 /* inet_addr() returns a value that is already in network order */
35 memset(&lsocket, 0, sizeof(lsocket));
36 lsocket.sin_family = AF_INET;
37 - lsocket.sin_addr.s_addr = INADDR_ANY;
38 + if (inet_aton(config->address, &(lsocket.sin_addr)) == 1) {
39 + if (config->address != NULL) lsocket.sin_addr.s_addr = ((struct in_addr *) ((gethostbyname(config->address))->h_addr))->s_addr;
40 + else lsocket.sin_addr.s_addr = htons(INADDR_ANY);
41 + }
42 lsocket.sin_port = htons(config->port) ;
43 fd = socket(AF_INET, SOCK_STREAM, 0);
44 if (fd >= 0) {
45 @@ -1996,6 +2001,7 @@
46 USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,)
47 USE_FEATURE_HTTPD_SETUID(u_opt_setuid,)
48 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(p_opt_port,)
49 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(l_opt_addr,)
50 };
51
52 static const char httpd_opts[]="c:d:h:"
53 @@ -2003,7 +2009,7 @@
54 USE_FEATURE_HTTPD_BASIC_AUTH("r:")
55 USE_FEATURE_HTTPD_AUTH_MD5("m:")
56 USE_FEATURE_HTTPD_SETUID("u:")
57 - SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:");
58 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:l:");
59
60 #define OPT_CONFIG_FILE (1<<c_opt_config_file)
61 #define OPT_DECODE_URL (1<<d_opt_decode_url)
62 @@ -2024,6 +2030,8 @@
63 #define OPT_PORT SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<p_opt_port)) \
64 USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
65
66 +#define OPT_ADDRESS SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<l_opt_addr)) \
67 + USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
68
69 #ifdef HTTPD_STANDALONE
70 int main(int argc, char *argv[])
71 @@ -2036,6 +2044,7 @@
72 char *url_for_decode;
73 USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
74 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_port;)
75 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_addr;)
76 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(int server;)
77
78 USE_FEATURE_HTTPD_SETUID(const char *s_uid;)
79 @@ -2050,6 +2059,7 @@
80
81 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
82 config->port = 80;
83 + config->address = "";
84 #endif
85
86 config->ContentLength = -1;
87 @@ -2061,6 +2071,7 @@
88 USE_FEATURE_HTTPD_AUTH_MD5(, &pass)
89 USE_FEATURE_HTTPD_SETUID(, &s_uid)
90 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_port)
91 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_addr)
92 );
93
94 if(opt & OPT_DECODE_URL) {
95 @@ -2082,6 +2093,8 @@
96 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
97 if(opt & OPT_PORT)
98 config->port = bb_xgetlarg(s_port, 10, 1, 0xffff);
99 + if (opt & OPT_ADDRESS)
100 + if (s_addr) config->address = (char *) s_addr;
101 #ifdef CONFIG_FEATURE_HTTPD_SETUID
102 if(opt & OPT_SETUID) {
103 char *e;
This page took 0.057782 seconds and 5 git commands to generate.