Changeset 20884
- Timestamp:
- 2010-04-15T21:53:29+02:00 (8 years ago)
- Location:
- branches/backfire/package/uhttpd
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/backfire/package/uhttpd/Makefile
r20672 r20884 9 9 10 10 PKG_NAME:=uhttpd 11 PKG_RELEASE:= 711 PKG_RELEASE:=8 12 12 13 13 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) -
branches/backfire/package/uhttpd/files/uhttpd.config
r20500 r20884 30 30 # CGI/Lua timeout, if the called script does not 31 31 # write data within the given amount of seconds, 32 # the server will te mrinate the request with32 # the server will terminate the request with 33 33 # 504 Gateway Timeout response. 34 34 option script_timeout 60 35 36 # Network timeout, if the current connection is 37 # blocked for the specified amount of seconds, 38 # the server will terminate the associated 39 # request process. 40 option network_timeout 30 35 41 36 42 # Basic auth realm, defaults to local hostname -
branches/backfire/package/uhttpd/files/uhttpd.init
r20672 r20884 59 59 append_arg "$cfg" lua_handler "-L" 60 60 append_arg "$cfg" script_timeout "-t" 61 append_arg "$cfg" network_timeout "-T" 61 62 62 63 config_get http "$cfg" listen_http -
branches/backfire/package/uhttpd/src/uhttpd-file.c
r20428 r20884 30 30 { 31 31 struct mimetype *m = &uh_mime_types[0]; 32 char *p, *pd, *ps; 33 34 ps = strrchr(path, '/'); 35 pd = strrchr(path, '.'); 36 37 /* use either slash or dot as separator, whatever comes last */ 38 p = (ps && pd && (ps > pd)) ? ps : pd; 39 40 if( (p != NULL) && (*(++p) != 0) ) 41 { 42 while( m->extn ) 43 { 44 if( ! strcasecmp(p, m->extn) ) 32 char *e; 33 34 while( m->extn ) 35 { 36 e = &path[strlen(path)-1]; 37 38 while( e >= path ) 39 { 40 if( (*e == '.') && !strcasecmp(&e[1], m->extn) ) 45 41 return m->mime; 46 42 47 m++; 48 } 43 e--; 44 } 45 46 m++; 49 47 } 50 48 -
branches/backfire/package/uhttpd/src/uhttpd-mimetypes.h
r20428 r20884 21 21 static struct mimetype uh_mime_types[] = { 22 22 23 { "txt", "text/plain" },24 { "log", "text/plain" },25 { "js", "text/javascript" },26 { "css", "text/css" },27 { "htm", "text/html" },28 { "html", "text/html" },29 { "diff", "text/x-patch" },30 { "patch", "text/x-patch" },31 { "c", "text/x-csrc" },32 { "h", "text/x-chdr" },33 { "o", "text/x-object" },34 { "ko", "text/x-object" },23 { "txt", "text/plain" }, 24 { "log", "text/plain" }, 25 { "js", "text/javascript" }, 26 { "css", "text/css" }, 27 { "htm", "text/html" }, 28 { "html", "text/html" }, 29 { "diff", "text/x-patch" }, 30 { "patch", "text/x-patch" }, 31 { "c", "text/x-csrc" }, 32 { "h", "text/x-chdr" }, 33 { "o", "text/x-object" }, 34 { "ko", "text/x-object" }, 35 35 36 { "bmp", "image/bmp" },37 { "gif", "image/gif" },38 { "png", "image/png" },39 { "jpg", "image/jpeg" },40 { "jpeg", "image/jpeg" },41 { "svg", "image/svg+xml" },36 { "bmp", "image/bmp" }, 37 { "gif", "image/gif" }, 38 { "png", "image/png" }, 39 { "jpg", "image/jpeg" }, 40 { "jpeg", "image/jpeg" }, 41 { "svg", "image/svg+xml" }, 42 42 43 { "zip", "application/zip" }, 44 { "pdf", "application/pdf" }, 45 { "xml", "application/xml" }, 46 { "xsl", "application/xml" }, 47 { "doc", "application/msword" }, 48 { "ppt", "application/vnd.ms-powerpoint" }, 49 { "xls", "application/vnd.ms-excel" }, 50 { "odt", "application/vnd.oasis.opendocument.text" }, 51 { "odp", "application/vnd.oasis.opendocument.presentation" }, 52 { "pl", "application/x-perl" }, 53 { "sh", "application/x-shellscript" }, 54 { "php", "application/x-php" }, 55 { "deb", "application/x-deb" }, 56 { "iso", "application/x-cd-image" }, 57 { "tgz", "application/x-compressed-tar" }, 58 { "gz", "application/x-gzip" }, 59 { "bz2", "application/x-bzip" }, 60 { "tar", "application/x-tar" }, 61 { "rar", "application/x-rar-compressed" }, 43 { "zip", "application/zip" }, 44 { "pdf", "application/pdf" }, 45 { "xml", "application/xml" }, 46 { "xsl", "application/xml" }, 47 { "doc", "application/msword" }, 48 { "ppt", "application/vnd.ms-powerpoint" }, 49 { "xls", "application/vnd.ms-excel" }, 50 { "odt", "application/vnd.oasis.opendocument.text" }, 51 { "odp", "application/vnd.oasis.opendocument.presentation" }, 52 { "pl", "application/x-perl" }, 53 { "sh", "application/x-shellscript" }, 54 { "php", "application/x-php" }, 55 { "deb", "application/x-deb" }, 56 { "iso", "application/x-cd-image" }, 57 { "tar.gz", "application/x-compressed-tar" }, 58 { "tgz", "application/x-compressed-tar" }, 59 { "gz", "application/x-gzip" }, 60 { "tar.bz2", "application/x-bzip-compressed-tar" }, 61 { "tbz", "application/x-bzip-compressed-tar" }, 62 { "bz2", "application/x-bzip" }, 63 { "tar", "application/x-tar" }, 64 { "rar", "application/x-rar-compressed" }, 62 65 63 { "mp3", "audio/mpeg" },64 { "ogg", "audio/x-vorbis+ogg" },65 { "wav", "audio/x-wav" },66 { "mp3", "audio/mpeg" }, 67 { "ogg", "audio/x-vorbis+ogg" }, 68 { "wav", "audio/x-wav" }, 66 69 67 { "mpg", "video/mpeg" },68 { "mpeg", "video/mpeg" },69 { "avi", "video/x-msvideo" },70 { "mpg", "video/mpeg" }, 71 { "mpeg", "video/mpeg" }, 72 { "avi", "video/x-msvideo" }, 70 73 71 { "README", "text/plain" },72 { "log", "text/plain" },73 { "cfg", "text/plain" },74 { "conf", "text/plain" },74 { "README", "text/plain" }, 75 { "log", "text/plain" }, 76 { "cfg", "text/plain" }, 77 { "conf", "text/plain" }, 75 78 76 79 { NULL, NULL } -
branches/backfire/package/uhttpd/src/uhttpd-utils.c
r20513 r20884 117 117 FD_SET(cl->socket, &writer); 118 118 119 timeout.tv_sec = 0;120 timeout.tv_usec = 500000;119 timeout.tv_sec = cl->server->conf->network_timeout; 120 timeout.tv_usec = 0; 121 121 122 122 if( select(cl->socket + 1, NULL, &writer, NULL, &timeout) > 0 ) … … 377 377 } 378 378 379 static char * canonpath(const char *path, char *path_resolved) 380 { 381 char path_copy[PATH_MAX]; 382 char *path_cpy = path_copy; 383 char *path_res = path_resolved; 384 385 struct stat s; 386 387 388 /* relative -> absolute */ 389 if( *path != '/' ) 390 { 391 getcwd(path_copy, PATH_MAX); 392 strncat(path_copy, "/", PATH_MAX - strlen(path_copy)); 393 strncat(path_copy, path, PATH_MAX - strlen(path_copy)); 394 } 395 else 396 { 397 strncpy(path_copy, path, PATH_MAX); 398 } 399 400 /* normalize */ 401 while( (*path_cpy != '\0') && (path_cpy < (path_copy + PATH_MAX - 2)) ) 402 { 403 if( *path_cpy == '/' ) 404 { 405 /* skip repeating / */ 406 if( path_cpy[1] == '/' ) 407 { 408 path_cpy++; 409 continue; 410 } 411 412 /* /./ or /../ */ 413 else if( path_cpy[1] == '.' ) 414 { 415 /* skip /./ */ 416 if( (path_cpy[2] == '/') || (path_cpy[2] == '\0') ) 417 { 418 path_cpy += 2; 419 continue; 420 } 421 422 /* collapse /x/../ */ 423 else if( path_cpy[2] == '.' ) 424 { 425 while( (path_res > path_resolved) && (*--path_res != '/') ) 426 ; 427 428 path_cpy += 3; 429 continue; 430 } 431 } 432 } 433 434 *path_res++ = *path_cpy++; 435 } 436 437 /* remove trailing slash if not root / */ 438 if( (path_res > (path_resolved+1)) && (path_res[-1] == '/') ) 439 path_res--; 440 else if( path_res == path_resolved ) 441 *path_res++ = '/'; 442 443 *path_res = '\0'; 444 445 /* test access */ 446 if( !stat(path_resolved, &s) && (s.st_mode & S_IROTH) ) 447 return path_resolved; 448 449 return NULL; 450 } 379 451 380 452 struct path_info * uh_path_lookup(struct client *cl, const char *url) … … 388 460 char *pathptr = NULL; 389 461 462 int no_sym = cl->server->conf->no_symlinks; 390 463 int i = 0; 391 464 struct stat s; … … 433 506 memcpy(path_info, buffer, min(i + 1, sizeof(path_info) - 1)); 434 507 435 if( realpath(path_info, path_phys) ) 436 { 508 if( no_sym ? realpath(path_info, path_phys) 509 : canonpath(path_info, path_phys) 510 ) { 437 511 memset(path_info, 0, sizeof(path_info)); 438 512 memcpy(path_info, &buffer[i], -
branches/backfire/package/uhttpd/src/uhttpd.c
r20672 r20884 417 417 int new_fd, cur_fd, max_fd = 0; 418 418 419 #ifdef HAVE_TLS 419 420 int tls = 0; 420 421 int keys = 0; 422 #endif 423 421 424 int bound = 0; 422 425 int nofork = 0; … … 427 430 char *port = NULL; 428 431 429 /* library handles */ 430 void *tls_lib; 431 void *lua_lib; 432 #if defined(HAVE_TLS) || defined(HAVE_LUA) 433 /* library handle */ 434 void *lib; 435 #endif 432 436 433 437 /* clear the master and temp sets */ … … 467 471 #ifdef HAVE_TLS 468 472 /* load TLS plugin */ 469 if( ! ( tls_lib = dlopen("uhttpd_tls.so", RTLD_LAZY | RTLD_GLOBAL)) )473 if( ! (lib = dlopen("uhttpd_tls.so", RTLD_LAZY | RTLD_GLOBAL)) ) 470 474 { 471 475 fprintf(stderr, … … 477 481 { 478 482 /* resolve functions */ 479 if( !(conf.tls_init = dlsym( tls_lib, "uh_tls_ctx_init")) ||480 !(conf.tls_cert = dlsym( tls_lib, "uh_tls_ctx_cert")) ||481 !(conf.tls_key = dlsym( tls_lib, "uh_tls_ctx_key")) ||482 !(conf.tls_free = dlsym( tls_lib, "uh_tls_ctx_free")) ||483 !(conf.tls_accept = dlsym( tls_lib, "uh_tls_client_accept")) ||484 !(conf.tls_close = dlsym( tls_lib, "uh_tls_client_close")) ||485 !(conf.tls_recv = dlsym( tls_lib, "uh_tls_client_recv")) ||486 !(conf.tls_send = dlsym( tls_lib, "uh_tls_client_send"))483 if( !(conf.tls_init = dlsym(lib, "uh_tls_ctx_init")) || 484 !(conf.tls_cert = dlsym(lib, "uh_tls_ctx_cert")) || 485 !(conf.tls_key = dlsym(lib, "uh_tls_ctx_key")) || 486 !(conf.tls_free = dlsym(lib, "uh_tls_ctx_free")) || 487 !(conf.tls_accept = dlsym(lib, "uh_tls_client_accept")) || 488 !(conf.tls_close = dlsym(lib, "uh_tls_client_close")) || 489 !(conf.tls_recv = dlsym(lib, "uh_tls_client_recv")) || 490 !(conf.tls_send = dlsym(lib, "uh_tls_client_send")) 487 491 ) { 488 492 fprintf(stderr, … … 502 506 #endif 503 507 504 while( (opt = getopt(argc, argv, "f C:K:p:s:h:c:l:L:d:r:m:x:t:")) > 0 )508 while( (opt = getopt(argc, argv, "fSC:K:p:s:h:c:l:L:d:r:m:x:t:T:")) > 0 ) 505 509 { 506 510 switch(opt) … … 593 597 break; 594 598 599 /* don't follow symlinks */ 600 case 'S': 601 conf.no_symlinks = 1; 602 break; 603 595 604 #ifdef HAVE_CGI 596 605 /* cgi prefix */ … … 618 627 break; 619 628 #endif 629 630 /* network timeout */ 631 case 'T': 632 conf.network_timeout = atoi(optarg); 633 break; 620 634 621 635 /* no fork */ … … 664 678 #endif 665 679 " -h directory Specify the document root, default is '.'\n" 680 " -S Do not follow symbolic links outside of the docroot\n" 666 681 #ifdef HAVE_LUA 667 682 " -l string URL prefix for Lua handler, default is '/lua'\n" … … 674 689 " -t seconds CGI and Lua script timeout in seconds, default is 60\n" 675 690 #endif 691 " -T seconds Network timeout in seconds, default is 30\n" 676 692 " -d string URL decode given string\n" 677 693 " -r string Specify basic auth realm\n" … … 713 729 uh_config_parse(conf.file); 714 730 731 /* default network timeout */ 732 if( conf.network_timeout <= 0 ) 733 conf.network_timeout = 30; 734 715 735 #if defined(HAVE_CGI) || defined(HAVE_LUA) 716 736 /* default script timeout */ … … 727 747 #ifdef HAVE_LUA 728 748 /* load Lua plugin */ 729 if( ! (l ua_lib = dlopen("uhttpd_lua.so", RTLD_LAZY | RTLD_GLOBAL)) )749 if( ! (lib = dlopen("uhttpd_lua.so", RTLD_LAZY | RTLD_GLOBAL)) ) 730 750 { 731 751 fprintf(stderr, … … 737 757 { 738 758 /* resolve functions */ 739 if( !(conf.lua_init = dlsym(l ua_lib, "uh_lua_init")) ||740 !(conf.lua_close = dlsym(l ua_lib, "uh_lua_close")) ||741 !(conf.lua_request = dlsym(l ua_lib, "uh_lua_request"))759 if( !(conf.lua_init = dlsym(lib, "uh_lua_init")) || 760 !(conf.lua_close = dlsym(lib, "uh_lua_close")) || 761 !(conf.lua_request = dlsym(lib, "uh_lua_request")) 742 762 ) { 743 763 fprintf(stderr, -
branches/backfire/package/uhttpd/src/uhttpd.h
r20500 r20884 33 33 #include <netdb.h> 34 34 #include <ctype.h> 35 35 #include <errno.h> 36 36 #include <dlfcn.h> 37 37 … … 65 65 char *realm; 66 66 char *file; 67 int no_symlinks; 68 int network_timeout; 67 69 #ifdef HAVE_CGI 68 70 char *cgi_prefix;
Note: See TracChangeset
for help on using the changeset viewer.