Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Cherokee: commits
[3413] cherokee/trunk/cherokee: Fixes a problem between EVHost and the File Exists rule plug-in.
 

Index | Next | Previous | View Flat


cherokee at cherokee-project

Jul 1, 2009, 10:58 AM


Views: 142
Permalink
[3413] cherokee/trunk/cherokee: Fixes a problem between EVHost and the File Exists rule plug-in.

Revision: 3413
http://svn.cherokee-project.com/changeset/3413
Author: alo
Date: 2009-07-01 19:58:18 +0200 (Wed, 01 Jul 2009)

Log Message:
-----------
Fixes a problem between EVHost and the File Exists rule plug-in. They
did not work together because of an invalid execution order. Now the
EVHost document root is evaluated in advance so the file exists rule
knows about it when checking.

Modified Paths:
--------------
cherokee/trunk/cherokee/connection-protected.h
cherokee/trunk/cherokee/connection.c
cherokee/trunk/cherokee/rule_exists.c
cherokee/trunk/cherokee/thread.c

Modified: cherokee/trunk/cherokee/connection-protected.h
===================================================================
--- cherokee/trunk/cherokee/connection-protected.h 2009-07-01 16:22:27 UTC (rev 3412)
+++ cherokee/trunk/cherokee/connection-protected.h 2009-07-01 17:58:18 UTC (rev 3413)
@@ -284,8 +284,11 @@
ret_t cherokee_connection_get_request (cherokee_connection_t *conn);
ret_t cherokee_connection_parse_range (cherokee_connection_t *conn);
int cherokee_connection_is_userdir (cherokee_connection_t *conn);
-ret_t cherokee_connection_build_local_directory (cherokee_connection_t *conn, cherokee_virtual_server_t *vsrv, cherokee_config_entry_t *entry);
-ret_t cherokee_connection_build_local_directory_userdir (cherokee_connection_t *conn, cherokee_virtual_server_t *vsrv, cherokee_config_entry_t *entry);
+
+ret_t cherokee_connection_build_local_directory (cherokee_connection_t *conn, cherokee_virtual_server_t *vsrv);
+ret_t cherokee_connection_build_local_directory_userdir (cherokee_connection_t *conn, cherokee_virtual_server_t *vsrv);
+ret_t cherokee_connection_set_custom_droot (cherokee_connection_t *conn, cherokee_config_entry_t *entry);
+
ret_t cherokee_connection_clean_error_headers (cherokee_connection_t *conn);
ret_t cherokee_connection_set_redirect (cherokee_connection_t *conn, cherokee_buffer_t *address);


Modified: cherokee/trunk/cherokee/connection.c
===================================================================
--- cherokee/trunk/cherokee/connection.c 2009-07-01 16:22:27 UTC (rev 3412)
+++ cherokee/trunk/cherokee/connection.c 2009-07-01 17:58:18 UTC (rev 3413)
@@ -1498,50 +1498,62 @@


ret_t
-cherokee_connection_build_local_directory (cherokee_connection_t *conn,
- cherokee_virtual_server_t *vsrv,
- cherokee_config_entry_t *entry)
+cherokee_connection_set_custom_droot (cherokee_connection_t *conn,
+ cherokee_config_entry_t *entry)
{
ret_t ret;

- /* Custom Document Root
+ /* Shortcut
*/
- if ((entry->document_root != NULL) &&
- (entry->document_root->len >= 1))
- {
- BIT_SET (conn->options, conn_op_document_root);
+ if ((entry->document_root == NULL) ||
+ (entry->document_root->len <= 0))
+ return ret_ok;

- /* Have a special DocumentRoot
- */
- ret = cherokee_buffer_add_buffer (&conn->local_directory, entry->document_root);
+ /* Have a special DocumentRoot
+ */
+ BIT_SET (conn->options, conn_op_document_root);

- /* It has to drop the webdir from the request:
- *
- * Directory /thing {
- * DocumentRoot /usr/share/this/rocks
- * }
- *
- * on petition: http://server/thing/cherokee
- * should read: /usr/share/this/rocks/cherokee
- */
- if (cherokee_buffer_is_empty (&conn->request_original)) {
- cherokee_buffer_add_buffer (&conn->request_original, &conn->request);
- }
+ cherokee_buffer_clean (&conn->local_directory);
+ ret = cherokee_buffer_add_buffer (&conn->local_directory, entry->document_root);

- if (conn->web_directory.len > 1) {
- cherokee_buffer_move_to_begin (&conn->request, conn->web_directory.len);
- }
+ /* It has to drop the webdir from the request:
+ *
+ * Directory /thing {
+ * DocumentRoot /usr/share/this/rocks
+ * }
+ *
+ * on petition: http://server/thing/cherokee
+ * should read: /usr/share/this/rocks/cherokee
+ */
+ if (cherokee_buffer_is_empty (&conn->request_original)) {
+ cherokee_buffer_add_buffer (&conn->request_original, &conn->request);
+ }
+
+ if (conn->web_directory.len > 1) {
+ cherokee_buffer_move_to_begin (&conn->request, conn->web_directory.len);
+ }
+
+ if ((conn->request.len >= 2) && (strncmp(conn->request.buf, "//", 2) == 0)) {
+ cherokee_buffer_move_to_begin (&conn->request, 1);
+ }

- if ((conn->request.len >= 2) && (strncmp(conn->request.buf, "//", 2) == 0)) {
- cherokee_buffer_move_to_begin (&conn->request, 1);
- }
+ TRACE(ENTRIES, "Set Custom Local Directory: '%s'\n", conn->local_directory.buf);
+ return ret_ok;
+}

- goto ok;
- }

