1 --- busybox-1.1.1/networking/httpd.c 2006-03-22 22:16:19.000000000 +0100
2 +++ busybox-1.1.1.new/networking/httpd.c 2006-04-01 19:41:42.150744624 +0200
5 #include <sys/socket.h> /* for connect and socket*/
6 #include <netinet/in.h> /* for sockaddr_in */
7 +#include <arpa/inet.h>
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 */
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 USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,)
44 USE_FEATURE_HTTPD_SETUID(u_opt_setuid,)
45 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(p_opt_port,)
46 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(l_opt_addr,)
49 static const char httpd_opts[]="c:d:h:"
51 USE_FEATURE_HTTPD_BASIC_AUTH("r:")
52 USE_FEATURE_HTTPD_AUTH_MD5("m:")
53 USE_FEATURE_HTTPD_SETUID("u:")
54 - SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:");
55 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:l:");
57 #define OPT_CONFIG_FILE (1<<c_opt_config_file)
58 #define OPT_DECODE_URL (1<<d_opt_decode_url)
60 #define OPT_PORT SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<p_opt_port)) \
61 USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
63 +#define OPT_ADDRESS SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<l_opt_addr)) \
64 + USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
66 #ifdef HTTPD_STANDALONE
67 int main(int argc, char *argv[])
70 USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
71 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_port;)
72 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_addr;)
73 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(int server;)
75 USE_FEATURE_HTTPD_SETUID(const char *s_uid;)
78 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
80 + config->address = "";
83 config->ContentLength = -1;
85 USE_FEATURE_HTTPD_AUTH_MD5(, &pass)
86 USE_FEATURE_HTTPD_SETUID(, &s_uid)
87 SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_port)
88 + SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_addr)
91 if(opt & OPT_DECODE_URL) {
93 #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
95 config->port = bb_xgetlarg(s_port, 10, 1, 0xffff);
96 + if (opt & OPT_ADDRESS)
97 + if (s_addr) config->address = (char *) s_addr;
98 #ifdef CONFIG_FEATURE_HTTPD_SETUID
99 if(opt & OPT_SETUID) {