httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject [Patch 1.3.18] Refactored mod_userdir - Comments welcomed
Date Wed, 07 Feb 2001 18:01:25 GMT
We do have a new NT bug report 7211, although I am not certain it applies to any
legitimate use of mod_userdir.

I took [Roy's? Dean's?] comment that we should flip the is_redirect and is_absolute
tests to heart, and finally broke down and refactored this code so it is [perhaps]
more legible, and no longer contains the mutilitude of platform exceptions.

Need an absolute 3 +1's other than my own to put this to bed.  I'll be comparing
to the documented behavior in an hour or two, so please consider this preliminary.

Bill



Index: mod_userdir.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_userdir.c,v
retrieving revision 1.48
diff -u -r1.48 mod_userdir.c
--- mod_userdir.c 2001/01/25 22:59:36 1.48
+++ mod_userdir.c 2001/02/07 18:01:18
@@ -207,7 +207,6 @@
     const char *userdirs = s_cfg->userdir;
     const char *w, *dname;
     char *redirect;
-    char *x = NULL;
     struct stat statbuf;
 
     /*
@@ -266,41 +265,58 @@
     while (*userdirs) {
         const char *userdir = ap_getword_conf(r->pool, &userdirs);
         char *filename = NULL;
-#if defined(NETWARE) || defined(HAVE_DRIVE_LETTERS)
         int is_absolute = ap_os_is_path_absolute(userdir);
-#endif  
 
-        if (strchr(userdir, '*'))
-            x = ap_getword(r->pool, &userdir, '*');
-
- if (userdir[0] == '\0' || userdir[0] == '/') {
-            if (x) {
-#if defined(NETWARE) || defined(HAVE_DRIVE_LETTERS)
-                if (strchr(x, ':') && !is_absolute )
-#else /* !(NETWARE || HAVE_DRIVE_LETTERS) */
-                if (strchr(x, ':'))
-#endif
-  {
-                    redirect = ap_pstrcat(r->pool, x, w, userdir, dname, NULL);
-                    ap_table_setn(r->headers_out, "Location", redirect);
-                    return REDIRECT;
-                }
-                else
-                    filename = ap_pstrcat(r->pool, x, w, userdir, NULL);
+        if (strchr(userdir, '*')) {
+            /* token '*' embedded:
+             */
+            char *x = ap_getword(r->pool, &userdir, '*');
+            if (is_absolute) {
+                /* token '*' within absolute path
+                 * serves [UserDir arg-pre*][user][UserDir arg-post*]
+                 * /somepath/*/somedir + /~smith -> /somepath/smith/somedir
+                 */
+                filename = ap_pstrcat(r->pool, x, w, userdir, NULL);
+            }
+            else if (strchr(x, ':')) {
+                /* token '*' within a redirect path
+                 * serves [UserDir arg-pre*][user][UserDir arg-post*]
+                 * http://server/user/* + /~smith/foo -> http://server/user/smith/foo
+                 */
+                redirect = ap_pstrcat(r->pool, x, w, userdir, dname, NULL);
+                ap_table_setn(r->headers_out, "Location", redirect);
+                return REDIRECT;
             }
-            else
-                filename = ap_pstrcat(r->pool, userdir, "/", w, NULL);
+            else {
+                /* Not a redirect, not an absolute path, '*' token:
+                 * serves [homedir]/[UserDir arg]
+                 * something/*/public_html
+                 */
+                /* Yuck, what's up with that? */
+                return DECLINED;
+            }
+        }
+        else if (is_absolute) {
+            /* An absolute path, no * token:
+             * serves [UserDir arg]/[user]
+             * /home + /~smith -> /home/smith
+             */
+            filename = ap_pstrcat(r->pool, userdir, "/", w, NULL);
         }
-#if defined(NETWARE) || defined(HAVE_DRIVE_LETTERS)
-        else if (strchr(userdir, ':') && !is_absolute ) {
-#else /* !(NETWARE || HAVE_DRIVE_LETTERS) */
         else if (strchr(userdir, ':')) {
-#endif
+            /* A redirect, not an absolute path, no * token:
+             * serves [UserDir arg]/[user][dname]
+             * http://server/ + /~smith/foo -> http://server/smith/foo
+             */
             redirect = ap_pstrcat(r->pool, userdir, "/", w, dname, NULL);
             ap_table_setn(r->headers_out, "Location", redirect);
             return REDIRECT;
         }
         else {
+            /* Not a redirect, not an absolute path, no * token:
+             * serves [homedir]/[UserDir arg]
+             * e.g. /~smith -> /home/smith/public_html
+             */
 #if defined(WIN32) || defined(NETWARE)
             /* Need to figure out home dirs on NT and NetWare */
             return DECLINED;



Mime
View raw message