2006-04-02 18:16:27 +03:00
|
|
|
--- busybox-1.1.1/networking/httpd.c 2006-03-22 22:16:19.000000000 +0100
|
|
|
|
+++ busybox-1.1.1.new/networking/httpd.c 2006-04-01 19:41:42.150744624 +0200
|
|
|
|
@@ -110,6 +110,7 @@
|
2006-02-06 17:45:24 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h> /* for connect and socket*/
|
|
|
|
#include <netinet/in.h> /* for sockaddr_in */
|
2006-04-02 18:16:27 +03:00
|
|
|
+#include <arpa/inet.h>
|
2006-02-06 17:45:24 +02:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
2006-04-02 18:16:27 +03:00
|
|
|
@@ -204,8 +205,8 @@
|
2006-02-06 17:45:24 +02:00
|
|
|
|
|
|
|
void bb_show_usage(void)
|
|
|
|
{
|
|
|
|
- fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] "
|
|
|
|
- "[-r realm] [-u user] [-h homedir]\n", bb_applet_name);
|
|
|
|
+ fprintf(stderr, "Usage: %s [-p <port>] [-l <IP address>] [-c configFile]"
|
|
|
|
+ "[-d/-e <string>] [-r realm] [-u user] [-h homedir]\n", bb_applet_name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#endif
|
2006-04-02 18:16:27 +03:00
|
|
|
@@ -255,6 +256,7 @@
|
2006-02-06 17:45:24 +02:00
|
|
|
#endif
|
|
|
|
unsigned port; /* server initial port and for
|
|
|
|
set env REMOTE_PORT */
|
2006-04-02 18:16:27 +03:00
|
|
|
+ char *address;
|
2006-02-06 17:45:24 +02:00
|
|
|
union HTTPD_FOUND {
|
|
|
|
const char *found_mime_type;
|
|
|
|
const char *found_moved_temporarily;
|
2006-04-02 18:16:27 +03:00
|
|
|
@@ -958,7 +960,10 @@
|
2006-02-06 17:45:24 +02:00
|
|
|
/* inet_addr() returns a value that is already in network order */
|
|
|
|
memset(&lsocket, 0, sizeof(lsocket));
|
|
|
|
lsocket.sin_family = AF_INET;
|
|
|
|
- lsocket.sin_addr.s_addr = INADDR_ANY;
|
|
|
|
+ if (inet_aton(config->address, &(lsocket.sin_addr)) == 1) {
|
|
|
|
+ if (config->address != NULL) lsocket.sin_addr.s_addr = ((struct in_addr *) ((gethostbyname(config->address))->h_addr))->s_addr;
|
|
|
|
+ else lsocket.sin_addr.s_addr = htons(INADDR_ANY);
|
|
|
|
+ }
|
|
|
|
lsocket.sin_port = htons(config->port) ;
|
|
|
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
|
if (fd >= 0) {
|
2006-04-02 18:16:27 +03:00
|
|
|
@@ -1996,6 +2001,7 @@
|
|
|
|
USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,)
|
|
|
|
USE_FEATURE_HTTPD_SETUID(u_opt_setuid,)
|
|
|
|
SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(p_opt_port,)
|
|
|
|
+ SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(l_opt_addr,)
|
|
|
|
};
|
2006-02-06 17:45:24 +02:00
|
|
|
|
2006-04-02 18:16:27 +03:00
|
|
|
static const char httpd_opts[]="c:d:h:"
|
|
|
|
@@ -2003,7 +2009,7 @@
|
|
|
|
USE_FEATURE_HTTPD_BASIC_AUTH("r:")
|
|
|
|
USE_FEATURE_HTTPD_AUTH_MD5("m:")
|
|
|
|
USE_FEATURE_HTTPD_SETUID("u:")
|
|
|
|
- SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:");
|
|
|
|
+ SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:l:");
|
2006-02-06 17:45:24 +02:00
|
|
|
|
2006-04-02 18:16:27 +03:00
|
|
|
#define OPT_CONFIG_FILE (1<<c_opt_config_file)
|
|
|
|
#define OPT_DECODE_URL (1<<d_opt_decode_url)
|
|
|
|
@@ -2024,6 +2030,8 @@
|
|
|
|
#define OPT_PORT SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<p_opt_port)) \
|
|
|
|
USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
|
|
|
|
|
|
|
|
+#define OPT_ADDRESS SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<l_opt_addr)) \
|
|
|
|
+ USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
|
2006-02-06 17:45:24 +02:00
|
|
|
|
|
|
|
#ifdef HTTPD_STANDALONE
|
2006-04-02 18:16:27 +03:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
@@ -2036,6 +2044,7 @@
|
|
|
|
char *url_for_decode;
|
|
|
|
USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
|
|
|
|
SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_port;)
|
|
|
|
+ SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_addr;)
|
|
|
|
SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(int server;)
|
2006-02-06 17:45:24 +02:00
|
|
|
|
2006-04-02 18:16:27 +03:00
|
|
|
USE_FEATURE_HTTPD_SETUID(const char *s_uid;)
|
|
|
|
@@ -2050,6 +2059,7 @@
|
2006-02-06 17:45:24 +02:00
|
|
|
|
|
|
|
#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
|
|
|
|
config->port = 80;
|
|
|
|
+ config->address = "";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
config->ContentLength = -1;
|
2006-04-02 18:16:27 +03:00
|
|
|
@@ -2061,6 +2071,7 @@
|
|
|
|
USE_FEATURE_HTTPD_AUTH_MD5(, &pass)
|
|
|
|
USE_FEATURE_HTTPD_SETUID(, &s_uid)
|
|
|
|
SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_port)
|
|
|
|
+ SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_addr)
|
|
|
|
);
|
|
|
|
|
|
|
|
if(opt & OPT_DECODE_URL) {
|
|
|
|
@@ -2082,6 +2093,8 @@
|
2006-02-06 17:45:24 +02:00
|
|
|
#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
|
|
|
|
if(opt & OPT_PORT)
|
|
|
|
config->port = bb_xgetlarg(s_port, 10, 1, 0xffff);
|
|
|
|
+ if (opt & OPT_ADDRESS)
|
|
|
|
+ if (s_addr) config->address = (char *) s_addr;
|
|
|
|
#ifdef CONFIG_FEATURE_HTTPD_SETUID
|
|
|
|
if(opt & OPT_SETUID) {
|
|
|
|
char *e;
|