1 diff -ur busybox-1.1.0/networking/httpd.c busybox-1.1.0-owrt/networking/httpd.c
2 --- busybox-1.1.0/networking/httpd.c 2006-01-11 06:43:51.000000000 +0100
3 +++ busybox-1.1.0-owrt/networking/httpd.c 2006-01-14 17:56:53.000000000 +0100
6 /* You can use this server as standalone, require libbb.a for linking */
7 //#define HTTPD_STANDALONE
8 +static const char address[16] = "127.0.0.1";
10 /* Config options, disable this for do very small module */
11 //#define CONFIG_FEATURE_HTTPD_CGI
13 void bb_show_usage(void)
15 fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] "
16 - "[-r realm] [-u user] [-h homedir]\n", bb_applet_name);
17 + "[-l IP address] [-r realm] [-u user] [-h homedir]\n", bb_applet_name);
23 unsigned port; /* server initial port and for
24 set env REMOTE_PORT */
25 + char addr[16]; /* server initial IP address */
27 const char *found_mime_type;
28 const char *found_moved_temporarily;
30 sprintf(buf, "%u", config->port);
31 addEnv(port_name, "PORT", buf);
33 +static void addEnvAddr(const char *addr_name)
37 + sprintf(buf, "%s", config->addr);
38 + addEnv(addr_name, "ADDR", buf);
41 #endif /* CONFIG_FEATURE_HTTPD_CGI */
44 /* inet_addr() returns a value that is already in network order */
45 memset(&lsocket, 0, sizeof(lsocket));
46 lsocket.sin_family = AF_INET;
47 - lsocket.sin_addr.s_addr = INADDR_ANY;
48 + if (inet_aton(config->addr, & (lsocket.sin_addr)) == 0) {
49 + if ((gethostbyname(config->addr)) == NULL) return -1;
50 + lsocket.sin_addr.s_addr = ((struct in_addr *) ((gethostbyname(config->addr))->h_addr))->s_addr;
54 + lsocket.sin_addr.s_addr = htons(INADDR_ANY);
56 lsocket.sin_port = htons(config->port) ;
57 fd = socket(AF_INET, SOCK_STREAM, 0);
60 #define OPT_INC_3 ENABLE_FEATURE_HTTPD_AUTH_MD5
62 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
66 #ifdef CONFIG_FEATURE_HTTPD_SETUID
69 #define OPT_REALM (1<<(2+OPT_INC_1+OPT_INC_2)) /* r */
70 #define OPT_MD5 (1<<(2+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* m */
71 #define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* p */
72 +#define OPT_ADDR (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* l */
73 #define OPT_SETUID (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* u */
78 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
82 #ifdef CONFIG_FEATURE_HTTPD_SETUID
84 Only in busybox-1.1.0-owrt/networking: httpd.c.orig
85 Only in busybox-1.1.0-owrt/networking: httpd.c.rej