source:
clfs-embedded/patches/busybox-1.14.1-branch_update-1.patch@
b71d8ca
Last change on this file since b71d8ca was b71d8ca, checked in by , 15 years ago | |
---|---|
|
|
File size: 29.7 KB |
-
coreutils/readlink.c
diff -ru busybox-1.14.1/coreutils/readlink.c busybox-1.14.1-fixed/coreutils/readlink.c
old new 6 6 * 7 7 * Licensed under GPL v2 or later, see file LICENSE in this tarball for details. 8 8 */ 9 10 9 #include "libbb.h" 11 10 11 /* 12 * # readlink --version 13 * readlink (GNU coreutils) 6.10 14 * # readlink --help 15 * -f, --canonicalize 16 * canonicalize by following every symlink in 17 * every component of the given name recursively; 18 * all but the last component must exist 19 * -e, --canonicalize-existing 20 * canonicalize by following every symlink in 21 * every component of the given name recursively, 22 * all components must exist 23 * -m, --canonicalize-missing 24 * canonicalize by following every symlink in 25 * every component of the given name recursively, 26 * without requirements on components existence 27 * -n, --no-newline do not output the trailing newline 28 * -q, --quiet, -s, --silent suppress most error messages 29 * -v, --verbose report error messages 30 * 31 * bbox supports: -f -n -v (fully), -q -s (accepts but ignores) 32 */ 33 12 34 int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 13 35 int readlink_main(int argc UNUSED_PARAM, char **argv) 14 36 { … … 20 42 unsigned opt; 21 43 /* We need exactly one non-option argument. */ 22 44 opt_complementary = "=1"; 23 opt = getopt32(argv, "f ");45 opt = getopt32(argv, "fnvsq"); 24 46 fname = argv[optind]; 25 47 ) 26 48 SKIP_FEATURE_READLINK_FOLLOW( … … 30 52 ) 31 53 32 54 /* compat: coreutils readlink reports errors silently via exit code */ 33 logmode = LOGMODE_NONE; 55 if (!(opt & 4)) /* not -v */ 56 logmode = LOGMODE_NONE; 34 57 35 if (opt ) {58 if (opt & 1) { /* -f */ 36 59 buf = realpath(fname, pathbuf); 37 60 } else { 38 61 buf = xmalloc_readlink_or_warn(fname); … … 40 63 41 64 if (!buf) 42 65 return EXIT_FAILURE; 43 p uts(buf);66 printf((opt & 2) ? "%s" : "%s\n", buf); 44 67 45 68 if (ENABLE_FEATURE_CLEAN_UP && !opt) 46 69 free(buf); -
include/libbb.h
diff -ru busybox-1.14.1/include/libbb.h busybox-1.14.1-fixed/include/libbb.h
old new 1099 1099 void print_signames(void) FAST_FUNC; 1100 1100 1101 1101 char *bb_simplify_path(const char *path) FAST_FUNC; 1102 /* Returns ptr to NUL */ 1103 char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC; 1102 1104 1103 1105 #define FAIL_DELAY 3 1104 1106 extern void bb_do_delay(int seconds) FAST_FUNC; -
include/usage.h
diff -ru busybox-1.14.1/include/usage.h busybox-1.14.1-fixed/include/usage.h
old new 3404 3404 "files do not block on disk I/O" 3405 3405 3406 3406 #define readlink_trivial_usage \ 3407 USE_FEATURE_READLINK_FOLLOW("[-f ] ") "FILE"3407 USE_FEATURE_READLINK_FOLLOW("[-fnv] ") "FILE" 3408 3408 #define readlink_full_usage "\n\n" \ 3409 3409 "Display the value of a symlink" \ 3410 3410 USE_FEATURE_READLINK_FOLLOW( "\n" \ 3411 3411 "\nOptions:" \ 3412 "\n -f Canonicalize by following all symlinks") \ 3412 "\n -f Canonicalize by following all symlinks" \ 3413 "\n -n Don't add newline" \ 3414 "\n -v Verbose" \ 3415 ) \ 3413 3416 3414 3417 #define readprofile_trivial_usage \ 3415 3418 "[OPTIONS]..." -
libbb/simplify_path.c
diff -ru busybox-1.14.1/libbb/simplify_path.c busybox-1.14.1-fixed/libbb/simplify_path.c
old new 6 6 * 7 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 8 8 */ 9 10 9 #include "libbb.h" 11 10 12 char* FAST_FUNC bb_simplify_ path(const char *path)11 char* FAST_FUNC bb_simplify_abs_path_inplace(char *start) 13 12 { 14 char *s, * start, *p;13 char *s, *p; 15 14 16 if (path[0] == '/')17 start = xstrdup(path);18 else {19 s = xrealloc_getcwd_or_warn(NULL);20 start = concat_path_file(s, path);21 free(s);22 }23 15 p = s = start; 24 25 16 do { 26 17 if (*p == '/') { 27 18 if (*s == '/') { /* skip duplicate (or initial) slash */ … … 47 38 if ((p == start) || (*p != '/')) { /* not a trailing slash */ 48 39 ++p; /* so keep last character */ 49 40 } 50 *p = 0; 41 *p = '\0'; 42 return p; 43 } 44 45 char* FAST_FUNC bb_simplify_path(const char *path) 46 { 47 char *s, *p; 48 49 if (path[0] == '/') 50 s = xstrdup(path); 51 else { 52 p = xrealloc_getcwd_or_warn(NULL); 53 s = concat_path_file(p, path); 54 free(p); 55 } 51 56 52 return start; 57 bb_simplify_abs_path_inplace(s); 58 return s; 53 59 } -
modutils/modprobe-small.c
diff -ru busybox-1.14.1/modutils/modprobe-small.c busybox-1.14.1-fixed/modutils/modprobe-small.c
old new 656 656 [-b basedirectory] [forced_version] 657 657 depmod [-n -e -v -q -r -u] [-F kernelsyms] module1.ko module2.ko ... 658 658 If no arguments (except options) are given, "depmod -a" is assumed. 659 depmod will output a depend ancy list suitable for the modprobe utility.659 depmod will output a dependency list suitable for the modprobe utility. 660 660 Options: 661 661 -a, --all Probe all modules 662 662 -A, --quick Only does the work if there's a new module -
modutils/modprobe.c
diff -ru busybox-1.14.1/modutils/modprobe.c busybox-1.14.1-fixed/modutils/modprobe.c
old new 8 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 9 9 */ 10 10 11 /* Note that unlike older versions of modules.dep/depmod (busybox and m-i-t), 12 * we expect the full dependency list to be specified in modules.dep. Older 13 * versions would only export the direct dependency list. 14 */ 15 11 16 #include "libbb.h" 12 17 #include "modutils.h" 13 18 #include <sys/utsname.h> 14 19 #include <fnmatch.h> 15 20 16 //#define DBG( ...) bb_error_msg(__VA_ARGS__)21 //#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__) 17 22 #define DBG(...) ((void)0) 18 23 19 24 #define MODULE_FLAG_LOADED 0x0001 … … 116 121 return; 117 122 } 118 123 124 DBG("queuing %s", name); 119 125 m->probed_name = name; 120 126 m->flags |= MODULE_FLAG_NEED_DEPS; 121 127 llist_add_to_end(&G.probes, m); … … 205 211 206 212 static int do_modprobe(struct module_entry *m) 207 213 { 208 struct module_entry *m2 ;214 struct module_entry *m2 = m2; /* for compiler */ 209 215 char *fn, *options; 210 int rc = -1; 216 int rc, first; 217 llist_t *l; 211 218 212 219 if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) { 213 220 DBG("skipping %s, not found in modules.dep", m->modname); … … 218 225 if (!(option_mask32 & MODPROBE_OPT_REMOVE)) 219 226 m->deps = llist_rev(m->deps); 220 227 228 for (l = m->deps; l != NULL; l = l->link) 229 DBG("dep: %s", l->data); 230 231 first = 1; 221 232 rc = 0; 222 233 while (m->deps && rc == 0) { 223 234 fn = llist_pop(&m->deps); 224 235 m2 = get_or_add_modentry(fn); 225 236 if (option_mask32 & MODPROBE_OPT_REMOVE) { 226 if (bb_delete_module(m->modname, O_EXCL) != 0) 227 rc = errno; 237 if (m2->flags & MODULE_FLAG_LOADED) { 238 if (bb_delete_module(m2->modname, O_EXCL) != 0) { 239 if (first) 240 rc = errno; 241 } else { 242 m2->flags &= ~MODULE_FLAG_LOADED; 243 } 244 } 245 /* do not error out if *deps* fail to unload */ 246 first = 0; 228 247 } else if (!(m2->flags & MODULE_FLAG_LOADED)) { 229 248 options = m2->options; 230 249 m2->options = NULL; … … 242 261 free(fn); 243 262 } 244 263 245 //FIXME: what if rc < 0? 246 if (rc > 0 && !(option_mask32 & INSMOD_OPT_SILENT)) { 264 if (rc && !(option_mask32 & INSMOD_OPT_SILENT)) { 247 265 bb_error_msg("failed to %sload module %s: %s", 248 266 (option_mask32 & MODPROBE_OPT_REMOVE) ? "un" : "", 249 m ->probed_name ? m->probed_name : m->modname,267 m2->probed_name ? m2->probed_name : m2->modname, 250 268 moderror(rc) 251 269 ); 252 270 } … … 294 312 llist_add_to(&m->deps, xstrdup(tokens[0])); 295 313 if (tokens[1]) 296 314 string_to_llist(tokens[1], &m->deps, " "); 297 } 315 } else 316 DBG("skipping dep line"); 298 317 } 299 318 config_close(p); 300 319 } … … 344 363 if (opt & (MODPROBE_OPT_INSERT_ALL | MODPROBE_OPT_REMOVE)) { 345 364 /* Each argument is a module name */ 346 365 do { 366 DBG("adding module %s", *argv); 347 367 add_probe(*argv++); 348 368 } while (*argv); 349 369 } else { 350 370 /* First argument is module name, rest are parameters */ 371 DBG("probing just module %s", *argv); 351 372 add_probe(argv[0]); 352 373 G.cmdline_mopts = parse_cmdline_module_options(argv); 353 374 } -
modutils/modutils.c
diff -ru busybox-1.14.1/modutils/modutils.c busybox-1.14.1-fixed/modutils/modutils.c
old new 57 57 from = bb_get_last_path_component_nostrip(filename); 58 58 for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++) 59 59 modname[i] = (from[i] == '-') ? '_' : from[i]; 60 modname[i] = 0;60 modname[i] = '\0'; 61 61 62 62 return modname; 63 63 } -
networking/ftpd.c
diff -ru busybox-1.14.1/networking/ftpd.c busybox-1.14.1-fixed/networking/ftpd.c
old new 1320 1320 handle_appe(); 1321 1321 else if (cmdval == const_STOU) /* "store unique" */ 1322 1322 handle_stou(); 1323 else 1324 goto bad_cmd; 1323 1325 } 1324 1326 #endif 1325 1327 #if 0 … … 1340 1342 * (doesn't necessarily mean "we must support them") 1341 1343 * foo 1.2.3: XXXX - comment 1342 1344 */ 1345 #if ENABLE_FEATURE_FTP_WRITE 1346 bad_cmd: 1347 #endif 1343 1348 cmdio_write_raw(STR(FTP_BADCMD)" Unknown command\r\n"); 1344 1349 } 1345 1350 } -
networking/httpd.c
diff -ru busybox-1.14.1/networking/httpd.c busybox-1.14.1-fixed/networking/httpd.c
old new 32 32 * foo=`httpd -d $foo` # decode "Hello%20World" as "Hello World" 33 33 * bar=`httpd -e "<Hello World>"` # encode as "<Hello World>" 34 34 * Note that url encoding for arguments is not the same as html encoding for 35 * presentation. -d decodes a url-encoded argument while -e encodes in html35 * presentation. -d decodes an url-encoded argument while -e encodes in html 36 36 * for page display. 37 37 * 38 38 * httpd.conf has the following format: … … 54 54 * /adm:admin:setup # Require user admin, pwd setup on urls starting with /adm/ 55 55 * /adm:toor:PaSsWd # or user toor, pwd PaSsWd on urls starting with /adm/ 56 56 * .au:audio/basic # additional mime type for audio.au files 57 * *.php:/path/php # run ning cgi.php scriptsthrough an interpreter57 * *.php:/path/php # run xxx.php through an interpreter 58 58 * 59 59 * A/D may be as a/d or allow/deny - only first char matters. 60 60 * Deny/Allow IP logic: … … 94 94 * server exits with an error. 95 95 * 96 96 */ 97 /* TODO: use TCP_CORK, parse_config() */ 97 98 98 99 #include "libbb.h" 99 100 #if ENABLE_FEATURE_HTTPD_USE_SENDFILE 100 101 # include <sys/sendfile.h> 101 102 #endif 102 103 103 //#define DEBUG 1104 104 #define DEBUG 0 105 105 106 106 #define IOBUF_SIZE 8192 /* IO buffer */ … … 115 115 116 116 #define HEADER_READ_TIMEOUT 60 117 117 118 static const char default_path_httpd_conf[] ALIGN1 = "/etc";119 static const char httpd_conf[] ALIGN1 = "httpd.conf";118 static const char DEFAULT_PATH_HTTPD_CONF[] ALIGN1 = "/etc"; 119 static const char HTTPD_CONF[] ALIGN1 = "httpd.conf"; 120 120 static const char HTTP_200[] ALIGN1 = "HTTP/1.0 200 OK\r\n"; 121 121 122 122 typedef struct has_next_ptr { … … 242 242 const char *bind_addr_or_port; 243 243 244 244 const char *g_query; 245 const char * configFile;245 const char *opt_c_configFile; 246 246 const char *home_httpd; 247 247 const char *index_page; 248 248 … … 289 289 #define rmt_ip (G.rmt_ip ) 290 290 #define bind_addr_or_port (G.bind_addr_or_port) 291 291 #define g_query (G.g_query ) 292 #define configFile (G.configFile)292 #define opt_c_configFile (G.opt_c_configFile ) 293 293 #define home_httpd (G.home_httpd ) 294 294 #define index_page (G.index_page ) 295 295 #define found_mime_type (G.found_mime_type ) … … 452 452 /* 453 453 * Parse configuration file into in-memory linked list. 454 454 * 455 * The first non-white character is examined to determine if the config line456 * is one of the following:457 * .ext:mime/type # new mime type not compiled into httpd458 * [adAD]:from # ip address allow/deny, * for wildcard459 * /path:user:pass # username/password460 * Ennn:error.html # error page for status nnn461 * P:/url:[http://]hostname[:port]/new/path # reverse proxy462 *463 455 * Any previous IP rules are discarded. 464 456 * If the flag argument is not SUBDIR_PARSE then all /path and mime rules 465 457 * are also discarded. That is, previous settings are retained if flag is … … 469 461 * path Path where to look for httpd.conf (without filename). 470 462 * flag Type of the parse request. 471 463 */ 472 /* flag */ 473 #define FIRST_PARSE 0 474 #define SUBDIR_PARSE 1 475 #define SIGNALED_PARSE 2 476 #define FIND_FROM_HTTPD_ROOT 3 464 /* flag param: */ 465 enum { 466 FIRST_PARSE = 0, /* path will be "/etc" */ 467 SIGNALED_PARSE = 1, /* path will be "/etc" */ 468 SUBDIR_PARSE = 2, /* path will be derived from URL */ 469 }; 477 470 static void parse_conf(const char *path, int flag) 478 471 { 472 /* internally used extra flag state */ 473 enum { TRY_CURDIR_PARSE = 3 }; 474 479 475 FILE *f; 480 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH 481 Htaccess *prev; 482 #endif 483 Htaccess *cur; 484 const char *filename = configFile; 476 const char *filename; 485 477 char buf[160]; 486 char *p, *p0;487 char *after_colon;488 Htaccess_IP *pip;489 478 490 479 /* discard old rules */ 491 480 free_Htaccess_IP_list(&ip_a_d); 492 481 flg_deny_all = 0; 493 482 /* retain previous auth and mime config only for subdir parse */ 494 483 if (flag != SUBDIR_PARSE) { 484 free_Htaccess_list(&mime_a); 495 485 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH 496 486 free_Htaccess_list(&g_auth); 497 487 #endif 498 free_Htaccess_list(&mime_a);499 488 #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 500 489 free_Htaccess_list(&script_i); 501 490 #endif 502 491 } 503 492 493 filename = opt_c_configFile; 504 494 if (flag == SUBDIR_PARSE || filename == NULL) { 505 filename = alloca(strlen(path) + sizeof( httpd_conf) + 2);506 sprintf((char *)filename, "%s/%s", path, httpd_conf);495 filename = alloca(strlen(path) + sizeof(HTTPD_CONF) + 2); 496 sprintf((char *)filename, "%s/%s", path, HTTPD_CONF); 507 497 } 508 498 509 499 while ((f = fopen_for_read(filename)) == NULL) { 510 if (flag == SUBDIR_PARSE || flag == FIND_FROM_HTTPD_ROOT) {500 if (flag >= SUBDIR_PARSE) { /* SUBDIR or TRY_CURDIR */ 511 501 /* config file not found, no changes to config */ 512 502 return; 513 503 } 514 if (configFile && flag == FIRST_PARSE) /* if -c option given */ 515 bb_simple_perror_msg_and_die(filename); 516 flag = FIND_FROM_HTTPD_ROOT; 517 filename = httpd_conf; 504 if (flag == FIRST_PARSE) { 505 /* -c CONFFILE given, but CONFFILE doesn't exist? */ 506 if (opt_c_configFile) 507 bb_simple_perror_msg_and_die(opt_c_configFile); 508 /* else: no -c, thus we looked at /etc/httpd.conf, 509 * and it's not there. try ./httpd.conf: */ 510 } 511 flag = TRY_CURDIR_PARSE; 512 filename = HTTPD_CONF; 518 513 } 519 514 520 515 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH 521 prev = g_auth; 522 #endif 523 /* This could stand some work */ 524 while ((p0 = fgets(buf, sizeof(buf), f)) != NULL) { 525 after_colon = NULL; 526 for (p = p0; *p0 != '\0' && *p0 != '#'; p0++) { 527 if (!isspace(*p0)) { 528 *p++ = *p0; 529 if (*p0 == ':' && after_colon == NULL) 530 after_colon = p; 516 /* in "/file:user:pass" lines, we prepend path in subdirs */ 517 if (flag != SUBDIR_PARSE) 518 path = ""; 519 #endif 520 /* The lines can be: 521 * 522 * I:default_index_file 523 * H:http_home 524 * [AD]:IP[/mask] # allow/deny, * for wildcard 525 * Ennn:error.html # error page for status nnn 526 * P:/url:[http://]hostname[:port]/new/path # reverse proxy 527 * .ext:mime/type # mime type 528 * *.php:/path/php # run xxx.php through an interpreter 529 * /file:user:pass # username and password 530 */ 531 while (fgets(buf, sizeof(buf), f) != NULL) { 532 unsigned strlen_buf; 533 unsigned char ch; 534 char *after_colon; 535 536 { /* remove all whitespace, and # comments */ 537 char *p, *p0; 538 539 p0 = buf; 540 /* skip non-whitespace beginning. Often the whole line 541 * is non-whitespace. We want this case to work fast, 542 * without needless copying, therefore we don't merge 543 * this operation into next while loop. */ 544 while ((ch = *p0) != '\0' && ch != '\n' && ch != '#' 545 && ch != ' ' && ch != '\t' 546 ) { 547 p0++; 548 } 549 p = p0; 550 /* if we enter this loop, we have some whitespace. 551 * discard it */ 552 while (ch != '\0' && ch != '\n' && ch != '#') { 553 if (ch != ' ' && ch != '\t') { 554 *p++ = ch; 555 } 556 ch = *++p0; 531 557 } 558 *p = '\0'; 559 strlen_buf = p - buf; 560 if (strlen_buf == 0) 561 continue; /* empty line */ 532 562 } 533 *p = '\0';534 563 535 /* test for empty or strange line */ 536 if (after_colon == NULL || *after_colon == '\0') 564 after_colon = strchr(buf, ':'); 565 /* strange line? */ 566 if (after_colon == NULL || *++after_colon == '\0') 567 goto config_error; 568 569 ch = (buf[0] & ~0x20); /* toupper if it's a letter */ 570 571 if (ch == 'I') { 572 index_page = xstrdup(after_colon); 537 573 continue; 538 p0 = buf; 539 if (*p0 == 'd' || *p0 == 'a') 540 *p0 -= 0x20; /* a/d -> A/D */ 541 if (*after_colon == '*') { 542 if (*p0 == 'D') { 543 /* memorize "deny all" */ 544 flg_deny_all = 1; 545 } 546 /* skip assumed "A:*", it is a default anyway */ 574 } 575 576 /* do not allow jumping around using H in subdir's configs */ 577 if (flag == FIRST_PARSE && ch == 'H') { 578 home_httpd = xstrdup(after_colon); 579 xchdir(home_httpd); 547 580 continue; 548 581 } 549 582 550 if (*p0 == 'A' || *p0 == 'D') { 551 /* storing current config IP line */ 552 pip = xzalloc(sizeof(Htaccess_IP)); 553 if (scan_ip_mask(after_colon, &(pip->ip), &(pip->mask))) { 583 if (ch == 'A' || ch == 'D') { 584 Htaccess_IP *pip; 585 586 if (*after_colon == '*') { 587 if (ch == 'D') { 588 /* memorize "deny all" */ 589 flg_deny_all = 1; 590 } 591 /* skip assumed "A:*", it is a default anyway */ 592 continue; 593 } 594 /* store "allow/deny IP/mask" line */ 595 pip = xzalloc(sizeof(*pip)); 596 if (scan_ip_mask(after_colon, &pip->ip, &pip->mask)) { 554 597 /* IP{/mask} syntax error detected, protect all */ 555 *p0= 'D';598 ch = 'D'; 556 599 pip->mask = 0; 557 600 } 558 pip->allow_deny = *p0;559 if ( *p0== 'D') {601 pip->allow_deny = ch; 602 if (ch == 'D') { 560 603 /* Deny:from_IP - prepend */ 561 604 pip->next = ip_a_d; 562 605 ip_a_d = pip; 563 606 } else { 564 /* A:from_IP - append (thus D precedes A) */607 /* A:from_IP - append (thus all D's precedes A's) */ 565 608 Htaccess_IP *prev_IP = ip_a_d; 566 609 if (prev_IP == NULL) { 567 610 ip_a_d = pip; … … 575 618 } 576 619 577 620 #if ENABLE_FEATURE_HTTPD_ERROR_PAGES 578 if (flag == FIRST_PARSE && *p0== 'E') {621 if (flag == FIRST_PARSE && ch == 'E') { 579 622 unsigned i; 580 int status = atoi(++p0); /* error status code */ 623 int status = atoi(buf + 1); /* error status code */ 624 581 625 if (status < HTTP_CONTINUE) { 582 bb_error_msg("config error '%s' in '%s'", buf, filename); 583 continue; 626 goto config_error; 584 627 } 585 628 /* then error page; find matching status */ 586 629 for (i = 0; i < ARRAY_SIZE(http_response_type); i++) { … … 597 640 #endif 598 641 599 642 #if ENABLE_FEATURE_HTTPD_PROXY 600 if (flag == FIRST_PARSE && *p0== 'P') {643 if (flag == FIRST_PARSE && ch == 'P') { 601 644 /* P:/url:[http://]hostname[:port]/new/path */ 602 645 char *url_from, *host_port, *url_to; 603 646 Htaccess_Proxy *proxy_entry; … … 605 648 url_from = after_colon; 606 649 host_port = strchr(after_colon, ':'); 607 650 if (host_port == NULL) { 608 bb_error_msg("config error '%s' in '%s'", buf, filename); 609 continue; 651 goto config_error; 610 652 } 611 653 *host_port++ = '\0'; 612 654 if (strncmp(host_port, "http://", 7) == 0) 613 655 host_port += 7; 614 656 if (*host_port == '\0') { 615 bb_error_msg("config error '%s' in '%s'", buf, filename); 616 continue; 657 goto config_error; 617 658 } 618 659 url_to = strchr(host_port, '/'); 619 660 if (url_to == NULL) { 620 bb_error_msg("config error '%s' in '%s'", buf, filename); 621 continue; 661 goto config_error; 622 662 } 623 663 *url_to = '\0'; 624 proxy_entry = xzalloc(sizeof( Htaccess_Proxy));664 proxy_entry = xzalloc(sizeof(*proxy_entry)); 625 665 proxy_entry->url_from = xstrdup(url_from); 626 666 proxy_entry->host_port = xstrdup(host_port); 627 667 *url_to = '/'; … … 631 671 continue; 632 672 } 633 673 #endif 674 /* the rest of directives are non-alphabetic, 675 * must avoid using "toupper'ed" ch */ 676 ch = buf[0]; 634 677 635 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH 636 if (*p0 == '/') { 637 /* make full path from httpd root / current_path / config_line_path */ 638 const char *tp = (flag == SUBDIR_PARSE ? path : ""); 639 p0 = xmalloc(strlen(tp) + (after_colon - buf) + 2 + strlen(after_colon)); 640 after_colon[-1] = '\0'; 641 sprintf(p0, "/%s%s", tp, buf); 642 643 /* looks like bb_simplify_path... */ 644 tp = p = p0; 645 do { 646 if (*p == '/') { 647 if (*tp == '/') { /* skip duplicate (or initial) slash */ 648 continue; 649 } 650 if (*tp == '.') { 651 if (tp[1] == '/' || tp[1] == '\0') { /* remove extra '.' */ 652 continue; 653 } 654 if ((tp[1] == '.') && (tp[2] == '/' || tp[2] == '\0')) { 655 ++tp; 656 if (p > p0) { 657 while (*--p != '/') /* omit previous dir */ 658 continue; 659 } 660 continue; 661 } 662 } 663 } 664 *++p = *tp; 665 } while (*++tp); 678 if (ch == '.' /* ".ext:mime/type" */ 679 #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 680 || (ch == '*' && buf[1] == '.') /* "*.php:/path/php" */ 681 #endif 682 ) { 683 char *p; 684 Htaccess *cur; 666 685 667 if ((p == p0) || (*p != '/')) { /* not a trailing slash */ 668 ++p; /* so keep last character */ 686 cur = xzalloc(sizeof(*cur) /* includes space for NUL */ + strlen_buf); 687 strcpy(cur->before_colon, buf); 688 p = cur->before_colon + (after_colon - buf); 689 p[-1] = '\0'; 690 cur->after_colon = p; 691 if (ch == '.') { 692 /* .mime line: prepend to mime_a list */ 693 cur->next = mime_a; 694 mime_a = cur; 695 } 696 #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 697 else { 698 /* script interpreter line: prepend to script_i list */ 699 cur->next = script_i; 700 script_i = cur; 669 701 } 670 *p = ':';671 strcpy(p + 1, after_colon);672 }673 702 #endif 674 if (*p0 == 'I') {675 index_page = xstrdup(after_colon);676 continue;677 }678 679 /* Do not allow jumping around using H in subdir's configs */680 if (flag == FIRST_PARSE && *p0 == 'H') {681 home_httpd = xstrdup(after_colon);682 xchdir(home_httpd);683 703 continue; 684 704 } 685 705 686 /* storing current config line */687 cur = xzalloc(sizeof(Htaccess) + strlen(p0));688 strcpy(cur->before_colon, p0);689 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH690 if (*p0 == '/') /* was malloced - see above */691 free(p0);692 #endif693 cur->after_colon = strchr(cur->before_colon, ':');694 *cur->after_colon++ = '\0';695 if (cur->before_colon[0] == '.') {696 /* .mime line: prepend to mime_a list */697 cur->next = mime_a;698 mime_a = cur;699 continue;700 }701 #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR702 if (cur->before_colon[0] == '*' && cur->before_colon[1] == '.') {703 /* script interpreter line: prepend to script_i list */704 cur->next = script_i;705 script_i = cur;706 continue;707 }708 #endif709 706 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH 710 //TODO: we do not test for leading "/"?? 711 //also, do we leak cur if BASIC_AUTH is off? 712 if (prev == NULL) { 713 /* first line */ 714 g_auth = prev = cur; 715 } else { 716 /* sort path, if current length eq or bigger then move up */ 717 Htaccess *prev_hti = g_auth; 718 size_t l = strlen(cur->before_colon); 719 Htaccess *hti; 720 721 for (hti = prev_hti; hti; hti = hti->next) { 722 if (l >= strlen(hti->before_colon)) { 723 /* insert before hti */ 724 cur->next = hti; 725 if (prev_hti != hti) { 726 prev_hti->next = cur; 727 } else { 728 /* insert as top */ 729 g_auth = cur; 707 if (ch == '/') { /* "/file:user:pass" */ 708 char *p; 709 Htaccess *cur; 710 unsigned file_len; 711 712 /* note: path is "" unless we are in SUBDIR parse, 713 * otherwise it does NOT start with "/" */ 714 cur = xzalloc(sizeof(*cur) /* includes space for NUL */ 715 + 1 + strlen(path) 716 + strlen_buf 717 ); 718 /* form "/path/file" */ 719 sprintf(cur->before_colon, "/%s%.*s", 720 path, 721 (int) (after_colon - buf - 1), /* includes "/", but not ":" */ 722 buf); 723 /* canonicalize it */ 724 p = bb_simplify_abs_path_inplace(cur->before_colon); 725 file_len = p - cur->before_colon; 726 /* add "user:pass" after NUL */ 727 strcpy(++p, after_colon); 728 cur->after_colon = p; 729 730 /* insert cur into g_auth */ 731 /* g_auth is sorted by decreased filename length */ 732 { 733 Htaccess *auth, **authp; 734 735 authp = &g_auth; 736 while ((auth = *authp) != NULL) { 737 if (file_len >= strlen(auth->before_colon)) { 738 /* insert cur before auth */ 739 cur->next = auth; 740 break; 730 741 } 731 break;742 authp = &auth->next; 732 743 } 733 if (prev_hti != hti) 734 prev_hti = prev_hti->next; 735 } 736 if (!hti) { /* not inserted, add to bottom */ 737 prev->next = cur; 738 prev = cur; 744 *authp = cur; 739 745 } 746 continue; 740 747 } 741 748 #endif /* BASIC_AUTH */ 749 750 /* the line is not recognized */ 751 config_error: 752 bb_error_msg("config error '%s' in '%s'", buf, filename); 742 753 } /* while (fgets) */ 754 743 755 fclose(f); 744 756 } 745 757 … … 1527 1539 send_headers_and_exit(HTTP_NOT_FOUND); 1528 1540 log_and_exit(); 1529 1541 } 1530 1531 if (DEBUG)1532 bb_error_msg("sending file '%s' content-type: %s",1533 url, found_mime_type);1534 1535 1542 /* If you want to know about EPIPE below 1536 1543 * (happens if you abort downloads from local httpd): */ 1537 1544 signal(SIGPIPE, SIG_IGN); … … 1559 1566 } 1560 1567 } 1561 1568 } 1569 1570 if (DEBUG) 1571 bb_error_msg("sending file '%s' content-type: %s", 1572 url, found_mime_type); 1573 1562 1574 #if ENABLE_FEATURE_HTTPD_RANGES 1563 1575 if (what == SEND_BODY) 1564 1576 range_start = 0; /* err pages and ranges don't mix */ … … 2031 2043 /* We are done reading headers, disable peer timeout */ 2032 2044 alarm(0); 2033 2045 2034 if (strcmp(bb_basename(urlcopy), httpd_conf) == 0 || !ip_allowed) {2035 /* protect listing [/path]/httpd _conf or IP deny */2046 if (strcmp(bb_basename(urlcopy), HTTPD_CONF) == 0 || !ip_allowed) { 2047 /* protect listing [/path]/httpd.conf or IP deny */ 2036 2048 send_headers_and_exit(HTTP_FORBIDDEN); 2037 2049 } 2038 2050 … … 2074 2086 header_ptr += 2; 2075 2087 write(proxy_fd, header_buf, header_ptr - header_buf); 2076 2088 free(header_buf); /* on the order of 8k, free it */ 2077 /* cgi_io_loop_and_exit needs to have two dis ctinct fds */2089 /* cgi_io_loop_and_exit needs to have two distinct fds */ 2078 2090 cgi_io_loop_and_exit(proxy_fd, dup(proxy_fd), length); 2079 2091 } 2080 2092 #endif … … 2245 2257 2246 2258 static void sighup_handler(int sig UNUSED_PARAM) 2247 2259 { 2248 parse_conf( default_path_httpd_conf, SIGNALED_PARSE);2260 parse_conf(DEFAULT_PATH_HTTPD_CONF, SIGNALED_PARSE); 2249 2261 } 2250 2262 2251 2263 enum { … … 2304 2316 USE_FEATURE_HTTPD_AUTH_MD5("m:") 2305 2317 USE_FEATURE_HTTPD_SETUID("u:") 2306 2318 "p:ifv", 2307 & configFile, &url_for_decode, &home_httpd2319 &opt_c_configFile, &url_for_decode, &home_httpd 2308 2320 USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode) 2309 2321 USE_FEATURE_HTTPD_BASIC_AUTH(, &g_realm) 2310 2322 USE_FEATURE_HTTPD_AUTH_MD5(, &pass) … … 2375 2387 } 2376 2388 #endif 2377 2389 2378 parse_conf( default_path_httpd_conf, FIRST_PARSE);2390 parse_conf(DEFAULT_PATH_HTTPD_CONF, FIRST_PARSE); 2379 2391 if (!(opt & OPT_INETD)) 2380 2392 signal(SIGHUP, sighup_handler); 2381 2393 -
networking/telnetd.c
diff -ru busybox-1.14.1/networking/telnetd.c busybox-1.14.1-fixed/networking/telnetd.c
old new 199 199 return total + rc; 200 200 } 201 201 202 /* Must match getopt32 string */ 203 enum { 204 OPT_WATCHCHILD = (1 << 2), /* -K */ 205 OPT_INETD = (1 << 3) * ENABLE_FEATURE_TELNETD_STANDALONE, /* -i */ 206 OPT_PORT = (1 << 4) * ENABLE_FEATURE_TELNETD_STANDALONE, /* -p */ 207 OPT_FOREGROUND = (1 << 6) * ENABLE_FEATURE_TELNETD_STANDALONE, /* -F */ 208 }; 209 202 210 static struct tsession * 203 211 make_new_session( 204 USE_FEATURE_TELNETD_STANDALONE(int sock)212 USE_FEATURE_TELNETD_STANDALONE(int master_fd, int sock) 205 213 SKIP_FEATURE_TELNETD_STANDALONE(void) 206 214 ) { 207 215 const char *login_argv[2]; … … 288 296 /* Restore default signal handling ASAP */ 289 297 bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL); 290 298 299 #if ENABLE_FEATURE_TELNETD_STANDALONE 300 if (!(option_mask32 & OPT_INETD)) { 301 struct tsession *tp = sessions; 302 while (tp) { 303 close(tp->ptyfd); 304 close(tp->sockfd_read); 305 /* sockfd_write == sockfd_read for standalone telnetd */ 306 /*close(tp->sockfd_write);*/ 307 tp = tp->next; 308 } 309 } 310 #endif 311 291 312 /* Make new session and process group */ 292 313 setsid(); 293 314 315 close(fd); 316 #if ENABLE_FEATURE_TELNETD_STANDALONE 317 close(sock); 318 if (master_fd >= 0) 319 close(master_fd); 320 #endif 321 294 322 /* Open the child's side of the tty. */ 295 323 /* NB: setsid() disconnects from any previous ctty's. Therefore 296 324 * we must open child's side of the tty AFTER setsid! */ … … 329 357 _exit(EXIT_FAILURE); /*bb_perror_msg_and_die("execv %s", loginpath);*/ 330 358 } 331 359 332 /* Must match getopt32 string */333 enum {334 OPT_WATCHCHILD = (1 << 2), /* -K */335 OPT_INETD = (1 << 3) * ENABLE_FEATURE_TELNETD_STANDALONE, /* -i */336 OPT_PORT = (1 << 4) * ENABLE_FEATURE_TELNETD_STANDALONE, /* -p */337 OPT_FOREGROUND = (1 << 6) * ENABLE_FEATURE_TELNETD_STANDALONE, /* -F */338 };339 340 360 #if ENABLE_FEATURE_TELNETD_STANDALONE 341 361 342 362 static void … … 465 485 466 486 #if ENABLE_FEATURE_TELNETD_STANDALONE 467 487 if (IS_INETD) { 468 sessions = make_new_session( 0);488 sessions = make_new_session(-1, 0); 469 489 if (!sessions) /* pty opening or vfork problem, exit */ 470 490 return 1; /* make_new_session prints error message */ 471 491 } else { … … 553 573 if (fd < 0) 554 574 goto again; 555 575 /* Create a new session and link it into our active list */ 556 new_ts = make_new_session( fd);576 new_ts = make_new_session(master_fd, fd); 557 577 if (new_ts) { 558 578 new_ts->next = sessions; 559 579 sessions = new_ts; -
busybox-1.14.
diff -ru busybox-1.14.1/shell/ash.c busybox-1.14.1-fixed/shell/ash.c
old new 11909 11909 */ 11910 11910 return fullname; 11911 11911 } 11912 stunalloc(fullname); 11912 if (fullname != name) 11913 stunalloc(fullname); 11913 11914 } 11914 11915 11915 11916 /* not found in the PATH */
Note:
See TracBrowser
for help on using the repository browser.