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] again, mod_userdir
Date Sat, 10 Feb 2001 17:12:42 GMT
Sorry I've been rather invisible this week, caught a rather nasty head/chest cold,
and the return flight back from SFO to Chicago completely wasted me.  I noticed there
has been no comment on this patch, and since we would all like to get a solid 1.3.18
out the door that -doesn't- have to be revisited later, I'd really appreciate some
code review and feedback.  PR7211 indicates this is still a problem.

My regression testing of the patch included the following successful paths:

    UserDir "d:\Documents and Settings\*\My Documents\My Website\"
    UserDir "d:\apache\users\*\"
    UserDir "d:\apache\users\"
    UserDir "\apache\users\"
    UserDir "http://www.rowe-clan.net/~*/"

On Win32 we fail (correctly) on this variant:

    UserDir "public_html"

The code is refactored to make the code paths nearly legible.  Nearly all the 
platform discrepancies are gone.  Here is the repost of that patch:

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/10 17:07:45
@@ -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