+ret_t
+cherokee_connection_build_local_directory (cherokee_connection_t *conn,
+ cherokee_virtual_server_t *vsrv)
+{
+ ret_t ret;
+
/* Enhanced Virtual-Hosting
*/
if (vsrv->evhost != NULL) {
+ TRACE(ENTRIES, "About to evaluate EVHost. Now Document root is: '%s'\n",
+ conn->local_directory.buf ? conn->local_directory.buf : "");
+
ret = EVHOST(vsrv->evhost)->func_document_root (vsrv->evhost, conn);
if (ret == ret_ok)
goto ok;
@@ -1568,36 +1580,13 @@


ret_t
-cherokee_connection_build_local_directory_userdir (cherokee_connection_t *conn, cherokee_virtual_server_t *vsrv, cherokee_config_entry_t *entry)
+cherokee_connection_build_local_directory_userdir (cherokee_connection_t *conn,
+ cherokee_virtual_server_t *vsrv)
{
ret_t ret;
struct passwd pwd;
char tmp[1024];

- /* Has a defined DocumentRoot
- */
- if (entry->document_root &&
- entry->document_root->len >= 1)
- {
- BIT_SET (conn->options, conn_op_document_root);
-
- cherokee_buffer_add_buffer (&conn->local_directory, entry->document_root);
-
- if (cherokee_buffer_is_empty (&conn->request_original)) {
- cherokee_buffer_add_buffer (&conn->request_original, &conn->request);
- }
-
- if (conn->web_directory.len > 1) {
- cherokee_buffer_move_to_begin (&conn->request, conn->web_directory.len);
- }
-
- if ((conn->request.len >= 2) && (strncmp(conn->request.buf, "//", 2) == 0)) {
- cherokee_buffer_move_to_begin (&conn->request, 1);
- }
-
- return ret_ok;
- }
-
/* Default: it is inside the UserDir in home
*/
ret = cherokee_getpwnam (conn->userdir.buf, &pwd, tmp, sizeof(tmp));

Modified: cherokee/trunk/cherokee/rule_exists.c
===================================================================
--- cherokee/trunk/cherokee/rule_exists.c 2009-07-01 16:22:27 UTC (rev 3412)
+++ cherokee/trunk/cherokee/rule_exists.c 2009-07-01 17:58:18 UTC (rev 3413)
@@ -253,7 +253,7 @@
/* A previous non-final rule set a custom document root */
cherokee_buffer_add_buffer (tmp, ret_conf->document_root);
} else {
- cherokee_buffer_add_buffer (tmp, &CONN_VSRV(conn)->root);
+ cherokee_buffer_add_buffer (tmp, &conn->local_directory);
}

cherokee_buffer_add_str (tmp, "/");

Modified: cherokee/trunk/cherokee/thread.c
===================================================================
--- cherokee/trunk/cherokee/thread.c 2009-07-01 16:22:27 UTC (rev 3412)
+++ cherokee/trunk/cherokee/thread.c 2009-07-01 17:58:18 UTC (rev 3413)
@@ -896,6 +896,15 @@
} else {
rules = &CONN_VSRV(conn)->rules;
}
+
+ /* Local directory
+ */
+ if (cherokee_buffer_is_empty (&conn->local_directory)) {
+ if (is_userdir)
+ ret = cherokee_connection_build_local_directory_userdir (conn, CONN_VSRV(conn));
+ else
+ ret = cherokee_connection_build_local_directory (conn, CONN_VSRV(conn));
+ }

/* Check against the rule list
*/
@@ -905,21 +914,16 @@
continue;
}

+ /* Local directory
+ */
+ cherokee_connection_set_custom_droot (conn, &entry);
+
/* Set the logger of the connection
*/
if (entry.no_log != true) {
conn->logger_ref = CONN_VSRV(conn)->logger;
}

- /* Local directory
- */
- if (cherokee_buffer_is_empty (&conn->local_directory)) {
- if (is_userdir)
- ret = cherokee_connection_build_local_directory_userdir (conn, CONN_VSRV(conn), &entry);
- else
- ret = cherokee_connection_build_local_directory (conn, CONN_VSRV(conn), &entry);
- }
-
/* Check of the HTTP method is supported by the handler
*/
ret = cherokee_connection_check_http_method (conn, &entry);

Subject User Time
[3413] cherokee/trunk/cherokee: Fixes a problem between EVHost and the File Exists rule plug-in. cherokee at cherokee-project Jul 1, 2009, 10:58 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.