1 --- busybox-1.1.0-pre1.orig/networking/httpd.c 2005-11-01 00:55:15.000000000 +0100
2 +++ busybox-1.1.0-pre1/networking/httpd.c 2006-01-07 00:58:45.000000000 +0100
5 /* You can use this server as standalone, require libbb.a for linking */
6 //#define HTTPD_STANDALONE
7 +static const char address[16] = "127.0.0.1";
9 /* Config options, disable this for do very small module */
10 //#define CONFIG_FEATURE_HTTPD_CGI
12 void bb_show_usage(void)
14 fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] "
15 - "[-r realm] [-u user] [-h homedir]\n", bb_applet_name);
16 + "[-l IP address] [-r realm] [-u user] [-h homedir]\n", bb_applet_name);
22 unsigned port; /* server initial port and for
23 set env REMOTE_PORT */
24 + char addr[16]; /* server initial IP address */
26 const char *found_mime_type;
27 const char *found_moved_temporarily;
29 sprintf(buf, "%u", config->port);
30 addEnv(port_name, "PORT", buf);
32 +static void addEnvAddr(const char *addr_name)
36 + sprintf(buf, "%s", config->addr);
37 + addEnv(addr_name, "ADDR", buf);
40 #endif /* CONFIG_FEATURE_HTTPD_CGI */
43 /* inet_addr() returns a value that is already in network order */
44 memset(&lsocket, 0, sizeof(lsocket));
45 lsocket.sin_family = AF_INET;
46 - lsocket.sin_addr.s_addr = INADDR_ANY;
47 + if (inet_aton(config->addr, & (lsocket.sin_addr)) == 0) {
48 + if ((gethostbyname(config->addr)) == NULL) return -1;
49 + lsocket.sin_addr.s_addr = ((struct in_addr *) ((gethostbyname(config->addr))->h_addr))->s_addr;
53 + lsocket.sin_addr.s_addr = htons(INADDR_ANY);
55 lsocket.sin_port = htons(config->port) ;
56 fd = socket(AF_INET, SOCK_STREAM, 0);
61 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
64 #ifdef CONFIG_FEATURE_HTTPD_SETUID
68 #define OPT_REALM (1<<(3+OPT_INC_1))
69 #define OPT_MD5 (1<<(4+OPT_INC_1))
70 #define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2))
71 -#define OPT_DEBUG (1<<(4+OPT_INC_1+OPT_INC_2))
72 -#define OPT_SETUID (1<<(5+OPT_INC_1+OPT_INC_2))
73 +#define OPT_ADDR (1<<(4+OPT_INC_1+OPT_INC_2))
74 +#define OPT_DEBUG (1<<(5+OPT_INC_1+OPT_INC_2))
75 +#define OPT_SETUID (1<<(6+OPT_INC_1+OPT_INC_2))
78 #ifdef HTTPD_STANDALONE
81 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
84 #ifdef CONFIG_FEATURE_HTTPD_SETUID