Changeset 391
- Timestamp:
- 09/05/06 20:19:09 (2 years ago)
- Files:
-
- cherokee/trunk/cherokee/Makefile.am (modified) (7 diffs)
- cherokee/trunk/cherokee/main.c (modified) (2 diffs)
- cherokee/trunk/cherokee/validator.c (modified) (1 diff)
- cherokee/trunk/cherokee/validator.h (modified) (1 diff)
- cherokee/trunk/cherokee/validator_htdigest.c (modified) (1 diff)
- cherokee/trunk/cherokee/validator_ldap.c (modified) (1 diff)
- cherokee/trunk/cherokee/validator_mysql.c (added)
- cherokee/trunk/cherokee/validator_mysql.h (added)
- cherokee/trunk/cherokee/validator_plain.c (modified) (6 diffs)
- cherokee/trunk/configure.in (modified) (5 diffs)
- cherokee/trunk/m4/mysql.m4 (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/cherokee/Makefile.am
r388 r391 548 548 549 549 # 550 # Validator mysql 551 # 552 if HAVE_MYSQL 553 validator_mysql = \ 554 validator_mysql.c \ 555 validator_mysql.h 556 557 libplugin_mysql_la_LDFLAGS = $(module_ldflags) 558 libplugin_mysql_la_SOURCES = $(validator_mysql) 559 libplugin_mysql_la_LIBADD = $(MYSQL_LDFLAGS) 560 libplugin_mysql_la_CFLAGS = $(MYSQL_CFLAGS) 561 562 if STATIC_VALIDATOR_MYSQL 563 static_validator_mysql_src = $(validator_mysql) 564 static_validator_mysql_lib = $(MYSQL_LDFLAGS) 565 static_validator_mysql_flags = $(MYSQL_CFLAGS) 566 else 567 dynamic_validator_mysql_lib = libplugin_mysql.la 568 endif 569 endif 570 571 572 # 550 573 # Balancer Round Robin 551 574 # … … 598 621 libcherokee_server_la_LDFLAGS = $(common_ldflags) 599 622 libcherokee_server_la_CFLAGS = \ 600 $(static_validator_htpasswd_flags) 623 $(static_validator_htpasswd_flags) \ 624 $(static_validator_mysql_flags) 625 601 626 libcherokee_server_la_LIBADD = \ 602 627 $(TLS_LIBS) \ … … 606 631 $(static_validator_ldap_lib) \ 607 632 $(static_validator_htpasswd_lib) \ 633 $(static_validator_mysql_lib) \ 608 634 $(static_handler_proxy_lib) \ 609 635 libcherokee-base.la … … 750 776 751 777 libcherokee_server_la_SOURCES = \ 752 source.h \753 source.c \754 source_interpreter.h \755 source_interpreter.c \756 778 $(static_handler_file_src) \ 757 779 $(static_handler_admin_src) \ … … 780 802 $(static_validator_htdigest_src) \ 781 803 $(static_validator_htpasswd_src) \ 804 $(static_validator_mysql_src) \ 782 805 \ 783 806 $(static_balancer_round_robin_src) \ … … 832 855 config_node.c \ 833 856 balancer.h \ 834 balancer.c 857 balancer.c \ 858 source.h \ 859 source.c \ 860 source_interpreter.h \ 861 source_interpreter.c 835 862 836 863 libcherokee_config_la_SOURCES = \ … … 903 930 $(dynamic_validator_htdigest_lib) \ 904 931 $(dynamic_validator_htpasswd_lib) \ 932 $(dynamic_validator_mysql_lib) \ 905 933 $(dynamic_balancer_round_robin_lib) 906 934 cherokee/trunk/cherokee/main.c
r390 r391 46 46 #endif 47 47 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" \ 57 57 "include = " CHEROKEE_CONFDIR "/mods-enabled\n" 58 58 … … 81 81 if (ret != ret_ok) exit(3); 82 82 } 83 83 84 84 85 static void cherokee/trunk/cherokee/validator.c
r384 r391 333 333 334 334 335 ret_t 336 cherokee_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 366 go_out: 367 cherokee_buffer_mrproper (&a1); 368 cherokee_buffer_mrproper (&buf); 369 return ret; 370 } 371 372 335 373 static ret_t 336 374 add_method (char *method, void *data) cherokee/trunk/cherokee/validator.h
r343 r391 106 106 ret_t cherokee_validator_parse_digest (cherokee_validator_t *validator, char *str, cuint_t str_len); 107 107 ret_t cherokee_validator_digest_response (cherokee_validator_t *validator, char *A1, cherokee_buffer_t *buf, cherokee_connection_t *conn); 108 ret_t cherokee_validator_digest_check (cherokee_validator_t *validator, char *passwd, cherokee_connection_t *conn); 108 109 109 110 /* Handler properties cherokee/trunk/cherokee/validator_htdigest.c
r343 r391 208 208 /* Compare and return 209 209 */ 210 ret = (strcmp (conn->validator->response.buf, buf.buf) == 0) ? ret_ok : ret_error;210 ret = cherokee_buffer_cmp_buf (&conn->validator->response, &buf); 211 211 212 212 go_out: cherokee/trunk/cherokee/validator_ldap.c
r384 r391 107 107 } 108 108 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 109 124 return ret_ok; 110 125 } cherokee/trunk/cherokee/validator_plain.c
r333 r391 57 57 props = PROP_PLAIN(*_props); 58 58 59 /* Read the properties 60 */ 59 61 ret = cherokee_config_node_get (conf, "passwdfile", &subconf); 60 62 if (ret == ret_ok) { … … 62 64 } 63 65 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 64 73 return ret_ok; 65 74 } … … 79 88 VALIDATOR(n)->check = (validator_func_check_t) cherokee_validator_plain_check; 80 89 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 */ 89 93 *plain = n; 90 94 return ret_ok; … … 99 103 } 100 104 101 102 static ret_t103 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 check111 */112 if (cherokee_buffer_is_empty (&validator->user) ||113 cherokee_buffer_is_empty (&validator->realm))114 return ret_deny;115 116 /* Build A1117 */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 response126 */127 cherokee_validator_digest_response (VALIDATOR(plain), a1.buf, &buf, conn);128 129 /* Check the response130 */131 if (cherokee_buffer_is_empty (&conn->validator->response)) {132 ret = ret_error;133 goto go_out;134 }135 136 /* Compare and return137 */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 }145 105 146 106 ret_t … … 150 110 ret_t ret; 151 111 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 { 153 115 return ret_error; 154 116 } 155 117 156 118 f = fopen (VAL_PLAIN_PROP(plain)->password_file.buf, "r"); 157 // f = fopen (plain->file_ref, "r");158 119 if (f == NULL) { 159 120 return ret_error; … … 216 177 217 178 case http_auth_digest: 218 ret = che ck_digest (plain, pass, conn);179 ret = cherokee_validator_digest_check (VALIDATOR(plain), pass, conn); 219 180 if (ret == ret_ok) goto go_out; 220 181 break; cherokee/trunk/configure.in
r379 r391 906 906 907 907 dnl 908 dnl Check for MySQL 4.0.0 support 909 dnl 910 AX_LIB_MYSQL(4.0.0) 911 912 913 dnl 908 914 dnl WWW root directory 909 915 dnl … … 922 928 [use_static_module="$use_static_module $enableval "],[]) 923 929 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"930 modules="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" 925 931 926 932 # Remove modules that will not be compiles … … 931 937 if test "x$have_ldap" != "xyes"; then 932 938 modules=`echo $modules | sed s/ldap//` 939 fi 940 if test "x$have_mysql" != "xyes"; then 941 modules=`echo $modules | sed s/mysql//` 933 942 fi 934 943 if test "$have_crypt_lib $have_crypt_include" != "yes yes"; then … … 984 993 AM_CONDITIONAL(STATIC_VALIDATOR_PAM, grep pam $conf_h >/dev/null) 985 994 AM_CONDITIONAL(STATIC_VALIDATOR_LDAP, grep ldap $conf_h >/dev/null) 995 AM_CONDITIONAL(STATIC_VALIDATOR_MYSQL, grep mysql $conf_h >/dev/null) 986 996 AM_CONDITIONAL(STATIC_VALIDATOR_HTPASSWD, grep htpasswd $conf_h >/dev/null) 987 997 AM_CONDITIONAL(STATIC_VALIDATOR_PLAIN, grep plain $conf_h >/dev/null) … … 1024 1034 echo "Compatible PAM $have_pam" 1025 1035 echo "LDAP $have_ldap" 1036 echo "MySQL $have_mysql" 1026 1037 echo "crypt support $crypt_type" 1027 1038 echo