Changeset 1494

Show
Ignore:
Timestamp:
12/29/2006 11:38:18 PM (21 months ago)
Author:
darix
Message:

- merged a few fixes from the 1.4.x branch to trunk

Location:
trunk
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/SConscript

    r1477 r1494  
    125125                'src' : [ 'mod_auth.c', 'http_auth_digest.c', 'http_auth.c' ],  
    126126                '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'] ] }, 
    128128        'mod_sql_vhost_core' : { 'src' : [ 'mod_sql_vhost_core.c' ] }, 
    129129        'mod_mysql_vhost' : { 'src' : [ 'mod_mysql_vhost.c' ], 'lib' : [ env['LIBMYSQL'] ] }, 
  • trunk/src/array.c

    r1465 r1494  
    261261        int i; 
    262262        for (i = 0; i < depth; i ++) { 
    263                 fprintf(stderr, "    "); 
     263                fprintf(stdout, "    "); 
    264264        } 
    265265} 
     
    305305        } 
    306306        if (oneline) { 
    307                 fprintf(stderr, "("); 
     307                fprintf(stdout, "("); 
    308308                for (i = 0; i < a->used; i++) { 
    309309                        data_unset *du = a->data[i]; 
    310310                        if (i != 0) { 
    311                                 fprintf(stderr, ", "); 
     311                                fprintf(stdout, ", "); 
    312312                        } 
    313313                        du->print(du, depth + 1); 
    314314                } 
    315                 fprintf(stderr, ")"); 
     315                fprintf(stdout, ")"); 
    316316                return 0; 
    317317        } 
    318318 
    319319        maxlen = array_get_max_key_length(a); 
    320         fprintf(stderr, "(\n"); 
     320        fprintf(stdout, "(\n"); 
    321321        for (i = 0; i < a->used; i++) { 
    322322                data_unset *du = a->data[i]; 
     
    326326 
    327327                        if (i && (i % 5) == 0) { 
    328                                 fprintf(stderr, "# %zd\n", i); 
     328                                fprintf(stdout, "# %zd\n", i); 
    329329                                array_print_indent(depth + 1); 
    330330                        } 
    331                         fprintf(stderr, "\"%s\"", du->key->ptr); 
     331                        fprintf(stdout, "\"%s\"", du->key->ptr); 
    332332                        for (j = maxlen - strlen(du->key->ptr); j > 0; j --) { 
    333                                 fprintf(stderr, " "); 
     333                                fprintf(stdout, " "); 
    334334                        } 
    335                         fprintf(stderr, " => "); 
     335                        fprintf(stdout, " => "); 
    336336                } 
    337337                du->print(du, depth + 1); 
    338                 fprintf(stderr, ",\n"); 
     338                fprintf(stdout, ",\n"); 
    339339        } 
    340340        if (!(i && (i - 1 % 5) == 0)) { 
    341341                array_print_indent(depth + 1); 
    342                 fprintf(stderr, "# %zd\n", i); 
     342                fprintf(stdout, "# %zd\n", i); 
    343343        } 
    344344        array_print_indent(depth); 
    345         fprintf(stderr, ")"); 
     345        fprintf(stdout, ")"); 
    346346 
    347347        return 0; 
  • trunk/src/configfile-glue.c

    r1409 r1494  
    6060                                        } else { 
    6161                                                log_error_write(srv, __FILE__, __LINE__, "sssd", 
    62                                                                 "the key of and array can only be a string or a integer, variable:", 
     62                                                                "the key of an array can only be a string or a integer, variable:", 
    6363                                                                cv[i].key, "type:", da->value->data[j]->type); 
    6464 
     
    103103                                } 
    104104 
    105                                 log_error_write(srv, __FILE__, __LINE__, "ssb", "get 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); 
    106106 
    107107                                return -1; 
  • trunk/src/http_auth.c

    r1349 r1494  
    3939# include "md5.h" 
    4040#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 */ 
    4156 
    4257handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s); 
     
    406421} 
    407422 
     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 
     432static 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 
     443static 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 
    408595/** 
    409596 * 
     
    442629                } 
    443630        } 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 { 
    444639#ifdef HAVE_CRYPT 
    445640                char salt[32]; 
  • trunk/src/mod_cml.c

    r1349 r1494  
    178178        buffer *b; 
    179179        char *c; 
    180         int ret; 
    181180 
    182181        /* cleanup basedir */ 
     
    204203         *   - get-param-based 
    205204         */ 
    206  
    207205        return cache_parse_lua(srv, con, p, cml_file); 
    208  
    209206} 
    210207 
  • trunk/src/mod_cml_lua.c

    r1349 r1494  
    459459#else 
    460460int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn) { 
     461        UNUSED(srv); 
     462        UNUSED(con); 
     463        UNUSED(p); 
     464        UNUSED(fn); 
    461465        /* error */ 
    462466        return -1; 
  • trunk/src/mod_dirlisting.c

    r1466 r1494  
    517517                "</h2>\n" 
    518518                "<div class=\"list\">\n" 
    519                 "<table cellpadding=\"0\" cellspacing=\"0\">\n" 
     519                "<table summary=\"Directory Listing\" cellpadding=\"0\" cellspacing=\"0\">\n" 
    520520                "<thead>" 
    521521                "<tr>" 
  • trunk/src/mod_fastcgi.c

    r1349 r1494  
    2424#include "stat_cache.h" 
    2525 
     26#ifdef HAVE_FASTCGI_FASTCGI_H 
     27#include <fastcgi/fastcgi.h> 
     28#else 
     29#ifdef HAVE_FASTCGI_H 
     30#include <fastcgi.h> 
     31#else 
    2632#include "fastcgi.h" 
     33#endif 
     34#endif /* HAVE_FASTCGI_FASTCGI_H */ 
    2735#include <stdio.h> 
    2836 
  • trunk/src/mod_status.c

    r1466 r1494  
    174174                BUFFER_APPEND_STRING_CONST(b, "<th class=\"status\"><a href=\"#\" class=\"sortheader\" onclick=\"resort(this);return false;\">"); 
    175175                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"); 
    177177        } else { 
    178178                BUFFER_APPEND_STRING_CONST(b, "<th class=\"status\">"); 
     
    678678                           " <body>\n" 
    679679                           "  <h1>" PACKAGE_NAME " " PACKAGE_VERSION "</h1>\n" 
    680                            "  <table border=\"1\">\n"); 
     680                           "  <table summary=\"status\" border=\"1\">\n"); 
    681681 
    682682        mod_status_header_append(b, "Server-Features"); 
  • trunk/src/mod_webdav.c

    r1466 r1494  
    4848 */ 
    4949 
    50  
     50#define WEBDAV_FILE_MODE WEBDAV_FILE_MODE 
     51#define WEBDAV_DIR_MODE  S_IRWXU | S_IRWXG | S_IRWXO 
    5152 
    5253/* plugin config for all request/connections */ 
     
    209210 
    210211                        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)); 
    212215                                return HANDLER_ERROR; 
    213216                        } 
     
    669672        } 
    670673 
    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))) { 
    672675                /* opening the destination failed for some reason */ 
    673676                switch(errno) { 
     
    774777                        } else if (S_ISDIR(st.st_mode)) { 
    775778                                /* a directory */ 
    776                                 if (-1 == mkdir(d.path->ptr, 0700) && 
     779                                if (-1 == mkdir(d.path->ptr, WEBDAV_DIR_MODE) && 
    777780                                    errno != EEXIST) { 
    778781                                        /* WTH ? */ 
     
    11511154        int has_lock = 1; 
    11521155 
    1153         UNUSED(srv); 
    1154  
    11551156#ifdef USE_LOCKS 
    11561157        data_string *ds; 
    11571158 
     1159        UNUSED(srv); 
     1160 
    11581161        /** 
    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 
    11701164         * 
    11711165         * X-Litmus: locks: 11 (owner_modify) 
    11721166         * 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 
    11731170         * 
    11741171         * X-Litmus: locks: 16 (fail_cond_put) 
    11751172         * If: (<DAV:no-lock> ["-1622396671"]) 
     1173         * - untagged: 
     1174         *   go on if the resource has the etag [...] and the lock 
    11761175         */ 
    11771176        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                 **/ 
    11781181        } else { 
    11791182                /* we didn't provided a lock-token -> */ 
     
    11921195                } 
    11931196        } 
     1197#else 
     1198        UNUSED(srv); 
    11941199#endif 
    11951200 
     
    14961501                /* let's create the directory */ 
    14971502 
    1498                 if (-1 == mkdir(con->physical.path->ptr, 0700)) { 
     1503                if (-1 == mkdir(con->physical.path->ptr, WEBDAV_DIR_MODE)) { 
    14991504                        switch(errno) { 
    15001505                        case EPERM: 
     
    16541659                        } 
    16551660 
    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))) { 
    16571662                                switch (errno) { 
    16581663                                case ENOENT: 
     
    16781683 
    16791684                        /* 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))) { 
    16811686                                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))) { 
    16831688                                        /* we can't open the file */ 
    16841689                                        con->http_status = 403; 
     
    18861891 
    18871892                        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)) { 
    18891894                                        con->http_status = 403; 
    18901895                                        return HANDLER_FINISHED; 
     
    18971902                                } else { 
    18981903                                        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)) { 
    19001905                                                con->http_status = 403; 
    19011906                                                return HANDLER_FINISHED; 
     
    23092314 
    23102315                                                        sqlite3_bind_text(stmt, 3, 
    2311                                                                           lockscope, 
     2316                                                                          (const char *)lockscope, 
    23122317                                                                          xmlStrlen(lockscope), 
    23132318                                                                          SQLITE_TRANSIENT); 
    23142319 
    23152320                                                        sqlite3_bind_text(stmt, 4, 
    2316                                                                           locktype, 
    2317                                                                           xmlStrlen(locktype), 
     2321                                                                          (const char *)locktype, 
     2322                                                                          +xmlStrlen(locktype), 
    23182323                                                                          SQLITE_TRANSIENT); 
    23192324 
     
    23352340 
    23362341                                                        /* 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); 
    23382343 
    23392344                                                        con->http_status = 201; 
  • trunk/src/plugin.c

    r1490 r1494  
    244244                } 
    245245#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))) { 
    247247                        log_error_write(srv, __FILE__, __LINE__, "sbs", "dlopen() failed for:", 
    248248                                        srv->tmp_buf, dlerror()); 
  • trunk/src/response.c

    r1467 r1494  
    169169                 * - query 
    170170                 * 
    171                  * (scheme)://(authority)(path)?(query) 
     171                 * (scheme)://(authority)(path)?(query)#fragment 
    172172                 * 
    173173                 * 
     
    183183                config_patch_connection(srv, con, COMP_HTTP_USERAGENT); /* User-Agent:  */ 
    184184                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                } 
    185191 
    186192                /** extract query string from request.uri */ 
  • trunk/src/spawn-fcgi.c

    r1403 r1494