diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-30 20:41:44 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-30 20:41:44 +0000 |
commit | 55a994055ff2c391aeec377dbb1e6b3c096334d2 (patch) | |
tree | 750347c7cd275a8fbb8ca17e5d36579aac462e9a /networking/httpd.c | |
parent | 3038ac9c1977c8472fdda2d833a4e4fd5ba6ea94 (diff) | |
download | busybox-w32-55a994055ff2c391aeec377dbb1e6b3c096334d2.tar.gz busybox-w32-55a994055ff2c391aeec377dbb1e6b3c096334d2.tar.bz2 busybox-w32-55a994055ff2c391aeec377dbb1e6b3c096334d2.zip |
lsmod: repair indentation
httpd: ifdef CONFIG -> if ENABLE (shorted, catched typos)
Diffstat (limited to 'networking/httpd.c')
-rw-r--r-- | networking/httpd.c | 186 |
1 files changed, 91 insertions, 95 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 9c3c85861..7388bb67e 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -97,7 +97,7 @@ static const char default_path_httpd_conf[] = "/etc"; | |||
97 | static const char httpd_conf[] = "httpd.conf"; | 97 | static const char httpd_conf[] = "httpd.conf"; |
98 | static const char home[] = "./"; | 98 | static const char home[] = "./"; |
99 | 99 | ||
100 | #ifdef CONFIG_LFS | 100 | #if ENABLE_LFS |
101 | # define cont_l_fmt "%lld" | 101 | # define cont_l_fmt "%lld" |
102 | # define cont_l_type (long long) | 102 | # define cont_l_type (long long) |
103 | #else | 103 | #else |
@@ -146,7 +146,7 @@ typedef struct { | |||
146 | const char *configFile; | 146 | const char *configFile; |
147 | 147 | ||
148 | unsigned int rmt_ip; | 148 | unsigned int rmt_ip; |
149 | #if defined(CONFIG_FEATURE_HTTPD_CGI) || DEBUG | 149 | #if ENABLE_FEATURE_HTTPD_CGI || DEBUG |
150 | char rmt_ip_str[16]; /* for set env REMOTE_ADDR */ | 150 | char rmt_ip_str[16]; /* for set env REMOTE_ADDR */ |
151 | #endif | 151 | #endif |
152 | unsigned port; /* server initial port and for | 152 | unsigned port; /* server initial port and for |
@@ -161,14 +161,14 @@ typedef struct { | |||
161 | 161 | ||
162 | Htaccess_IP *ip_a_d; /* config allow/deny lines */ | 162 | Htaccess_IP *ip_a_d; /* config allow/deny lines */ |
163 | int flg_deny_all; | 163 | int flg_deny_all; |
164 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 164 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
165 | Htaccess *auth; /* config user:password lines */ | 165 | Htaccess *auth; /* config user:password lines */ |
166 | #endif | 166 | #endif |
167 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | 167 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES |
168 | Htaccess *mime_a; /* config mime types */ | 168 | Htaccess *mime_a; /* config mime types */ |
169 | #endif | 169 | #endif |
170 | 170 | ||
171 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 171 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
172 | int accepted_socket; | 172 | int accepted_socket; |
173 | # define a_c_r config->accepted_socket | 173 | # define a_c_r config->accepted_socket |
174 | # define a_c_w config->accepted_socket | 174 | # define a_c_w config->accepted_socket |
@@ -178,7 +178,7 @@ typedef struct { | |||
178 | #endif | 178 | #endif |
179 | volatile int alarm_signaled; | 179 | volatile int alarm_signaled; |
180 | 180 | ||
181 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 181 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
182 | Htaccess *script_i; /* config script interpreters */ | 182 | Htaccess *script_i; /* config script interpreters */ |
183 | #endif | 183 | #endif |
184 | } HttpdConfig; | 184 | } HttpdConfig; |
@@ -209,8 +209,7 @@ static const char* const suffixTable [] = { | |||
209 | 0, "application/octet-stream" /* default */ | 209 | 0, "application/octet-stream" /* default */ |
210 | }; | 210 | }; |
211 | 211 | ||
212 | typedef enum | 212 | typedef enum { |
213 | { | ||
214 | HTTP_OK = 200, | 213 | HTTP_OK = 200, |
215 | HTTP_MOVED_TEMPORARILY = 302, | 214 | HTTP_MOVED_TEMPORARILY = 302, |
216 | HTTP_BAD_REQUEST = 400, /* malformed syntax */ | 215 | HTTP_BAD_REQUEST = 400, /* malformed syntax */ |
@@ -237,8 +236,7 @@ typedef enum | |||
237 | #endif | 236 | #endif |
238 | } HttpResponseNum; | 237 | } HttpResponseNum; |
239 | 238 | ||
240 | typedef struct | 239 | typedef struct { |
241 | { | ||
242 | HttpResponseNum type; | 240 | HttpResponseNum type; |
243 | const char *name; | 241 | const char *name; |
244 | const char *info; | 242 | const char *info; |
@@ -251,7 +249,7 @@ static const HttpEnumString httpResponseNames[] = { | |||
251 | "No request appeared within a reasonable time period." }, | 249 | "No request appeared within a reasonable time period." }, |
252 | { HTTP_NOT_IMPLEMENTED, "Not Implemented", | 250 | { HTTP_NOT_IMPLEMENTED, "Not Implemented", |
253 | "The requested method is not recognized by this server." }, | 251 | "The requested method is not recognized by this server." }, |
254 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 252 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
255 | { HTTP_UNAUTHORIZED, "Unauthorized", "" }, | 253 | { HTTP_UNAUTHORIZED, "Unauthorized", "" }, |
256 | #endif | 254 | #endif |
257 | { HTTP_NOT_FOUND, "Not Found", | 255 | { HTTP_NOT_FOUND, "Not Found", |
@@ -277,8 +275,7 @@ static const char RFC1123FMT[] = "%a, %d %b %Y %H:%M:%S GMT"; | |||
277 | static const char Content_length[] = "Content-length:"; | 275 | static const char Content_length[] = "Content-length:"; |
278 | 276 | ||
279 | 277 | ||
280 | static int | 278 | static int scan_ip(const char **ep, unsigned int *ip, unsigned char endc) |
281 | scan_ip (const char **ep, unsigned int *ip, unsigned char endc) | ||
282 | { | 279 | { |
283 | const char *p = *ep; | 280 | const char *p = *ep; |
284 | int auto_mask = 8; | 281 | int auto_mask = 8; |
@@ -315,8 +312,7 @@ scan_ip (const char **ep, unsigned int *ip, unsigned char endc) | |||
315 | return auto_mask; | 312 | return auto_mask; |
316 | } | 313 | } |
317 | 314 | ||
318 | static int | 315 | static int scan_ip_mask(const char *ipm, unsigned int *ip, unsigned int *mask) |
319 | scan_ip_mask (const char *ipm, unsigned int *ip, unsigned int *mask) | ||
320 | { | 316 | { |
321 | int i; | 317 | int i; |
322 | unsigned int msk; | 318 | unsigned int msk; |
@@ -331,7 +327,7 @@ scan_ip_mask (const char *ipm, unsigned int *ip, unsigned int *mask) | |||
331 | while (*p) { | 327 | while (*p) { |
332 | if (*p < '0' || *p > '9') { | 328 | if (*p < '0' || *p > '9') { |
333 | if (*p == '.') { | 329 | if (*p == '.') { |
334 | i = scan_ip (&ipm, mask, 0); | 330 | i = scan_ip(&ipm, mask, 0); |
335 | return i != 32; | 331 | return i != 32; |
336 | } | 332 | } |
337 | return -1; | 333 | return -1; |
@@ -353,7 +349,7 @@ scan_ip_mask (const char *ipm, unsigned int *ip, unsigned int *mask) | |||
353 | return 0; | 349 | return 0; |
354 | } | 350 | } |
355 | 351 | ||
356 | #if defined(CONFIG_FEATURE_HTTPD_BASIC_AUTH) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES) | 352 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES |
357 | static void free_config_lines(Htaccess **pprev) | 353 | static void free_config_lines(Htaccess **pprev) |
358 | { | 354 | { |
359 | Htaccess *prev = *pprev; | 355 | Htaccess *prev = *pprev; |
@@ -401,7 +397,7 @@ static void free_config_lines(Htaccess **pprev) | |||
401 | static void parse_conf(const char *path, int flag) | 397 | static void parse_conf(const char *path, int flag) |
402 | { | 398 | { |
403 | FILE *f; | 399 | FILE *f; |
404 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 400 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
405 | Htaccess *prev, *cur; | 401 | Htaccess *prev, *cur; |
406 | #elif CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | 402 | #elif CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES |
407 | Htaccess *cur; | 403 | Htaccess *cur; |
@@ -425,16 +421,16 @@ static void parse_conf(const char *path, int flag) | |||
425 | 421 | ||
426 | config->flg_deny_all = 0; | 422 | config->flg_deny_all = 0; |
427 | 423 | ||
428 | #if defined(CONFIG_FEATURE_HTTPD_BASIC_AUTH) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR) | 424 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
429 | /* retain previous auth and mime config only for subdir parse */ | 425 | /* retain previous auth and mime config only for subdir parse */ |
430 | if (flag != SUBDIR_PARSE) { | 426 | if (flag != SUBDIR_PARSE) { |
431 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 427 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
432 | free_config_lines(&config->auth); | 428 | free_config_lines(&config->auth); |
433 | #endif | 429 | #endif |
434 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | 430 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES |
435 | free_config_lines(&config->mime_a); | 431 | free_config_lines(&config->mime_a); |
436 | #endif | 432 | #endif |
437 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 433 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
438 | free_config_lines(&config->script_i); | 434 | free_config_lines(&config->script_i); |
439 | #endif | 435 | #endif |
440 | } | 436 | } |
@@ -461,11 +457,11 @@ static void parse_conf(const char *path, int flag) | |||
461 | cf = httpd_conf; | 457 | cf = httpd_conf; |
462 | } | 458 | } |
463 | 459 | ||
464 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 460 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
465 | prev = config->auth; | 461 | prev = config->auth; |
466 | #endif | 462 | #endif |
467 | /* This could stand some work */ | 463 | /* This could stand some work */ |
468 | while ( (p0 = fgets(buf, sizeof(buf), f)) != NULL) { | 464 | while ((p0 = fgets(buf, sizeof(buf), f)) != NULL) { |
469 | c = NULL; | 465 | c = NULL; |
470 | for (p = p0; *p0 != 0 && *p0 != '#'; p0++) { | 466 | for (p = p0; *p0 != 0 && *p0 != '#'; p0++) { |
471 | if (!isspace(*p0)) { | 467 | if (!isspace(*p0)) { |
@@ -494,13 +490,13 @@ static void parse_conf(const char *path, int flag) | |||
494 | if (*p0 == 'a') | 490 | if (*p0 == 'a') |
495 | *p0 = 'A'; | 491 | *p0 = 'A'; |
496 | else if (*p0 != 'D' && *p0 != 'A' | 492 | else if (*p0 != 'D' && *p0 != 'A' |
497 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 493 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
498 | && *p0 != '/' | 494 | && *p0 != '/' |
499 | #endif | 495 | #endif |
500 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | 496 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES |
501 | && *p0 != '.' | 497 | && *p0 != '.' |
502 | #endif | 498 | #endif |
503 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 499 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
504 | && *p0 != '*' | 500 | && *p0 != '*' |
505 | #endif | 501 | #endif |
506 | ) | 502 | ) |
@@ -509,7 +505,7 @@ static void parse_conf(const char *path, int flag) | |||
509 | /* storing current config IP line */ | 505 | /* storing current config IP line */ |
510 | pip = calloc(1, sizeof(Htaccess_IP)); | 506 | pip = calloc(1, sizeof(Htaccess_IP)); |
511 | if (pip) { | 507 | if (pip) { |
512 | if (scan_ip_mask (c, &(pip->ip), &(pip->mask))) { | 508 | if (scan_ip_mask(c, &(pip->ip), &(pip->mask))) { |
513 | /* syntax IP{/mask} error detected, protect all */ | 509 | /* syntax IP{/mask} error detected, protect all */ |
514 | *p0 = 'D'; | 510 | *p0 = 'D'; |
515 | pip->mask = 0; | 511 | pip->mask = 0; |
@@ -534,7 +530,7 @@ static void parse_conf(const char *path, int flag) | |||
534 | } | 530 | } |
535 | continue; | 531 | continue; |
536 | } | 532 | } |
537 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 533 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
538 | if (*p0 == '/') { | 534 | if (*p0 == '/') { |
539 | /* make full path from httpd root / curent_path / config_line_path */ | 535 | /* make full path from httpd root / curent_path / config_line_path */ |
540 | cf = flag == SUBDIR_PARSE ? path : ""; | 536 | cf = flag == SUBDIR_PARSE ? path : ""; |
@@ -574,7 +570,7 @@ static void parse_conf(const char *path, int flag) | |||
574 | } | 570 | } |
575 | #endif | 571 | #endif |
576 | 572 | ||
577 | #if defined(CONFIG_FEATURE_HTTPD_BASIC_AUTH) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR) | 573 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
578 | /* storing current config line */ | 574 | /* storing current config line */ |
579 | cur = calloc(1, sizeof(Htaccess) + strlen(p0)); | 575 | cur = calloc(1, sizeof(Htaccess) + strlen(p0)); |
580 | if (cur) { | 576 | if (cur) { |
@@ -582,7 +578,7 @@ static void parse_conf(const char *path, int flag) | |||
582 | c = strchr(cf, ':'); | 578 | c = strchr(cf, ':'); |
583 | *c++ = 0; | 579 | *c++ = 0; |
584 | cur->after_colon = c; | 580 | cur->after_colon = c; |
585 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | 581 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES |
586 | if (*cf == '.') { | 582 | if (*cf == '.') { |
587 | /* config .mime line move top for overwrite previous */ | 583 | /* config .mime line move top for overwrite previous */ |
588 | cur->next = config->mime_a; | 584 | cur->next = config->mime_a; |
@@ -590,7 +586,7 @@ static void parse_conf(const char *path, int flag) | |||
590 | continue; | 586 | continue; |
591 | } | 587 | } |
592 | #endif | 588 | #endif |
593 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 589 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
594 | if (*cf == '*' && cf[1] == '.') { | 590 | if (*cf == '*' && cf[1] == '.') { |
595 | /* config script interpreter line move top for overwrite previous */ | 591 | /* config script interpreter line move top for overwrite previous */ |
596 | cur->next = config->script_i; | 592 | cur->next = config->script_i; |
@@ -598,7 +594,7 @@ static void parse_conf(const char *path, int flag) | |||
598 | continue; | 594 | continue; |
599 | } | 595 | } |
600 | #endif | 596 | #endif |
601 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 597 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
602 | free(p0); | 598 | free(p0); |
603 | if (prev == NULL) { | 599 | if (prev == NULL) { |
604 | /* first line */ | 600 | /* first line */ |
@@ -636,7 +632,7 @@ static void parse_conf(const char *path, int flag) | |||
636 | fclose(f); | 632 | fclose(f); |
637 | } | 633 | } |
638 | 634 | ||
639 | #ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR | 635 | #if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR |
640 | /**************************************************************************** | 636 | /**************************************************************************** |
641 | * | 637 | * |
642 | > $Function: encodeString() | 638 | > $Function: encodeString() |
@@ -725,7 +721,7 @@ static char *decodeString(char *orig, int flag_plus_to_space) | |||
725 | } | 721 | } |
726 | 722 | ||
727 | 723 | ||
728 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 724 | #if ENABLE_FEATURE_HTTPD_CGI |
729 | /**************************************************************************** | 725 | /**************************************************************************** |
730 | * | 726 | * |
731 | > $Function: addEnv() | 727 | > $Function: addEnv() |
@@ -745,7 +741,7 @@ static char *decodeString(char *orig, int flag_plus_to_space) | |||
745 | * | 741 | * |
746 | ****************************************************************************/ | 742 | ****************************************************************************/ |
747 | static void addEnv(const char *name_before_underline, | 743 | static void addEnv(const char *name_before_underline, |
748 | const char *name_after_underline, const char *value) | 744 | const char *name_after_underline, const char *value) |
749 | { | 745 | { |
750 | char *s = NULL; | 746 | char *s = NULL; |
751 | const char *underline; | 747 | const char *underline; |
@@ -760,7 +756,7 @@ static void addEnv(const char *name_before_underline, | |||
760 | } | 756 | } |
761 | } | 757 | } |
762 | 758 | ||
763 | #if defined(CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV) || defined(CONFIG_FEATURE_HTTPD_WITHOUT_INETD) | 759 | #if ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV || ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
764 | /* set environs SERVER_PORT and REMOTE_PORT */ | 760 | /* set environs SERVER_PORT and REMOTE_PORT */ |
765 | static void addEnvPort(const char *port_name) | 761 | static void addEnvPort(const char *port_name) |
766 | { | 762 | { |
@@ -773,7 +769,7 @@ static void addEnvPort(const char *port_name) | |||
773 | #endif /* CONFIG_FEATURE_HTTPD_CGI */ | 769 | #endif /* CONFIG_FEATURE_HTTPD_CGI */ |
774 | 770 | ||
775 | 771 | ||
776 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 772 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
777 | /**************************************************************************** | 773 | /**************************************************************************** |
778 | * | 774 | * |
779 | > $Function: decodeBase64() | 775 | > $Function: decodeBase64() |
@@ -832,7 +828,7 @@ static void decodeBase64(char *Data) | |||
832 | #endif | 828 | #endif |
833 | 829 | ||
834 | 830 | ||
835 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 831 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
836 | /**************************************************************************** | 832 | /**************************************************************************** |
837 | * | 833 | * |
838 | > $Function: openServer() | 834 | > $Function: openServer() |
@@ -860,9 +856,9 @@ static int openServer(void) | |||
860 | /* tell the OS it's OK to reuse a previous address even though */ | 856 | /* tell the OS it's OK to reuse a previous address even though */ |
861 | /* it may still be in a close down state. Allows bind to succeed. */ | 857 | /* it may still be in a close down state. Allows bind to succeed. */ |
862 | #ifdef SO_REUSEPORT | 858 | #ifdef SO_REUSEPORT |
863 | setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ; | 859 | setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)); |
864 | #else | 860 | #else |
865 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ; | 861 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)); |
866 | #endif | 862 | #endif |
867 | xbind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)); | 863 | xbind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)); |
868 | xlisten(fd, 9); | 864 | xlisten(fd, 9); |
@@ -916,7 +912,7 @@ static int sendHeaders(HttpResponseNum responseNum) | |||
916 | "Date: %s\r\nConnection: close\r\n", | 912 | "Date: %s\r\nConnection: close\r\n", |
917 | responseNum, responseString, mime_type, timeStr); | 913 | responseNum, responseString, mime_type, timeStr); |
918 | 914 | ||
919 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 915 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
920 | if (responseNum == HTTP_UNAUTHORIZED) { | 916 | if (responseNum == HTTP_UNAUTHORIZED) { |
921 | len += sprintf(buf+len, "WWW-Authenticate: Basic realm=\"%s\"\r\n", | 917 | len += sprintf(buf+len, "WWW-Authenticate: Basic realm=\"%s\"\r\n", |
922 | config->realm); | 918 | config->realm); |
@@ -978,7 +974,7 @@ static int getLine(void) | |||
978 | else return -1; | 974 | else return -1; |
979 | } | 975 | } |
980 | 976 | ||
981 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 977 | #if ENABLE_FEATURE_HTTPD_CGI |
982 | /**************************************************************************** | 978 | /**************************************************************************** |
983 | * | 979 | * |
984 | > $Function: sendCgi() | 980 | > $Function: sendCgi() |
@@ -1091,7 +1087,7 @@ static int sendCgi(const char *url, | |||
1091 | addEnv("SERVER", "PROTOCOL", "HTTP/1.0"); | 1087 | addEnv("SERVER", "PROTOCOL", "HTTP/1.0"); |
1092 | addEnv("GATEWAY_INTERFACE", "", "CGI/1.1"); | 1088 | addEnv("GATEWAY_INTERFACE", "", "CGI/1.1"); |
1093 | addEnv("REMOTE", "ADDR", config->rmt_ip_str); | 1089 | addEnv("REMOTE", "ADDR", config->rmt_ip_str); |
1094 | #ifdef CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV | 1090 | #if ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV |
1095 | addEnvPort("REMOTE"); | 1091 | addEnvPort("REMOTE"); |
1096 | #endif | 1092 | #endif |
1097 | if (bodyLen) { | 1093 | if (bodyLen) { |
@@ -1104,7 +1100,7 @@ static int sendCgi(const char *url, | |||
1104 | addEnv("HTTP", "COOKIE", cookie); | 1100 | addEnv("HTTP", "COOKIE", cookie); |
1105 | if (content_type) | 1101 | if (content_type) |
1106 | addEnv("CONTENT", "TYPE", content_type); | 1102 | addEnv("CONTENT", "TYPE", content_type); |
1107 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1103 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1108 | if (config->remoteuser) { | 1104 | if (config->remoteuser) { |
1109 | addEnv("REMOTE", "USER", config->remoteuser); | 1105 | addEnv("REMOTE", "USER", config->remoteuser); |
1110 | addEnv("AUTH_TYPE", "", "Basic"); | 1106 | addEnv("AUTH_TYPE", "", "Basic"); |
@@ -1124,7 +1120,7 @@ static int sendCgi(const char *url, | |||
1124 | // now run the program. If it fails, | 1120 | // now run the program. If it fails, |
1125 | // use _exit() so no destructors | 1121 | // use _exit() so no destructors |
1126 | // get called and make a mess. | 1122 | // get called and make a mess. |
1127 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 1123 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
1128 | char *interpr = NULL; | 1124 | char *interpr = NULL; |
1129 | char *suffix = strrchr(purl, '.'); | 1125 | char *suffix = strrchr(purl, '.'); |
1130 | 1126 | ||
@@ -1138,7 +1134,7 @@ static int sendCgi(const char *url, | |||
1138 | } | 1134 | } |
1139 | #endif | 1135 | #endif |
1140 | *script = '/'; | 1136 | *script = '/'; |
1141 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 1137 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
1142 | if (interpr) | 1138 | if (interpr) |
1143 | execv(interpr, argp); | 1139 | execv(interpr, argp); |
1144 | else | 1140 | else |
@@ -1147,7 +1143,7 @@ static int sendCgi(const char *url, | |||
1147 | } | 1143 | } |
1148 | } | 1144 | } |
1149 | } | 1145 | } |
1150 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1146 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1151 | config->accepted_socket = 1; /* send to stdout */ | 1147 | config->accepted_socket = 1; /* send to stdout */ |
1152 | #endif | 1148 | #endif |
1153 | sendHeaders(HTTP_NOT_FOUND); | 1149 | sendHeaders(HTTP_NOT_FOUND); |
@@ -1298,7 +1294,7 @@ static int sendFile(const char *url) | |||
1298 | } | 1294 | } |
1299 | /* also, if not found, set default as "application/octet-stream"; */ | 1295 | /* also, if not found, set default as "application/octet-stream"; */ |
1300 | config->httpd_found.found_mime_type = *(table+1); | 1296 | config->httpd_found.found_mime_type = *(table+1); |
1301 | #ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | 1297 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES |
1302 | if (suffix) { | 1298 | if (suffix) { |
1303 | Htaccess * cur; | 1299 | Htaccess * cur; |
1304 | 1300 | ||
@@ -1380,7 +1376,7 @@ static int checkPermIP(void) | |||
1380 | * | 1376 | * |
1381 | ****************************************************************************/ | 1377 | ****************************************************************************/ |
1382 | 1378 | ||
1383 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1379 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1384 | static int checkPerm(const char *path, const char *request) | 1380 | static int checkPerm(const char *path, const char *request) |
1385 | { | 1381 | { |
1386 | Htaccess * cur; | 1382 | Htaccess * cur; |
@@ -1396,7 +1392,7 @@ static int checkPerm(const char *path, const char *request) | |||
1396 | continue; /* find next identical */ | 1392 | continue; /* find next identical */ |
1397 | p = cur->after_colon; | 1393 | p = cur->after_colon; |
1398 | #if DEBUG | 1394 | #if DEBUG |
1399 | fprintf(stderr,"checkPerm: '%s' ? '%s'\n", p0, request); | 1395 | fprintf(stderr, "checkPerm: '%s' ? '%s'\n", p0, request); |
1400 | #endif | 1396 | #endif |
1401 | { | 1397 | { |
1402 | size_t l = strlen(p0); | 1398 | size_t l = strlen(p0); |
@@ -1413,7 +1409,7 @@ static int checkPerm(const char *path, const char *request) | |||
1413 | break; | 1409 | break; |
1414 | } | 1410 | } |
1415 | 1411 | ||
1416 | #ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5 | 1412 | #if ENABLE_FEATURE_HTTPD_AUTH_MD5 |
1417 | { | 1413 | { |
1418 | char *cipher; | 1414 | char *cipher; |
1419 | char *pp; | 1415 | char *pp; |
@@ -1435,7 +1431,7 @@ static int checkPerm(const char *path, const char *request) | |||
1435 | } | 1431 | } |
1436 | #endif | 1432 | #endif |
1437 | if (strcmp(p, request) == 0) { | 1433 | if (strcmp(p, request) == 0) { |
1438 | #ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5 | 1434 | #if ENABLE_FEATURE_HTTPD_AUTH_MD5 |
1439 | set_remoteuser_var: | 1435 | set_remoteuser_var: |
1440 | #endif | 1436 | #endif |
1441 | config->remoteuser = strdup(request); | 1437 | config->remoteuser = strdup(request); |
@@ -1483,7 +1479,7 @@ static void handleIncoming(void) | |||
1483 | char *test; | 1479 | char *test; |
1484 | struct stat sb; | 1480 | struct stat sb; |
1485 | int ip_allowed; | 1481 | int ip_allowed; |
1486 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1482 | #if ENABLE_FEATURE_HTTPD_CGI |
1487 | const char *prequest = request_GET; | 1483 | const char *prequest = request_GET; |
1488 | long length=0; | 1484 | long length=0; |
1489 | char *cookie = 0; | 1485 | char *cookie = 0; |
@@ -1494,7 +1490,7 @@ static void handleIncoming(void) | |||
1494 | int retval; | 1490 | int retval; |
1495 | struct sigaction sa; | 1491 | struct sigaction sa; |
1496 | 1492 | ||
1497 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1493 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1498 | int credentials = -1; /* if not requred this is Ok */ | 1494 | int credentials = -1; /* if not requred this is Ok */ |
1499 | #endif | 1495 | #endif |
1500 | 1496 | ||
@@ -1517,7 +1513,7 @@ BAD_REQUEST: | |||
1517 | break; | 1513 | break; |
1518 | } | 1514 | } |
1519 | *purl = 0; | 1515 | *purl = 0; |
1520 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1516 | #if ENABLE_FEATURE_HTTPD_CGI |
1521 | if (strcasecmp(buf, prequest) != 0) { | 1517 | if (strcasecmp(buf, prequest) != 0) { |
1522 | prequest = "POST"; | 1518 | prequest = "POST"; |
1523 | if (strcasecmp(buf, prequest) != 0) { | 1519 | if (strcasecmp(buf, prequest) != 0) { |
@@ -1559,7 +1555,7 @@ BAD_REQUEST: | |||
1559 | break; | 1555 | break; |
1560 | } | 1556 | } |
1561 | /* algorithm stolen from libbb bb_simplify_path(), | 1557 | /* algorithm stolen from libbb bb_simplify_path(), |
1562 | but don`t strdup and reducing trailing slash and protect out root */ | 1558 | but don't strdup and reducing trailing slash and protect out root */ |
1563 | purl = test = url; | 1559 | purl = test = url; |
1564 | 1560 | ||
1565 | do { | 1561 | do { |
@@ -1620,7 +1616,7 @@ BAD_REQUEST: | |||
1620 | fprintf(stderr, "Header: '%s'\n", buf); | 1616 | fprintf(stderr, "Header: '%s'\n", buf); |
1621 | #endif | 1617 | #endif |
1622 | 1618 | ||
1623 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1619 | #if ENABLE_FEATURE_HTTPD_CGI |
1624 | /* try and do our best to parse more lines */ | 1620 | /* try and do our best to parse more lines */ |
1625 | if ((strncasecmp(buf, Content_length, 15) == 0)) { | 1621 | if ((strncasecmp(buf, Content_length, 15) == 0)) { |
1626 | if (prequest != request_GET) | 1622 | if (prequest != request_GET) |
@@ -1640,7 +1636,7 @@ BAD_REQUEST: | |||
1640 | } | 1636 | } |
1641 | #endif | 1637 | #endif |
1642 | 1638 | ||
1643 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1639 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1644 | if (strncasecmp(buf, "Authorization:", 14) == 0) { | 1640 | if (strncasecmp(buf, "Authorization:", 14) == 0) { |
1645 | /* We only allow Basic credentials. | 1641 | /* We only allow Basic credentials. |
1646 | * It shows up as "Authorization: Basic <userid:password>" where | 1642 | * It shows up as "Authorization: Basic <userid:password>" where |
@@ -1665,14 +1661,14 @@ BAD_REQUEST: | |||
1665 | 1661 | ||
1666 | if (strcmp(strrchr(url, '/') + 1, httpd_conf) == 0 || ip_allowed == 0) { | 1662 | if (strcmp(strrchr(url, '/') + 1, httpd_conf) == 0 || ip_allowed == 0) { |
1667 | /* protect listing [/path]/httpd_conf or IP deny */ | 1663 | /* protect listing [/path]/httpd_conf or IP deny */ |
1668 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1664 | #if ENABLE_FEATURE_HTTPD_CGI |
1669 | FORBIDDEN: /* protect listing /cgi-bin */ | 1665 | FORBIDDEN: /* protect listing /cgi-bin */ |
1670 | #endif | 1666 | #endif |
1671 | sendHeaders(HTTP_FORBIDDEN); | 1667 | sendHeaders(HTTP_FORBIDDEN); |
1672 | break; | 1668 | break; |
1673 | } | 1669 | } |
1674 | 1670 | ||
1675 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1671 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1676 | if (credentials <= 0 && checkPerm(url, ":") == 0) { | 1672 | if (credentials <= 0 && checkPerm(url, ":") == 0) { |
1677 | sendHeaders(HTTP_UNAUTHORIZED); | 1673 | sendHeaders(HTTP_UNAUTHORIZED); |
1678 | break; | 1674 | break; |
@@ -1690,7 +1686,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1690 | 1686 | ||
1691 | test = url + 1; /* skip first '/' */ | 1687 | test = url + 1; /* skip first '/' */ |
1692 | 1688 | ||
1693 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1689 | #if ENABLE_FEATURE_HTTPD_CGI |
1694 | /* if strange Content-Length */ | 1690 | /* if strange Content-Length */ |
1695 | if (length < 0) | 1691 | if (length < 0) |
1696 | break; | 1692 | break; |
@@ -1711,12 +1707,12 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1711 | config->last_mod = sb.st_mtime; | 1707 | config->last_mod = sb.st_mtime; |
1712 | } | 1708 | } |
1713 | sendFile(test); | 1709 | sendFile(test); |
1714 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1710 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1715 | /* unset if non inetd looped */ | 1711 | /* unset if non inetd looped */ |
1716 | config->ContentLength = -1; | 1712 | config->ContentLength = -1; |
1717 | #endif | 1713 | #endif |
1718 | 1714 | ||
1719 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1715 | #if ENABLE_FEATURE_HTTPD_CGI |
1720 | } | 1716 | } |
1721 | } | 1717 | } |
1722 | #endif | 1718 | #endif |
@@ -1724,8 +1720,8 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1724 | } while (0); | 1720 | } while (0); |
1725 | 1721 | ||
1726 | 1722 | ||
1727 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1723 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1728 | /* from inetd don`t looping: freeing, closing automatic from exit always */ | 1724 | /* from inetd don't looping: freeing, closing automatic from exit always */ |
1729 | # if DEBUG | 1725 | # if DEBUG |
1730 | fprintf(stderr, "closing socket\n"); | 1726 | fprintf(stderr, "closing socket\n"); |
1731 | # endif | 1727 | # endif |
@@ -1733,7 +1729,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1733 | free(cookie); | 1729 | free(cookie); |
1734 | free(content_type); | 1730 | free(content_type); |
1735 | free(config->referer); | 1731 | free(config->referer); |
1736 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1732 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1737 | free(config->remoteuser); | 1733 | free(config->remoteuser); |
1738 | #endif | 1734 | #endif |
1739 | # endif | 1735 | # endif |
@@ -1741,17 +1737,17 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1741 | shutdown(a_c_w, SHUT_WR); | 1737 | shutdown(a_c_w, SHUT_WR); |
1742 | 1738 | ||
1743 | /* Properly wait for remote to closed */ | 1739 | /* Properly wait for remote to closed */ |
1744 | FD_ZERO (&s_fd) ; | 1740 | FD_ZERO(&s_fd); |
1745 | FD_SET (a_c_r, &s_fd) ; | 1741 | FD_SET(a_c_r, &s_fd); |
1746 | 1742 | ||
1747 | do { | 1743 | do { |
1748 | tv.tv_sec = 2 ; | 1744 | tv.tv_sec = 2; |
1749 | tv.tv_usec = 0 ; | 1745 | tv.tv_usec = 0; |
1750 | retval = select (a_c_r + 1, &s_fd, NULL, NULL, &tv); | 1746 | retval = select(a_c_r + 1, &s_fd, NULL, NULL, &tv); |
1751 | } while (retval > 0 && (read (a_c_r, buf, sizeof (config->buf)) > 0)); | 1747 | } while (retval > 0 && read(a_c_r, buf, sizeof(config->buf) > 0)); |
1752 | 1748 | ||
1753 | shutdown(a_c_r, SHUT_RD); | 1749 | shutdown(a_c_r, SHUT_RD); |
1754 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1750 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1755 | close(config->accepted_socket); | 1751 | close(config->accepted_socket); |
1756 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ | 1752 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ |
1757 | } | 1753 | } |
@@ -1771,7 +1767,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1771 | * $Return: (int) . . . . Always 0. | 1767 | * $Return: (int) . . . . Always 0. |
1772 | * | 1768 | * |
1773 | ****************************************************************************/ | 1769 | ****************************************************************************/ |
1774 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1770 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1775 | static int miniHttpd(int server) | 1771 | static int miniHttpd(int server) |
1776 | { | 1772 | { |
1777 | fd_set readfd, portfd; | 1773 | fd_set readfd, portfd; |
@@ -1798,7 +1794,7 @@ static int miniHttpd(int server) | |||
1798 | } | 1794 | } |
1799 | config->accepted_socket = s; | 1795 | config->accepted_socket = s; |
1800 | config->rmt_ip = ntohl(fromAddr.sin_addr.s_addr); | 1796 | config->rmt_ip = ntohl(fromAddr.sin_addr.s_addr); |
1801 | #if defined(CONFIG_FEATURE_HTTPD_CGI) || DEBUG | 1797 | #if ENABLE_FEATURE_HTTPD_CGI || DEBUG |
1802 | sprintf(config->rmt_ip_str, "%u.%u.%u.%u", | 1798 | sprintf(config->rmt_ip_str, "%u.%u.%u.%u", |
1803 | (unsigned char)(config->rmt_ip >> 24), | 1799 | (unsigned char)(config->rmt_ip >> 24), |
1804 | (unsigned char)(config->rmt_ip >> 16), | 1800 | (unsigned char)(config->rmt_ip >> 16), |
@@ -1813,14 +1809,14 @@ static int miniHttpd(int server) | |||
1813 | 1809 | ||
1814 | /* set the KEEPALIVE option to cull dead connections */ | 1810 | /* set the KEEPALIVE option to cull dead connections */ |
1815 | on = 1; | 1811 | on = 1; |
1816 | setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof (on)); | 1812 | setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on)); |
1817 | 1813 | ||
1818 | #if !DEBUG | 1814 | #if !DEBUG |
1819 | if (fork() == 0) | 1815 | if (fork() == 0) |
1820 | #endif | 1816 | #endif |
1821 | { | 1817 | { |
1822 | /* This is the spawned thread */ | 1818 | /* This is the spawned thread */ |
1823 | #ifdef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | 1819 | #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP |
1824 | /* protect reload config, may be confuse checking */ | 1820 | /* protect reload config, may be confuse checking */ |
1825 | signal(SIGHUP, SIG_IGN); | 1821 | signal(SIGHUP, SIG_IGN); |
1826 | #endif | 1822 | #endif |
@@ -1842,11 +1838,11 @@ static int miniHttpd(int server) | |||
1842 | static int miniHttpd(void) | 1838 | static int miniHttpd(void) |
1843 | { | 1839 | { |
1844 | struct sockaddr_in fromAddrLen; | 1840 | struct sockaddr_in fromAddrLen; |
1845 | socklen_t sinlen = sizeof (struct sockaddr_in); | 1841 | socklen_t sinlen = sizeof(struct sockaddr_in); |
1846 | 1842 | ||
1847 | getpeername (0, (struct sockaddr *)&fromAddrLen, &sinlen); | 1843 | getpeername(0, (struct sockaddr *)&fromAddrLen, &sinlen); |
1848 | config->rmt_ip = ntohl(fromAddrLen.sin_addr.s_addr); | 1844 | config->rmt_ip = ntohl(fromAddrLen.sin_addr.s_addr); |
1849 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1845 | #if ENABLE_FEATURE_HTTPD_CGI |
1850 | sprintf(config->rmt_ip_str, "%u.%u.%u.%u", | 1846 | sprintf(config->rmt_ip_str, "%u.%u.%u.%u", |
1851 | (unsigned char)(config->rmt_ip >> 24), | 1847 | (unsigned char)(config->rmt_ip >> 24), |
1852 | (unsigned char)(config->rmt_ip >> 16), | 1848 | (unsigned char)(config->rmt_ip >> 16), |
@@ -1859,7 +1855,7 @@ static int miniHttpd(void) | |||
1859 | } | 1855 | } |
1860 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ | 1856 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ |
1861 | 1857 | ||
1862 | #ifdef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | 1858 | #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP |
1863 | static void sighup_handler(int sig) | 1859 | static void sighup_handler(int sig) |
1864 | { | 1860 | { |
1865 | /* set and reset */ | 1861 | /* set and reset */ |
@@ -1884,7 +1880,7 @@ enum httpd_opts_nums { | |||
1884 | USE_FEATURE_HTTPD_WITHOUT_INETD(p_opt_port,) | 1880 | USE_FEATURE_HTTPD_WITHOUT_INETD(p_opt_port,) |
1885 | }; | 1881 | }; |
1886 | 1882 | ||
1887 | static const char httpd_opts[]="c:d:h:" | 1883 | static const char httpd_opts[] = "c:d:h:" |
1888 | USE_FEATURE_HTTPD_ENCODE_URL_STR("e:") | 1884 | USE_FEATURE_HTTPD_ENCODE_URL_STR("e:") |
1889 | USE_FEATURE_HTTPD_BASIC_AUTH("r:") | 1885 | USE_FEATURE_HTTPD_BASIC_AUTH("r:") |
1890 | USE_FEATURE_HTTPD_AUTH_MD5("m:") | 1886 | USE_FEATURE_HTTPD_AUTH_MD5("m:") |
@@ -1926,11 +1922,11 @@ int httpd_main(int argc, char *argv[]) | |||
1926 | USE_FEATURE_HTTPD_AUTH_MD5(const char *pass;) | 1922 | USE_FEATURE_HTTPD_AUTH_MD5(const char *pass;) |
1927 | 1923 | ||
1928 | config = xzalloc(sizeof(*config)); | 1924 | config = xzalloc(sizeof(*config)); |
1929 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1925 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1930 | config->realm = "Web Server Authentication"; | 1926 | config->realm = "Web Server Authentication"; |
1931 | #endif | 1927 | #endif |
1932 | 1928 | ||
1933 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1929 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1934 | config->port = 80; | 1930 | config->port = 80; |
1935 | #endif | 1931 | #endif |
1936 | 1932 | ||
@@ -1949,22 +1945,22 @@ int httpd_main(int argc, char *argv[]) | |||
1949 | printf("%s", decodeString(url_for_decode, 1)); | 1945 | printf("%s", decodeString(url_for_decode, 1)); |
1950 | return 0; | 1946 | return 0; |
1951 | } | 1947 | } |
1952 | #ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR | 1948 | #if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR |
1953 | if (opt & OPT_ENCODE_URL) { | 1949 | if (opt & OPT_ENCODE_URL) { |
1954 | printf("%s", encodeString(url_for_encode)); | 1950 | printf("%s", encodeString(url_for_encode)); |
1955 | return 0; | 1951 | return 0; |
1956 | } | 1952 | } |
1957 | #endif | 1953 | #endif |
1958 | #ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5 | 1954 | #if ENABLE_FEATURE_HTTPD_AUTH_MD5 |
1959 | if (opt & OPT_MD5) { | 1955 | if (opt & OPT_MD5) { |
1960 | printf("%s\n", pw_encrypt(pass, "$1$")); | 1956 | puts(pw_encrypt(pass, "$1$")); |
1961 | return 0; | 1957 | return 0; |
1962 | } | 1958 | } |
1963 | #endif | 1959 | #endif |
1964 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1960 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1965 | if (opt & OPT_PORT) | 1961 | if (opt & OPT_PORT) |
1966 | config->port = bb_xgetlarg(s_port, 10, 1, 0xffff); | 1962 | config->port = bb_xgetlarg(s_port, 10, 1, 0xffff); |
1967 | #ifdef CONFIG_FEATURE_HTTPD_SETUID | 1963 | #if ENABLE_FEATURE_HTTPD_SETUID |
1968 | if (opt & OPT_SETUID) { | 1964 | if (opt & OPT_SETUID) { |
1969 | char *e; | 1965 | char *e; |
1970 | 1966 | ||
@@ -1978,7 +1974,7 @@ int httpd_main(int argc, char *argv[]) | |||
1978 | #endif | 1974 | #endif |
1979 | 1975 | ||
1980 | xchdir(home_httpd); | 1976 | xchdir(home_httpd); |
1981 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 1977 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
1982 | server = openServer(); | 1978 | server = openServer(); |
1983 | # ifdef CONFIG_FEATURE_HTTPD_SETUID | 1979 | # ifdef CONFIG_FEATURE_HTTPD_SETUID |
1984 | /* drop privileges */ | 1980 | /* drop privileges */ |
@@ -1987,7 +1983,7 @@ int httpd_main(int argc, char *argv[]) | |||
1987 | # endif | 1983 | # endif |
1988 | #endif | 1984 | #endif |
1989 | 1985 | ||
1990 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1986 | #if ENABLE_FEATURE_HTTPD_CGI |
1991 | { | 1987 | { |
1992 | char *p = getenv("PATH"); | 1988 | char *p = getenv("PATH"); |
1993 | if (p) { | 1989 | if (p) { |
@@ -2002,15 +1998,15 @@ int httpd_main(int argc, char *argv[]) | |||
2002 | } | 1998 | } |
2003 | #endif | 1999 | #endif |
2004 | 2000 | ||
2005 | #ifdef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | 2001 | #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP |
2006 | sighup_handler(0); | 2002 | sighup_handler(0); |
2007 | #else | 2003 | #else |
2008 | parse_conf(default_path_httpd_conf, FIRST_PARSE); | 2004 | parse_conf(default_path_httpd_conf, FIRST_PARSE); |
2009 | #endif | 2005 | #endif |
2010 | 2006 | ||
2011 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD | 2007 | #if ENABLE_FEATURE_HTTPD_WITHOUT_INETD |
2012 | # if !DEBUG | 2008 | # if !DEBUG |
2013 | xdaemon(1, 0); /* don`t change curent directory */ | 2009 | xdaemon(1, 0); /* don't change curent directory */ |
2014 | # endif | 2010 | # endif |
2015 | return miniHttpd(server); | 2011 | return miniHttpd(server); |
2016 | #else | 2012 | #else |