1 --- busybox-1.1.0.orig/networking/httpd.c 2006-02-06 16:02:30.000000000 +0100
2 +++ busybox-1.1.0/networking/httpd.c 2006-02-06 16:25:34.000000000 +0100
5 #include <sys/socket.h> /* for connect and socket*/
6 #include <netinet/in.h> /* for sockaddr_in */
7 +#include <arpa/inet.h> /* for inet_aton */
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 + fprintf(stderr, "Usage: %s [-p <port>] [-l <IP address>] [-c configFile]"
18 + "[-d/-e <string>] [-r realm] [-u user] [-h homedir]\n", bb_applet_name);
24 unsigned port; /* server initial port and for
25 set env REMOTE_PORT */
26 + char *address; /* server initial address */
28 const char *found_mime_type;
29 const char *found_moved_temporarily;
31 /* inet_addr() returns a value that is already in network order */
32 memset(&lsocket, 0, sizeof(lsocket));
33 lsocket.sin_family = AF_INET;
34 - lsocket.sin_addr.s_addr = INADDR_ANY;
35 + if (inet_aton(config->address, &(lsocket.sin_addr)) == 1) {
36 + if (config->address != NULL) lsocket.sin_addr.s_addr = ((struct in_addr *) ((gethostbyname(config->address))->h_addr))->s_addr;
37 + else lsocket.sin_addr.s_addr = htons(INADDR_ANY);
39 lsocket.sin_port = htons(config->port) ;
40 fd = socket(AF_INET, SOCK_STREAM, 0);
43 #define OPT_INC_3 ENABLE_FEATURE_HTTPD_AUTH_MD5
45 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
49 #ifdef CONFIG_FEATURE_HTTPD_SETUID
52 #define OPT_REALM (1<<(2+OPT_INC_1+OPT_INC_2)) /* r */
53 #define OPT_MD5 (1<<(2+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* m */
54 #define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* p */
55 -#define OPT_SETUID (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* u */
56 +#define OPT_ADDRESS (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* l */
57 +#define OPT_SETUID (1<<(5+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* u */
60 #ifdef HTTPD_STANDALONE
63 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
71 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
73 + config->address = "";
76 config->ContentLength = -1;
79 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
83 #ifdef CONFIG_FEATURE_HTTPD_SETUID
86 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
88 config->port = bb_xgetlarg(s_port, 10, 1, 0xffff);
89 + if (opt & OPT_ADDRESS)
90 + if (s_addr) config->address = (char *) s_addr;
91 #ifdef CONFIG_FEATURE_HTTPD_SETUID
92 if(opt & OPT_SETUID) {