Changeset 391

Show
Ignore:
Timestamp:
09/05/06 20:19:09 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/cherokee/Makefile.am

    r388 r391  
    548548 
    549549# 
     550# Validator mysql 
     551# 
     552if HAVE_MYSQL 
     553validator_mysql = \ 
     554validator_mysql.c \ 
     555validator_mysql.h 
     556 
     557libplugin_mysql_la_LDFLAGS = $(module_ldflags) 
     558libplugin_mysql_la_SOURCES = $(validator_mysql) 
     559libplugin_mysql_la_LIBADD  = $(MYSQL_LDFLAGS) 
     560libplugin_mysql_la_CFLAGS  = $(MYSQL_CFLAGS) 
     561 
     562if STATIC_VALIDATOR_MYSQL 
     563static_validator_mysql_src   = $(validator_mysql) 
     564static_validator_mysql_lib   = $(MYSQL_LDFLAGS) 
     565static_validator_mysql_flags = $(MYSQL_CFLAGS) 
     566else 
     567dynamic_validator_mysql_lib = libplugin_mysql.la 
     568endif 
     569endif 
     570 
     571 
     572# 
    550573# Balancer Round Robin 
    551574# 
     
    598621libcherokee_server_la_LDFLAGS = $(common_ldflags) 
    599622libcherokee_server_la_CFLAGS = \ 
    600 $(static_validator_htpasswd_flags) 
     623$(static_validator_htpasswd_flags) \ 
     624$(static_validator_mysql_flags) 
     625 
    601626libcherokee_server_la_LIBADD = \ 
    602627$(TLS_LIBS) \ 
     
    606631$(static_validator_ldap_lib)  \ 
    607632$(static_validator_htpasswd_lib) \ 
     633$(static_validator_mysql_lib) \ 
    608634$(static_handler_proxy_lib) \ 
    609635libcherokee-base.la 
     
    750776 
    751777libcherokee_server_la_SOURCES = \ 
    752 source.h \ 
    753 source.c \ 
    754 source_interpreter.h \ 
    755 source_interpreter.c \ 
    756778$(static_handler_file_src) \ 
    757779$(static_handler_admin_src) \ 
     
    780802$(static_validator_htdigest_src) \ 
    781803$(static_validator_htpasswd_src) \ 
     804$(static_validator_mysql_src) \ 
    782805\ 
    783806$(static_balancer_round_robin_src) \ 
     
    832855config_node.c \ 
    833856balancer.h \ 
    834 balancer.c  
     857balancer.c \ 
     858source.h \ 
     859source.c \ 
     860source_interpreter.h \ 
     861source_interpreter.c 
    835862 
    836863libcherokee_config_la_SOURCES = \ 
     
    903930$(dynamic_validator_htdigest_lib) \ 
    904931$(dynamic_validator_htpasswd_lib) \ 
     932$(dynamic_validator_mysql_lib) \ 
    905933$(dynamic_balancer_round_robin_lib)  
    906934 
  • cherokee/trunk/cherokee/main.c

    r390 r391  
    4646#endif  
    4747 
    48 #define BASIC_CONFIG                                                               
    49         "vserver!default!directory!/!handler  = common\n"                           
    50         "vserver!default!directory!/!priority = 1\n"                               
    51         "vserver!default!directory!/icons!handler = file\n"                         
    52         "vserver!default!directory!/icons!document_root = " CHEROKEE_ICONSDIR "\n" 
    53         "vserver!default!directory!/icons!priority = 2\n"                           
    54         "vserver!default!directory!/themes!handler = file\n"                        \ 
    55         "vserver!default!directory!/themes!document_root = " CHEROKEE_THEMEDIR "\n" \ 
    56         "vserver!default!directory!/themes!priority = 3\n"                          \ 
     48#define BASIC_CONFIG                                                                         
     49        "vserver!default!directory!/!handler  = common\n"                                    
     50        "vserver!default!directory!/!priority = 1\n"                                         
     51        "vserver!default!directory!/icons!handler = file\n"                                  
     52        "vserver!default!directory!/icons!document_root = " CHEROKEE_ICONSDIR "\n"           
     53        "vserver!default!directory!/icons!priority = 2\n"                                    
     54        "vserver!default!directory!/cherokee_themes!handler = file\n"                        \ 
     55        "vserver!default!directory!/cherokee_themes!document_root = " CHEROKEE_THEMEDIR "\n" \ 
     56        "vserver!default!directory!/cherokee_themes!priority = 3\n"                          \ 
    5757        "include = " CHEROKEE_CONFDIR "/mods-enabled\n" 
    5858 
     
    8181        if (ret != ret_ok) exit(3); 
    8282} 
     83 
    8384 
    8485static void 
  • cherokee/trunk/cherokee/validator.c

    r384 r391  
    333333 
    334334 
     335ret_t  
     336cherokee_validator_digest_check (cherokee_validator_t *validator, char *passwd, cherokee_connection_t *conn) 
     337{ 
     338        ret_t             ret; 
     339        cherokee_buffer_t a1   = CHEROKEE_BUF_INIT; 
     340        cherokee_buffer_t buf  = CHEROKEE_BUF_INIT; 
     341 
     342        /* Sanity check 
     343         */ 
     344        if (cherokee_buffer_is_empty (&validator->user) || 
     345            cherokee_buffer_is_empty (&validator->realm))  
     346                return ret_deny; 
     347 
     348        /* Build A1 
     349         */ 
     350        cherokee_buffer_add_va (&a1, "%s:%s:%s",  
     351                                validator->user.buf, 
     352                                validator->realm.buf, 
     353                                passwd); 
     354 
     355        cherokee_buffer_encode_md5_digest (&a1); 
     356 
     357        /* Build a possible response 
     358         */ 
     359        ret = cherokee_validator_digest_response (validator, a1.buf, &buf, conn); 
     360        if (unlikely(ret != ret_ok)) goto go_out; 
     361         
     362        /* Compare and return 
     363         */ 
     364        ret = cherokee_buffer_cmp_buf (&conn->validator->response, &buf); 
     365 
     366go_out: 
     367        cherokee_buffer_mrproper (&a1); 
     368        cherokee_buffer_mrproper (&buf); 
     369        return ret; 
     370} 
     371 
     372 
    335373static ret_t 
    336374add_method (char *method, void *data) 
  • cherokee/trunk/cherokee/validator.h

    r343 r391  
    106106ret_t cherokee_validator_parse_digest    (cherokee_validator_t *validator, char *str, cuint_t str_len); 
    107107ret_t cherokee_validator_digest_response (cherokee_validator_t *validator, char *A1, cherokee_buffer_t *buf, cherokee_connection_t *conn); 
     108ret_t cherokee_validator_digest_check    (cherokee_validator_t *validator, char *passwd, cherokee_connection_t *conn); 
    108109 
    109110/* Handler properties 
  • cherokee/trunk/cherokee/validator_htdigest.c

    r343 r391  
    208208        /* Compare and return 
    209209         */ 
    210         ret = (strcmp (conn->validator->response.buf, buf.buf) == 0) ? ret_ok : ret_error
     210        ret = cherokee_buffer_cmp_buf (&conn->validator->response, &buf)
    211211         
    212212go_out: 
  • cherokee/trunk/cherokee/validator_ldap.c

    r384 r391  
    107107        } 
    108108 
     109        /* Checks 
     110         */ 
     111        if (cherokee_buffer_is_empty (&props->basedn)) { 
     112                PRINT_ERROR_S ("ERROR: LDAP validator: An entry 'base_dn' is needed\n"); 
     113                return ret_error; 
     114        } 
     115        if (cherokee_buffer_is_empty (&props->filter)) { 
     116                PRINT_ERROR_S ("ERROR: LDAP validator: An entry 'filter' is needed\n"); 
     117                return ret_error; 
     118        } 
     119        if (cherokee_buffer_is_empty (&props->server)) { 
     120                PRINT_ERROR_S ("ERROR: LDAP validator: An entry 'server' is needed\n"); 
     121                return ret_error; 
     122        } 
     123 
    109124        return ret_ok; 
    110125} 
  • cherokee/trunk/cherokee/validator_plain.c

    r333 r391  
    5757        props = PROP_PLAIN(*_props); 
    5858 
     59        /* Read the properties 
     60         */ 
    5961        ret = cherokee_config_node_get (conf, "passwdfile", &subconf); 
    6062        if (ret == ret_ok) { 
     
    6264        } 
    6365 
     66        /* Check them 
     67         */ 
     68        if (cherokee_buffer_is_empty (&props->password_file)) { 
     69                PRINT_MSG_S ("plain validator needs a password file\n"); 
     70                return ret_error; 
     71        } 
     72 
    6473        return ret_ok; 
    6574} 
     
    7988        VALIDATOR(n)->check       = (validator_func_check_t)       cherokee_validator_plain_check; 
    8089        VALIDATOR(n)->add_headers = (validator_func_add_headers_t) cherokee_validator_plain_add_headers; 
    81             
    82         /* Checks 
    83          */ 
    84         if (cherokee_buffer_is_empty (&VAL_PLAIN_PROP(n)->password_file)) { 
    85                 PRINT_MSG_S ("plain validator needs a password file\n"); 
    86                 return ret_error; 
    87         } 
    88             
     90 
     91        /* Return obj 
     92         */ 
    8993        *plain = n; 
    9094        return ret_ok; 
     
    99103} 
    100104 
    101  
    102 static ret_t 
    103 check_digest (cherokee_validator_plain_t *plain, char *passwd, cherokee_connection_t *conn) 
    104 {                        
    105         ret_t                 ret; 
    106         cherokee_buffer_t     a1        = CHEROKEE_BUF_INIT; 
    107         cherokee_buffer_t     buf       = CHEROKEE_BUF_INIT; 
    108         cherokee_validator_t *validator = conn->validator; 
    109  
    110         /* Sanity check 
    111          */ 
    112         if (cherokee_buffer_is_empty (&validator->user) || 
    113             cherokee_buffer_is_empty (&validator->realm))  
    114                 return ret_deny; 
    115  
    116         /* Build A1 
    117          */ 
    118         cherokee_buffer_add_va (&a1, "%s:%s:%s",  
    119                                 validator->user.buf, 
    120                                 validator->realm.buf, 
    121                                 passwd); 
    122  
    123         cherokee_buffer_encode_md5_digest (&a1); 
    124  
    125         /* Build a possible response 
    126          */ 
    127         cherokee_validator_digest_response (VALIDATOR(plain), a1.buf, &buf, conn); 
    128  
    129         /* Check the response 
    130          */ 
    131         if (cherokee_buffer_is_empty (&conn->validator->response)) { 
    132                 ret = ret_error; 
    133                 goto go_out; 
    134         } 
    135          
    136         /* Compare and return 
    137          */ 
    138         ret = (strcmp (conn->validator->response.buf, buf.buf) == 0) ? ret_ok : ret_error; 
    139  
    140 go_out: 
    141         cherokee_buffer_mrproper (&a1); 
    142         cherokee_buffer_mrproper (&buf); 
    143         return ret; 
    144 } 
    145105 
    146106ret_t  
     
    150110        ret_t  ret; 
    151111 
    152         if ((conn->validator == NULL) || cherokee_buffer_is_empty(&conn->validator->user)) { 
     112        if (unlikely ((conn->validator == NULL) ||  
     113                      cherokee_buffer_is_empty(&conn->validator->user))) 
     114        { 
    153115                return ret_error; 
    154116        } 
    155117 
    156118        f = fopen (VAL_PLAIN_PROP(plain)->password_file.buf, "r");  
    157 //      f = fopen (plain->file_ref, "r"); 
    158119        if (f == NULL) { 
    159120                return ret_error; 
     
    216177 
    217178                case http_auth_digest: 
    218                         ret = check_digest (plain, pass, conn); 
     179                        ret = cherokee_validator_digest_check (VALIDATOR(plain), pass, conn); 
    219180                        if (ret == ret_ok) goto go_out; 
    220181                        break; 
  • cherokee/trunk/configure.in

    r379 r391  
    906906 
    907907dnl 
     908dnl Check for MySQL 4.0.0 support 
     909dnl 
     910AX_LIB_MYSQL(4.0.0) 
     911 
     912 
     913dnl 
    908914dnl WWW root directory 
    909915dnl 
     
    922928           [use_static_module="$use_static_module $enableval "],[]) 
    923929 
    924 modules="error_redir server_info file admin dirlist fcgi fastcgi scgi redir common nn cgi phpcgi proxy gzip ncsa combined w3c pam ldap htpasswd plain htdigest round_robin" 
     930modules="error_redir server_info file admin dirlist fcgi fastcgi scgi redir common nn cgi phpcgi proxy gzip ncsa combined w3c pam ldap mysql htpasswd plain htdigest round_robin" 
    925931 
    926932# Remove modules that will not be compiles 
     
    931937if test "x$have_ldap" != "xyes"; then 
    932938        modules=`echo $modules | sed s/ldap//` 
     939fi 
     940if test "x$have_mysql" != "xyes"; then 
     941        modules=`echo $modules | sed s/mysql//` 
    933942fi 
    934943if test "$have_crypt_lib $have_crypt_include" != "yes yes"; then 
     
    984993AM_CONDITIONAL(STATIC_VALIDATOR_PAM,          grep pam            $conf_h >/dev/null) 
    985994AM_CONDITIONAL(STATIC_VALIDATOR_LDAP,         grep ldap           $conf_h >/dev/null) 
     995AM_CONDITIONAL(STATIC_VALIDATOR_MYSQL,        grep mysql          $conf_h >/dev/null) 
    986996AM_CONDITIONAL(STATIC_VALIDATOR_HTPASSWD,     grep htpasswd       $conf_h >/dev/null) 
    987997AM_CONDITIONAL(STATIC_VALIDATOR_PLAIN,        grep plain          $conf_h >/dev/null) 
     
    10241034echo "Compatible PAM        $have_pam" 
    10251035echo "LDAP                  $have_ldap" 
     1036echo "MySQL                 $have_mysql" 
    10261037echo "crypt support         $crypt_type" 
    10271038echo