Changeset 5893
- Timestamp:
- 03/21/10 03:15:36 (3 years ago)
- Location:
- luci/trunk/contrib/package/uhttpd/src
- Files:
-
- 4 modified
-
uhttpd-utils.c (modified) (3 diffs)
-
uhttpd-utils.h (modified) (1 diff)
-
uhttpd.c (modified) (6 diffs)
-
uhttpd.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/contrib/package/uhttpd/src/uhttpd-utils.c
r5892 r5893 483 483 static int uh_realm_count = 0; 484 484 485 struct auth_realm * uh_auth_add( 486 char *path, char *realm, char *user, char *pass 487 ) { 485 struct auth_realm * uh_auth_add(char *path, char *user, char *pass) 486 { 488 487 struct auth_realm *new = NULL; 489 488 struct passwd *pwd; … … 496 495 497 496 memset(new, 0, sizeof(struct auth_realm)); 498 499 memcpy(new->realm, realm,500 min(strlen(realm), sizeof(new->realm) - 1));501 497 502 498 memcpy(new->path, path, … … 634 630 "Content-Length: 23\r\n\r\n" 635 631 "Authorization Required\n", 636 req->version, realm ? realm->realm : ""632 req->version, cl->server->conf->realm 637 633 ); 638 634 -
luci/trunk/contrib/package/uhttpd/src/uhttpd-utils.h
r5892 r5893 80 80 81 81 82 struct auth_realm * uh_auth_add( 83 char *path, char *realm, char *user, char *pass 84 ); 82 struct auth_realm * uh_auth_add(char *path, char *user, char *pass); 85 83 86 84 int uh_auth_check( -
luci/trunk/contrib/package/uhttpd/src/uhttpd.c
r5892 r5893 17 17 */ 18 18 19 #define _XOPEN_SOURCE 500 /* crypt() */ 20 19 21 #include "uhttpd.h" 20 22 #include "uhttpd-utils.h" … … 39 41 { 40 42 run = 0; 43 } 44 45 static void uh_config_parse(const char *path) 46 { 47 FILE *c; 48 char line[512]; 49 char *user = NULL; 50 char *pass = NULL; 51 char *eol = NULL; 52 53 if( (c = fopen(path ? path : "/etc/httpd.conf", "r")) != NULL ) 54 { 55 memset(line, 0, sizeof(line)); 56 57 while( fgets(line, sizeof(line) - 1, c) ) 58 { 59 if( (line[0] == '/') && (strchr(line, ':') != NULL) ) 60 { 61 if( !(user = strchr(line, ':')) || (*user++ = 0) || 62 !(pass = strchr(user, ':')) || (*pass++ = 0) || 63 !(eol = strchr(pass, '\n')) || (*eol++ = 0) ) 64 continue; 65 66 if( !uh_auth_add(line, user, pass) ) 67 { 68 fprintf(stderr, 69 "Can not manage more than %i basic auth realms, " 70 "will skip the rest\n", UH_LIMIT_AUTHREALMS 71 ); 72 73 break; 74 } 75 } 76 } 77 78 fclose(c); 79 } 41 80 } 42 81 … … 399 438 #endif 400 439 401 while( (opt = getopt(argc, argv, "fC:K:p:s:h:c:l:L:d: ")) > 0 )440 while( (opt = getopt(argc, argv, "fC:K:p:s:h:c:l:L:d:r:m:x:")) > 0 ) 402 441 { 403 442 switch(opt) … … 468 507 #ifdef HAVE_CGI 469 508 /* cgi prefix */ 470 case ' c':509 case 'x': 471 510 conf.cgi_prefix = optarg; 472 511 break; … … 502 541 break; 503 542 543 /* basic auth realm */ 544 case 'r': 545 conf.realm = optarg; 546 break; 547 548 /* md5 crypt */ 549 case 'm': 550 printf("%s\n", crypt(optarg, "$1$")); 551 exit(0); 552 break; 553 554 /* config file */ 555 case 'c': 556 conf.file = optarg; 557 break; 558 504 559 default: 505 560 fprintf(stderr, 506 561 "Usage: %s -p [addr:]port [-h docroot]\n" 507 " -p Bind to specified address and port, multiple allowed\n" 562 " -f Do not fork to background\n" 563 " -c file Configuration file, default is '/etc/httpd.conf'\n" 564 " -p [addr:]port Bind to specified address and port, multiple allowed\n" 508 565 #ifdef HAVE_TLS 509 " -s Like -p but provide HTTPS on this port\n" 510 " -C ASN.1 server certificate file\n" 511 " -K ASN.1 server private key file\n" 512 #endif 513 " -h Specify the document root, default is '.'\n" 514 " -f Do not fork to background\n" 566 " -s [addr:]port Like -p but provide HTTPS on this port\n" 567 " -C file ASN.1 server certificate file\n" 568 " -K file ASN.1 server private key file\n" 569 #endif 570 " -h directory Specify the document root, default is '.'\n" 515 571 #ifdef HAVE_LUA 516 " -l URL prefix for Lua handler, default is '/lua'\n"517 " -L Lua handler script, omit to disable Lua\n"572 " -l string URL prefix for Lua handler, default is '/lua'\n" 573 " -L file Lua handler script, omit to disable Lua\n" 518 574 #endif 519 575 #ifdef HAVE_CGI 520 " -c URL prefix for CGI handler, default is '/cgi-bin'\n" 521 #endif 522 " -d URL decode given string\n" 576 " -x string URL prefix for CGI handler, default is '/cgi-bin'\n" 577 #endif 578 " -d string URL decode given string\n" 579 " -r string Specify basic auth realm\n" 580 " -m string MD5 crypt given string\n" 523 581 "\n", argv[0] 524 582 ); … … 549 607 exit(1); 550 608 } 609 610 /* default realm */ 611 if( ! conf.realm ) 612 conf.realm = "Protected Area"; 613 614 /* config file */ 615 uh_config_parse(conf.file); 551 616 552 617 #ifdef HAVE_CGI -
luci/trunk/contrib/package/uhttpd/src/uhttpd.h
r5892 r5893 52 52 struct config { 53 53 char docroot[PATH_MAX]; 54 char *realm; 55 char *file; 54 56 #ifdef HAVE_CGI 55 57 char *cgi_prefix; … … 89 91 struct auth_realm { 90 92 char path[PATH_MAX]; 91 char realm[128];92 93 char user[32]; 93 94 char pass[128];
