let ipkg fail when a package file to be installed is not found
[openwrt.git] / openwrt / package / busybox / patches / 320-httpd_address_binding.patch
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
3 @@ -110,6 +110,7 @@
4  #include <sys/types.h>
5  #include <sys/socket.h>    /* for connect and socket*/
6  #include <netinet/in.h>    /* for sockaddr_in       */
7 +#include <arpa/inet.h>
8  #include <sys/time.h>
9  #include <sys/stat.h>
10  #include <sys/wait.h>
11 @@ -204,8 +205,8 @@
12  
13  void bb_show_usage(void)
14  {
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);
19    exit(1);
20  }
21  #endif
22 @@ -255,6 +256,7 @@
23  #endif
24    unsigned port;           /* server initial port and for
25                               set env REMOTE_PORT */
26 +  char *address;
27    union HTTPD_FOUND {
28         const char *found_mime_type;
29         const char *found_moved_temporarily;
30 @@ -958,7 +960,10 @@
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);
38 +  }
39    lsocket.sin_port = htons(config->port) ;
40    fd = socket(AF_INET, SOCK_STREAM, 0);
41    if (fd >= 0) {
42 @@ -1996,6 +2001,7 @@
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,)
47  };
48  
49  static const char httpd_opts[]="c:d:h:"
50 @@ -2003,7 +2009,7 @@
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:");
56  
57  #define OPT_CONFIG_FILE (1<<c_opt_config_file)
58  #define OPT_DECODE_URL  (1<<d_opt_decode_url)
59 @@ -2024,6 +2030,8 @@
60  #define OPT_PORT        SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<p_opt_port)) \
61                         USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
62  
63 +#define OPT_ADDRESS     SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<l_opt_addr)) \
64 +                       USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
65  
66  #ifdef HTTPD_STANDALONE
67  int main(int argc, char *argv[])
68 @@ -2036,6 +2044,7 @@
69    char *url_for_decode;
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;)
74  
75    USE_FEATURE_HTTPD_SETUID(const char *s_uid;)
76 @@ -2050,6 +2059,7 @@
77  
78  #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
79    config->port = 80;
80 +  config->address = "";
81  #endif
82  
83    config->ContentLength = -1;
84 @@ -2061,6 +2071,7 @@
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)
89         );
90  
91    if(opt & OPT_DECODE_URL) {
92 @@ -2082,6 +2093,8 @@
93  #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
94      if(opt & OPT_PORT)
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) {
100         char *e;