Changeset 1494
- Timestamp:
- 12/29/2006 11:38:18 PM (21 months ago)
- Location:
- trunk
- Files:
-
- 15 modified
-
src/SConscript (modified) (1 diff)
-
src/array.c (modified) (3 diffs)
-
src/configfile-glue.c (modified) (2 diffs)
-
src/http_auth.c (modified) (3 diffs)
-
src/mod_cml.c (modified) (2 diffs)
-
src/mod_cml_lua.c (modified) (1 diff)
-
src/mod_dirlisting.c (modified) (1 diff)
-
src/mod_fastcgi.c (modified) (1 diff)
-
src/mod_status.c (modified) (2 diffs)
-
src/mod_webdav.c (modified) (13 diffs)
-
src/plugin.c (modified) (1 diff)
-
src/response.c (modified) (2 diffs)
-
src/spawn-fcgi.c (modified) (1 diff)
-
tests/fcgi-auth.c (modified) (1 diff)
-
tests/fcgi-responder.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SConscript
r1477 r1494 125 125 'src' : [ 'mod_auth.c', 'http_auth_digest.c', 'http_auth.c' ], 126 126 'lib' : [ env['LIBCRYPT'], env['LIBLDAP'], env['LIBLBER'] ] }, 127 'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'] ] },127 'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] }, 128 128 'mod_sql_vhost_core' : { 'src' : [ 'mod_sql_vhost_core.c' ] }, 129 129 'mod_mysql_vhost' : { 'src' : [ 'mod_mysql_vhost.c' ], 'lib' : [ env['LIBMYSQL'] ] }, -
trunk/src/array.c
r1465 r1494 261 261 int i; 262 262 for (i = 0; i < depth; i ++) { 263 fprintf(std err, " ");263 fprintf(stdout, " "); 264 264 } 265 265 } … … 305 305 } 306 306 if (oneline) { 307 fprintf(std err, "(");307 fprintf(stdout, "("); 308 308 for (i = 0; i < a->used; i++) { 309 309 data_unset *du = a->data[i]; 310 310 if (i != 0) { 311 fprintf(std err, ", ");311 fprintf(stdout, ", "); 312 312 } 313 313 du->print(du, depth + 1); 314 314 } 315 fprintf(std err, ")");315 fprintf(stdout, ")"); 316 316 return 0; 317 317 } 318 318 319 319 maxlen = array_get_max_key_length(a); 320 fprintf(std err, "(\n");320 fprintf(stdout, "(\n"); 321 321 for (i = 0; i < a->used; i++) { 322 322 data_unset *du = a->data[i]; … … 326 326 327 327 if (i && (i % 5) == 0) { 328 fprintf(std err, "# %zd\n", i);328 fprintf(stdout, "# %zd\n", i); 329 329 array_print_indent(depth + 1); 330 330 } 331 fprintf(std err, "\"%s\"", du->key->ptr);331 fprintf(stdout, "\"%s\"", du->key->ptr); 332 332 for (j = maxlen - strlen(du->key->ptr); j > 0; j --) { 333 fprintf(std err, " ");333 fprintf(stdout, " "); 334 334 } 335 fprintf(std err, " => ");335 fprintf(stdout, " => "); 336 336 } 337 337 du->print(du, depth + 1); 338 fprintf(std err, ",\n");338 fprintf(stdout, ",\n"); 339 339 } 340 340 if (!(i && (i - 1 % 5) == 0)) { 341 341 array_print_indent(depth + 1); 342 fprintf(std err, "# %zd\n", i);342 fprintf(stdout, "# %zd\n", i); 343 343 } 344 344 array_print_indent(depth); 345 fprintf(std err, ")");345 fprintf(stdout, ")"); 346 346 347 347 return 0; -
trunk/src/configfile-glue.c
r1409 r1494 60 60 } else { 61 61 log_error_write(srv, __FILE__, __LINE__, "sssd", 62 "the key of an darray can only be a string or a integer, variable:",62 "the key of an array can only be a string or a integer, variable:", 63 63 cv[i].key, "type:", da->value->data[j]->type); 64 64 … … 103 103 } 104 104 105 log_error_write(srv, __FILE__, __LINE__, "ssb", "g et a string but expected a short:", cv[i].key, ds->value);105 log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected a short:", cv[i].key, ds->value); 106 106 107 107 return -1; -
trunk/src/http_auth.c
r1349 r1494 39 39 # include "md5.h" 40 40 #endif 41 42 /** 43 * the $apr1$ handling is taken from apache 1.3.x 44 */ 45 46 /* 47 * The apr_md5_encode() routine uses much code obtained from the FreeBSD 3.0 48 * MD5 crypt() function, which is licenced as follows: 49 * ---------------------------------------------------------------------------- 50 * "THE BEER-WARE LICENSE" (Revision 42): 51 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you 52 * can do whatever you want with this stuff. If we meet some day, and you think 53 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 54 * ---------------------------------------------------------------------------- 55 */ 41 56 42 57 handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s); … … 406 421 } 407 422 423 #define APR_MD5_DIGESTSIZE 16 424 #define APR1_ID "$apr1$" 425 426 /* 427 * The following MD5 password encryption code was largely borrowed from 428 * the FreeBSD 3.0 /usr/src/lib/libcrypt/crypt.c file, which is 429 * licenced as stated at the top of this file. 430 */ 431 432 static void to64(char *s, unsigned long v, int n) 433 { 434 static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */ 435 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 436 437 while (--n >= 0) { 438 *s++ = itoa64[v&0x3f]; 439 v >>= 6; 440 } 441 } 442 443 static void apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes) { 444 /* 445 * Minimum size is 8 bytes for salt, plus 1 for the trailing NUL, 446 * plus 4 for the '$' separators, plus the password hash itself. 447 * Let's leave a goodly amount of leeway. 448 */ 449 450 char passwd[120], *p; 451 const char *sp, *ep; 452 unsigned char final[APR_MD5_DIGESTSIZE]; 453 ssize_t sl, pl, i; 454 MD5_CTX ctx, ctx1; 455 unsigned long l; 456 457 /* 458 * Refine the salt first. It's possible we were given an already-hashed 459 * string as the salt argument, so extract the actual salt value from it 460 * if so. Otherwise just use the string up to the first '$' as the salt. 461 */ 462 sp = salt; 463 464 /* 465 * If it starts with the magic string, then skip that. 466 */ 467 if (!strncmp(sp, APR1_ID, strlen(APR1_ID))) { 468 sp += strlen(APR1_ID); 469 } 470 471 /* 472 * It stops at the first '$' or 8 chars, whichever comes first 473 */ 474 for (ep = sp; (*ep != '\0') && (*ep != '$') && (ep < (sp + 8)); ep++) { 475 continue; 476 } 477 478 /* 479 * Get the length of the true salt 480 */ 481 sl = ep - sp; 482 483 /* 484 * 'Time to make the doughnuts..' 485 */ 486 MD5_Init(&ctx); 487 488 /* 489 * The password first, since that is what is most unknown 490 */ 491 MD5_Update(&ctx, pw, strlen(pw)); 492 493 /* 494 * Then our magic string 495 */ 496 MD5_Update(&ctx, APR1_ID, strlen(APR1_ID)); 497 498 /* 499 * Then the raw salt 500 */ 501 MD5_Update(&ctx, sp, sl); 502 503 /* 504 * Then just as many characters of the MD5(pw, salt, pw) 505 */ 506 MD5_Init(&ctx1); 507 MD5_Update(&ctx1, pw, strlen(pw)); 508 MD5_Update(&ctx1, sp, sl); 509 MD5_Update(&ctx1, pw, strlen(pw)); 510 MD5_Final(final, &ctx1); 511 for (pl = strlen(pw); pl > 0; pl -= APR_MD5_DIGESTSIZE) { 512 MD5_Update(&ctx, final, 513 (pl > APR_MD5_DIGESTSIZE) ? APR_MD5_DIGESTSIZE : pl); 514 } 515 516 /* 517 * Don't leave anything around in vm they could use. 518 */ 519 memset(final, 0, sizeof(final)); 520 521 /* 522 * Then something really weird... 523 */ 524 for (i = strlen(pw); i != 0; i >>= 1) { 525 if (i & 1) { 526 MD5_Update(&ctx, final, 1); 527 } 528 else { 529 MD5_Update(&ctx, pw, 1); 530 } 531 } 532 533 /* 534 * Now make the output string. We know our limitations, so we 535 * can use the string routines without bounds checking. 536 */ 537 strcpy(passwd, APR1_ID); 538 strncat(passwd, sp, sl); 539 strcat(passwd, "$"); 540 541 MD5_Final(final, &ctx); 542 543 /* 544 * And now, just to make sure things don't run too fast.. 545 * On a 60 Mhz Pentium this takes 34 msec, so you would 546 * need 30 seconds to build a 1000 entry dictionary... 547 */ 548 for (i = 0; i < 1000; i++) { 549 MD5_Init(&ctx1); 550 if (i & 1) { 551 MD5_Update(&ctx1, pw, strlen(pw)); 552 } 553 else { 554 MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE); 555 } 556 if (i % 3) { 557 MD5_Update(&ctx1, sp, sl); 558 } 559 560 if (i % 7) { 561 MD5_Update(&ctx1, pw, strlen(pw)); 562 } 563 564 if (i & 1) { 565 MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE); 566 } 567 else { 568 MD5_Update(&ctx1, pw, strlen(pw)); 569 } 570 MD5_Final(final,&ctx1); 571 } 572 573 p = passwd + strlen(passwd); 574 575 l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p, l, 4); p += 4; 576 l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p, l, 4); p += 4; 577 l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p, l, 4); p += 4; 578 l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p, l, 4); p += 4; 579 l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p, l, 4); p += 4; 580 l = final[11] ; to64(p, l, 2); p += 2; 581 *p = '\0'; 582 583 /* 584 * Don't leave anything around in vm they could use. 585 */ 586 memset(final, 0, sizeof(final)); 587 588 /* FIXME 589 */ 590 #define apr_cpystrn strncpy 591 apr_cpystrn(result, passwd, nbytes - 1); 592 } 593 594 408 595 /** 409 596 * … … 442 629 } 443 630 } else if (p->conf.auth_backend == AUTH_BACKEND_HTPASSWD) { 631 char sample[120]; 632 if (!strncmp(password->ptr, APR1_ID, strlen(APR1_ID))) { 633 /* 634 * The hash was created using $apr1$ custom algorithm. 635 */ 636 apr_md5_encode(pw, password->ptr, sample, sizeof(sample)); 637 return (strcmp(sample, password->ptr) == 0) ? 0 : 1; 638 } else { 444 639 #ifdef HAVE_CRYPT 445 640 char salt[32]; -
trunk/src/mod_cml.c
r1349 r1494 178 178 buffer *b; 179 179 char *c; 180 int ret;181 180 182 181 /* cleanup basedir */ … … 204 203 * - get-param-based 205 204 */ 206 207 205 return cache_parse_lua(srv, con, p, cml_file); 208 209 206 } 210 207 -
trunk/src/mod_cml_lua.c
r1349 r1494 459 459 #else 460 460 int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn) { 461 UNUSED(srv); 462 UNUSED(con); 463 UNUSED(p); 464 UNUSED(fn); 461 465 /* error */ 462 466 return -1; -
trunk/src/mod_dirlisting.c
r1466 r1494 517 517 "</h2>\n" 518 518 "<div class=\"list\">\n" 519 "<table cellpadding=\"0\" cellspacing=\"0\">\n"519 "<table summary=\"Directory Listing\" cellpadding=\"0\" cellspacing=\"0\">\n" 520 520 "<thead>" 521 521 "<tr>" -
trunk/src/mod_fastcgi.c
r1349 r1494 24 24 #include "stat_cache.h" 25 25 26 #ifdef HAVE_FASTCGI_FASTCGI_H 27 #include <fastcgi/fastcgi.h> 28 #else 29 #ifdef HAVE_FASTCGI_H 30 #include <fastcgi.h> 31 #else 26 32 #include "fastcgi.h" 33 #endif 34 #endif /* HAVE_FASTCGI_FASTCGI_H */ 27 35 #include <stdio.h> 28 36 -
trunk/src/mod_status.c
r1466 r1494 174 174 BUFFER_APPEND_STRING_CONST(b, "<th class=\"status\"><a href=\"#\" class=\"sortheader\" onclick=\"resort(this);return false;\">"); 175 175 buffer_append_string(b, key); 176 BUFFER_APPEND_STRING_CONST(b, "<span class=\"sortarrow\"> </span></a></th>\n");176 BUFFER_APPEND_STRING_CONST(b, "<span class=\"sortarrow\">:</span></a></th>\n"); 177 177 } else { 178 178 BUFFER_APPEND_STRING_CONST(b, "<th class=\"status\">"); … … 678 678 " <body>\n" 679 679 " <h1>" PACKAGE_NAME " " PACKAGE_VERSION "</h1>\n" 680 " <table border=\"1\">\n");680 " <table summary=\"status\" border=\"1\">\n"); 681 681 682 682 mod_status_header_append(b, "Server-Features"); -
trunk/src/mod_webdav.c
r1466 r1494 48 48 */ 49 49 50 50 #define WEBDAV_FILE_MODE WEBDAV_FILE_MODE 51 #define WEBDAV_DIR_MODE S_IRWXU | S_IRWXG | S_IRWXO 51 52 52 53 /* plugin config for all request/connections */ … … 209 210 210 211 if (SQLITE_OK != sqlite3_open(s->sqlite_db_name->ptr, &(s->sql))) { 211 log_error_write(srv, __FILE__, __LINE__, "s", "sqlite3_open failed"); 212 log_error_write(srv, __FILE__, __LINE__, "sbs", "sqlite3_open failed for", 213 s->sqlite_db_name, 214 sqlite3_errmsg(s->sql)); 212 215 return HANDLER_ERROR; 213 216 } … … 669 672 } 670 673 671 if (-1 == (ofd = open(dst->path->ptr, O_WRONLY|O_TRUNC|O_CREAT|(overwrite ? 0 : O_EXCL), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {674 if (-1 == (ofd = open(dst->path->ptr, O_WRONLY|O_TRUNC|O_CREAT|(overwrite ? 0 : O_EXCL), WEBDAV_FILE_MODE))) { 672 675 /* opening the destination failed for some reason */ 673 676 switch(errno) { … … 774 777 } else if (S_ISDIR(st.st_mode)) { 775 778 /* a directory */ 776 if (-1 == mkdir(d.path->ptr, 0700) &&779 if (-1 == mkdir(d.path->ptr, WEBDAV_DIR_MODE) && 777 780 errno != EEXIST) { 778 781 /* WTH ? */ … … 1151 1154 int has_lock = 1; 1152 1155 1153 UNUSED(srv);1154 1155 1156 #ifdef USE_LOCKS 1156 1157 data_string *ds; 1157 1158 1159 UNUSED(srv); 1160 1158 1161 /** 1159 * If can have 1160 * - <lock-token> 1161 * - [etag] 1162 * 1163 * there is NOT, AND and OR 1164 * and a list can be tagged 1165 * 1166 * (<lock-token>) is untagged 1167 * <tag> (<lock-token>) is tagged 1168 * 1169 * as long as we don't handle collections it is simple. :) 1162 * This implementation is more fake than real 1163 * we need a parser for the If: header to really handle the full scope 1170 1164 * 1171 1165 * X-Litmus: locks: 11 (owner_modify) 1172 1166 * If: <http://127.0.0.1:1025/dav/litmus/lockme> (<opaquelocktoken:2165478d-0611-49c4-be92-e790d68a38f1>) 1167 * - a tagged check: 1168 * if http://127.0.0.1:1025/dav/litmus/lockme is locked with 1169 * opaquelocktoken:2165478d-0611-49c4-be92-e790d68a38f1, go on 1173 1170 * 1174 1171 * X-Litmus: locks: 16 (fail_cond_put) 1175 1172 * If: (<DAV:no-lock> ["-1622396671"]) 1173 * - untagged: 1174 * go on if the resource has the etag [...] and the lock 1176 1175 */ 1177 1176 if (NULL != (ds = (data_string *)array_get_element(con->request.headers, "If"))) { 1177 /* Ooh, ooh. A if tag, now the fun begins. 1178 * 1179 * this can only work with a real parser 1180 **/ 1178 1181 } else { 1179 1182 /* we didn't provided a lock-token -> */ … … 1192 1195 } 1193 1196 } 1197 #else 1198 UNUSED(srv); 1194 1199 #endif 1195 1200 … … 1496 1501 /* let's create the directory */ 1497 1502 1498 if (-1 == mkdir(con->physical.path->ptr, 0700)) {1503 if (-1 == mkdir(con->physical.path->ptr, WEBDAV_DIR_MODE)) { 1499 1504 switch(errno) { 1500 1505 case EPERM: … … 1654 1659 } 1655 1660 1656 if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {1661 if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY, WEBDAV_FILE_MODE))) { 1657 1662 switch (errno) { 1658 1663 case ENOENT: … … 1678 1683 1679 1684 /* if the file doesn't exist, create it */ 1680 if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {1685 if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_TRUNC, WEBDAV_FILE_MODE))) { 1681 1686 if (errno == ENOENT && 1682 -1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {1687 -1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, WEBDAV_FILE_MODE))) { 1683 1688 /* we can't open the file */ 1684 1689 con->http_status = 403; … … 1886 1891 1887 1892 if (-1 == stat(p->physical.path->ptr, &st)) { 1888 if (-1 == mkdir(p->physical.path->ptr, 0700)) {1893 if (-1 == mkdir(p->physical.path->ptr, WEBDAV_DIR_MODE)) { 1889 1894 con->http_status = 403; 1890 1895 return HANDLER_FINISHED; … … 1897 1902 } else { 1898 1903 unlink(p->physical.path->ptr); 1899 if (-1 == mkdir(p->physical.path->ptr, 0700)) {1904 if (-1 == mkdir(p->physical.path->ptr, WEBDAV_DIR_MODE)) { 1900 1905 con->http_status = 403; 1901 1906 return HANDLER_FINISHED; … … 2309 2314 2310 2315 sqlite3_bind_text(stmt, 3, 2311 lockscope,2316 (const char *)lockscope, 2312 2317 xmlStrlen(lockscope), 2313 2318 SQLITE_TRANSIENT); 2314 2319 2315 2320 sqlite3_bind_text(stmt, 4, 2316 locktype,2317 xmlStrlen(locktype),2321 (const char *)locktype, 2322 +xmlStrlen(locktype), 2318 2323 SQLITE_TRANSIENT); 2319 2324 … … 2335 2340 2336 2341 /* looks like we survived */ 2337 webdav_lockdiscovery(srv, con, p->tmp_buf, lockscope,locktype, depth);2342 webdav_lockdiscovery(srv, con, p->tmp_buf, (const char *)lockscope, (const char *)locktype, depth); 2338 2343 2339 2344 con->http_status = 201; -
trunk/src/plugin.c
r1490 r1494 244 244 } 245 245 #else 246 if (NULL == (p->lib = dlopen(srv->tmp_buf->ptr, RTLD_ LAZY))) {246 if (NULL == (p->lib = dlopen(srv->tmp_buf->ptr, RTLD_NOW|RTLD_GLOBAL))) { 247 247 log_error_write(srv, __FILE__, __LINE__, "sbs", "dlopen() failed for:", 248 248 srv->tmp_buf, dlerror()); -
trunk/src/response.c
r1467 r1494 169 169 * - query 170 170 * 171 * (scheme)://(authority)(path)?(query) 171 * (scheme)://(authority)(path)?(query)#fragment 172 172 * 173 173 * … … 183 183 config_patch_connection(srv, con, COMP_HTTP_USERAGENT); /* User-Agent: */ 184 184 config_patch_connection(srv, con, COMP_HTTP_COOKIE); /* Cookie: */ 185 186 /** their might be a fragment which has to be cut away */ 187 if (NULL != (qstr = strchr(con->request.uri->ptr, '#'))) { 188 con->request.uri->used = qstr - con->request.uri->ptr; 189 con->request.uri->ptr[con->request.uri->used++] = '\0'; 190 } 185 191 186 192 /** extract query string from request.uri */ -
trunk/src/spawn-fcgi.c
r1403 r1494
