aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-05-26 14:07:50 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-05-26 14:07:50 +0000
commit76f4ab68a56e14747c25e6da830cf73b38bbe1cd (patch)
treed2e94dac0f1f5da5cb3ecb927b78c4c2a02f4ea6 /networking
parent37e0338781ea28f57bed354fe745effb020d16fc (diff)
downloadbusybox-w32-76f4ab68a56e14747c25e6da830cf73b38bbe1cd.tar.gz
busybox-w32-76f4ab68a56e14747c25e6da830cf73b38bbe1cd.tar.bz2
busybox-w32-76f4ab68a56e14747c25e6da830cf73b38bbe1cd.zip
Vodz, last_patch_86
git-svn-id: svn://busybox.net/trunk/busybox@6853 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r--networking/Config.in18
-rw-r--r--networking/httpd.c68
-rw-r--r--networking/ifconfig.c4
3 files changed, 39 insertions, 51 deletions
diff --git a/networking/Config.in b/networking/Config.in
index 3a0d3e9d9..2b2de28ec 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -58,6 +58,7 @@ config CONFIG_FEATURE_HTTPD_BASIC_AUTH
58 authentication on a per url basis. 58 authentication on a per url basis.
59 59
60 60
61if !CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
61config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP 62config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
62 bool " Enable support reload global config file after hup signaled" 63 bool " Enable support reload global config file after hup signaled"
63 default n 64 default n
@@ -75,6 +76,7 @@ config CONFIG_FEATURE_HTTPD_SETUID
75 rather than defaulting to the user that starts the server. 76 rather than defaulting to the user that starts the server.
76 Use of this option requires special privilegies to change to a 77 Use of this option requires special privilegies to change to a
77 different user. 78 different user.
79endif
78 80
79config CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES 81config CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
80 bool " Enable support load from config file mime types" 82 bool " Enable support load from config file mime types"
@@ -91,6 +93,7 @@ config CONFIG_FEATURE_HTTPD_CGI
91 help 93 help
92 This option allows scripts and executables to be invoked 94 This option allows scripts and executables to be invoked
93 when specific urls are requested. 95 when specific urls are requested.
96
94config CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 97config CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
95 bool " Enable support set eviroment REMOTE_PORT variable for CGI" 98 bool " Enable support set eviroment REMOTE_PORT variable for CGI"
96 default n 99 default n
@@ -111,15 +114,6 @@ config CONFIG_FEATURE_HTTPD_SET_CGI_VARS_TO_ENV
111 to 'bar'. In addition, this option sets a variable that 114 to 'bar'. In addition, this option sets a variable that
112 lists all the argument names. e.g. CGI_VARNAMES_="name1 name2". 115 lists all the argument names. e.g. CGI_VARNAMES_="name1 name2".
113 116
114config CONFIG_FEATURE_HTTPD_DECODE_URL_STR
115 bool " Enable the -d option for shell script CGI simplification"
116 default y
117 depends on CONFIG_HTTPD
118 help
119 After set, this option enables support for decoding of
120 url-encoded form arguments via the -d option. Output goes to
121 stdout. For example, httpd -d "Hello%20World" produces "Hello World".
122
123config CONFIG_FEATURE_HTTPD_ENCODE_URL_STR 117config CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
124 bool " Enable the -e option for shell script CGI simplification." 118 bool " Enable the -e option for shell script CGI simplification."
125 default y 119 default y
@@ -474,7 +468,7 @@ config CONFIG_FEATURE_TFTP_BLOCKSIZE
474 468
475config CONFIG_FEATURE_TFTP_DEBUG 469config CONFIG_FEATURE_TFTP_DEBUG
476 bool " Enable debug" 470 bool " Enable debug"
477 default y 471 default n
478 depends on CONFIG_TFTP 472 depends on CONFIG_TFTP
479 help 473 help
480 Please submit a patch to add help text for this item. 474 Please submit a patch to add help text for this item.
@@ -487,14 +481,14 @@ config CONFIG_TRACEROUTE
487 481
488config CONFIG_FEATURE_TRACEROUTE_VERBOSE 482config CONFIG_FEATURE_TRACEROUTE_VERBOSE
489 bool " Enable verbose output" 483 bool " Enable verbose output"
490 default y 484 default n
491 depends on CONFIG_TRACEROUTE 485 depends on CONFIG_TRACEROUTE
492 help 486 help
493 Please submit a patch to add help text for this item. 487 Please submit a patch to add help text for this item.
494 488
495config CONFIG_FEATURE_TRACEROUTE_SO_DEBUG 489config CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
496 bool " Enable SO_DEBUG option" 490 bool " Enable SO_DEBUG option"
497 default y 491 default n
498 depends on CONFIG_TRACEROUTE 492 depends on CONFIG_TRACEROUTE
499 help 493 help
500 Please submit a patch to add help text for this item. 494 Please submit a patch to add help text for this item.
diff --git a/networking/httpd.c b/networking/httpd.c
index e9f4c15bc..ef8263b99 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -60,8 +60,7 @@
60 * .au:audio/basic # additional mime type for audio.au files 60 * .au:audio/basic # additional mime type for audio.au files
61 * 61 *
62 * A/D may be as a/d or allow/deny - first char case unsensitive 62 * A/D may be as a/d or allow/deny - first char case unsensitive
63 * Deny IP rules take precedence over allow rules. Any IP rules after D:* are 63 * Deny IP rules take precedence over allow rules.
64 * ignored.
65 * 64 *
66 * 65 *
67 * The Deny/Allow IP logic: 66 * The Deny/Allow IP logic:
@@ -123,7 +122,7 @@
123#include "busybox.h" 122#include "busybox.h"
124 123
125 124
126static const char httpdVersion[] = "busybox httpd/1.26 18-May-2003"; 125static const char httpdVersion[] = "busybox httpd/1.27 25-May-2003";
127static const char default_path_httpd_conf[] = "/etc"; 126static const char default_path_httpd_conf[] = "/etc";
128static const char httpd_conf[] = "httpd.conf"; 127static const char httpd_conf[] = "httpd.conf";
129static const char home[] = "./"; 128static const char home[] = "./";
@@ -234,6 +233,7 @@ typedef struct
234 time_t last_mod; 233 time_t last_mod;
235 234
236 Htaccess *ip_a_d; /* config allow/deny lines */ 235 Htaccess *ip_a_d; /* config allow/deny lines */
236 int flg_deny_all;
237#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 237#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
238 Htaccess *auth; /* config user:password lines */ 238 Htaccess *auth; /* config user:password lines */
239#endif 239#endif
@@ -452,16 +452,21 @@ static void parse_conf(const char *path, int flag)
452 /* test for empty or strange line */ 452 /* test for empty or strange line */
453 if (c == NULL || *c == 0) 453 if (c == NULL || *c == 0)
454 continue; 454 continue;
455 if(*c == '*')
456 *c = 0; /* Allow all */
457 p0 = buf; 455 p0 = buf;
458 if((*p0 == 'i') || (*p0 == 'I'))
459 *p0 = 'A'; // version 1.1/1.2 compatibility for ip:
460 if(*p0 == 'a')
461 *p0 = 'A';
462 if(*p0 == 'd') 456 if(*p0 == 'd')
463 *p0 = 'D'; 457 *p0 = 'D';
464 if(*p0 != 'A' && *p0 != 'D' 458 if(*c == '*') {
459 if(*p0 == 'D') {
460 /* memorize deny all */
461 config->flg_deny_all++;
462 }
463 /* skip default other "word:*" config lines */
464 continue;
465 }
466
467 if(*p0 == 'a')
468 *p0 = 'A';
469 else if(*p0 != 'D'
465#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 470#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
466 && *p0 != '/' 471 && *p0 != '/'
467#endif 472#endif
@@ -471,17 +476,8 @@ static void parse_conf(const char *path, int flag)
471 ) 476 )
472 continue; 477 continue;
473 478
474 if(*p0 == 'A' && *c == 0) {
475 /* skip default A:* */
476 continue;
477 }
478 p0 = buf;
479#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 479#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
480 if(*p0 == '/') { 480 if(*p0 == '/') {
481 if(*c == 0) {
482 /* skip /path:* */
483 continue;
484 }
485 /* make full path from httpd root / curent_path / config_line_path */ 481 /* make full path from httpd root / curent_path / config_line_path */
486 cf = flag == SUBDIR_PARSE ? path : ""; 482 cf = flag == SUBDIR_PARSE ? path : "";
487 p0 = malloc(strlen(cf) + (c - buf) + 2 + strlen(c)); 483 p0 = malloc(strlen(cf) + (c - buf) + 2 + strlen(c));
@@ -532,12 +528,12 @@ static void parse_conf(const char *path, int flag)
532 free(p0); 528 free(p0);
533#endif 529#endif
534 if(*cf == 'A' || *cf == 'D') { 530 if(*cf == 'A' || *cf == 'D') {
535 if(*cf == 'D' && *c) { 531 if(*cf == 'D') {
536 /* Deny:form_IP move top */ 532 /* Deny:form_IP move top */
537 cur->next = config->ip_a_d; 533 cur->next = config->ip_a_d;
538 config->ip_a_d = cur; 534 config->ip_a_d = cur;
539 } else { 535 } else {
540 /* add to bottom current IP config line */ 536 /* add to bottom A:form_IP config line */
541 Htaccess *prev_IP = config->ip_a_d; 537 Htaccess *prev_IP = config->ip_a_d;
542 538
543 if(prev_IP == NULL) { 539 if(prev_IP == NULL) {
@@ -573,12 +569,11 @@ static void parse_conf(const char *path, int flag)
573 cur->next = hti; 569 cur->next = hti;
574 if(prev_hti != hti) { 570 if(prev_hti != hti) {
575 prev_hti->next = cur; 571 prev_hti->next = cur;
576 break;
577 } else { 572 } else {
578 /* insert as top */ 573 /* insert as top */
579 config->auth = cur; 574 config->auth = cur;
580 break;
581 } 575 }
576 break;
582 } 577 }
583 if(prev_hti != hti) 578 if(prev_hti != hti)
584 prev_hti = prev_hti->next; 579 prev_hti = prev_hti->next;
@@ -695,18 +690,16 @@ static void addEnv(const char *name_before_underline,
695 const char *name_after_underline, const char *value) 690 const char *name_after_underline, const char *value)
696{ 691{
697 char *s; 692 char *s;
693 const char *underline;
698 694
699 if (config->envCount >= ENVSIZE) 695 if (config->envCount >= ENVSIZE)
700 return; 696 return;
701 if (!value) 697 if (!value)
702 value = ""; 698 value = "";
703 s = malloc(strlen(name_before_underline) + strlen(name_after_underline) + 699 underline = *name_after_underline ? "_" : "";
704 strlen(value) + 3); 700 asprintf(&s, "%s%s%s=%s", name_before_underline, underline,
705 if (s) {
706 const char *underline = *name_after_underline ? "_" : "";
707
708 sprintf(s,"%s%s%s=%s", name_before_underline, underline,
709 name_after_underline, value); 701 name_after_underline, value);
702 if(s) {
710 config->envp[config->envCount++] = s; 703 config->envp[config->envCount++] = s;
711 config->envp[config->envCount] = 0; 704 config->envp[config->envCount] = 0;
712 } 705 }
@@ -764,11 +757,11 @@ static void addEnvCgi(const char *pargs)
764 *args++ = 0; 757 *args++ = 0;
765 addEnv("CGI", name, decodeString(value, 1)); 758 addEnv("CGI", name, decodeString(value, 1));
766 if (*namelist) strcat(namelist, " "); 759 if (*namelist) strcat(namelist, " ");
767 strcat(namelist,name); 760 strcat(namelist, name);
768 } 761 }
769 free(memargs); 762 free(memargs);
770 if (namelist) { 763 if (namelist) {
771 addEnv("CGI","ARGLIST_",namelist); 764 addEnv("CGI", "ARGLIST_", namelist);
772 free(namelist); 765 free(namelist);
773 } 766 }
774} 767}
@@ -1337,6 +1330,8 @@ static int checkPerm(const char *path, const char *request)
1337 } 1330 }
1338 } /* for */ 1331 } /* for */
1339 1332
1333 if(ipaddr)
1334 return config->flg_deny_all;
1340 return prev == NULL; 1335 return prev == NULL;
1341} 1336}
1342 1337
@@ -1359,7 +1354,7 @@ static int checkPermIP(const char *request)
1359 } 1354 }
1360 1355
1361 /* if uncofigured, return 1 - access from all */ 1356 /* if uncofigured, return 1 - access from all */
1362 return 1; 1357 return config->flg_deny_all;
1363} 1358}
1364#define checkPerm(null, request) checkPermIP(request) 1359#define checkPerm(null, request) checkPermIP(request)
1365#endif /* CONFIG_FEATURE_HTTPD_BASIC_AUTH */ 1360#endif /* CONFIG_FEATURE_HTTPD_BASIC_AUTH */
@@ -1788,9 +1783,7 @@ int httpd_main(int argc, char *argv[])
1788 config->debugHttpd = 1; 1783 config->debugHttpd = 1;
1789 break; 1784 break;
1790 case 'p': 1785 case 'p':
1791 config->port = atoi(optarg); 1786 config->port = bb_xgetlarg(optarg, 10, 1, 0xffff);
1792 if(config->port <= 0 || config->port > 0xffff)
1793 bb_error_msg_and_die("invalid %s for -p", optarg);
1794 break; 1787 break;
1795#endif 1788#endif
1796 case 'd': 1789 case 'd':
@@ -1854,10 +1847,11 @@ int httpd_main(int argc, char *argv[])
1854#ifdef TEST 1847#ifdef TEST
1855 if (numTestArgs) 1848 if (numTestArgs)
1856 { 1849 {
1857 if (strcmp(testArgs[0],"ip") == 0) testArgs[0] = 0; 1850 int result;
1851 if (strcmp(testArgs[0], "ip") == 0) testArgs[0] = 0;
1858 if (numTestArgs > 2) 1852 if (numTestArgs > 2)
1859 parse_conf(testArgs[2], SUBDIR_PARSE); 1853 parse_conf(testArgs[2], SUBDIR_PARSE);
1860 int result = printf("%d\n",checkPerm(testArgs[0],testArgs[1])); 1854 result = printf("%d\n", checkPerm(testArgs[0], testArgs[1]));
1861 return result; 1855 return result;
1862 } 1856 }
1863#endif 1857#endif
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index c09c48c58..37cba235a 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -15,7 +15,7 @@
15 * Foundation; either version 2 of the License, or (at 15 * Foundation; either version 2 of the License, or (at
16 * your option) any later version. 16 * your option) any later version.
17 * 17 *
18 * $Id: ifconfig.c,v 1.23 2003/03/19 09:12:38 mjn3 Exp $ 18 * $Id: ifconfig.c,v 1.24 2003/05/26 14:06:01 bug1 Exp $
19 * 19 *
20 */ 20 */
21 21
@@ -296,7 +296,7 @@ int ifconfig_main(int argc, char **argv)
296#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS 296#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS
297 unsigned int mask; 297 unsigned int mask;
298 unsigned int did_flags; 298 unsigned int did_flags;
299 in_addr_t sai_hostname, sai_netmask; 299 unsigned int sai_hostname, sai_netmask;
300#else 300#else
301 unsigned char mask; 301 unsigned char mask;
302 unsigned char did_flags; 302 unsigned char did_flags;