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 Re: [patch] again, mod_userdir
Date Thu, 15 Feb 2001 02:37:03 GMT
Without objection, based on Brad and Greg's review, I'll commit this on the hour.

I would really rather wait for another pair of eyes, but I'm believing the most capable
of eyes are elsewhere.

This will pull the last remaining showstopper to the tag and roll I am aware of.  I'd
like to fix that date to tommorow, if Jim would be up to pulling it off.  Target for release,
Monday the 19th of February.

Bill

From: "Brad Nicholes" <BNICHOLES@novell.com>
Sent: Wednesday, February 14, 2001 2:53 PM


> +1

>>> "William A. Rowe, Jr." <wrowe@rowe-clan.net> Wednesday, February 14, 2001
7:34:09 AM >>>
From: "Brad Nicholes" <BNICHOLES@novell.com>
Sent: Monday, February 12, 2001 12:06 PM


> Bill,
>    The patch seemed to work fine in general on NetWare except for one case.  If the userdir

> is defined as vol1:/users/ the resulting directory path is vol1:/users//user which is

> invalid on NetWare because of the double /.  If I omit the trailing / on the Userdir

> definition, then everything works find.  The same problem occurs if I define Userdir

> as "http:/www.domain.com/users/"  .  where the filename or redirect is being contructed,

> it should check for a trailing / first before blindly concatenating one.

Thanks Brad... here's your fix.  This addresses Greg's and Brad's observations.

Guys, can I please ask for one more pair of -UNIX- eyes to go over this patch and test?
I'd like to get this committed this morning and fix in a date to tag and roll (Thursday pm?)

Bill


Index: modules/standard/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
--- modules/standard/mod_userdir.c 2001/01/25 22:59:36 1.48
+++ modules/standard/mod_userdir.c 2001/02/14 14:31:12
@@ -169,6 +169,15 @@
          * If the first (only?) value isn't one of our keywords, just copy
          * the string to the userdir string.
          */
+        if (!ap_os_is_path_absolute(arg) && !strchr(arg, ':'))
+#if defined(WIN32) || defined(NETWARE)
+            return "UserDir must specify an absolute redirect or absolute "
+                   "file path";
+#else
+            if (strchr(arg, '*'))
+                 return "UserDir cannot specify a both a relative path and "
+                        "'*' substitution";
+#endif
         s_cfg->userdir = ap_pstrdup(cmd->pool, arg);
 #if defined(WIN32) || defined(OS2) || defined(NETWARE)
         /* This is an incomplete path, so we cannot canonicalize it yet.
@@ -207,7 +216,6 @@
     const char *userdirs = s_cfg->userdir;
     const char *w, *dname;
     char *redirect;
-    char *x = NULL;
     struct stat statbuf;
 
     /*
@@ -266,43 +274,68 @@
     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 {
+                /* Not a redirect, not an absolute path, '*' token:
+                 * serves [homedir]/[UserDir arg]
+                 * something/ * /public_html
+                 * Shouldn't happen, we trap for this in set_user_dir
+                 */
+                return DECLINED;
+            }
+        }
+        else if (is_absolute) {
+            /* An absolute path, no * token:
+             * serves [UserDir arg]/[user]
+             * /home + /~smith -> /home/smith
+             */
+            if (userdir[strlen(userdir) - 1] == '/')
+                filename = ap_pstrcat(r->pool, userdir, w, NULL);
             else
                 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
-            redirect = ap_pstrcat(r->pool, userdir, "/", w, dname, NULL);
+            /* A redirect, not an absolute path, no * token:
+             * serves [UserDir arg]/[user][dname]
+             * http://server/ + /~smith/foo -> http://server/smith/foo 
+             */
+            if (userdir[strlen(userdir) - 1] == '/')
+                redirect = ap_pstrcat(r->pool, userdir, w, dname, NULL);
+            else
+                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 */
+            /* Need to figure out home dirs on NT and NetWare 
+             * Shouldn't happen here, though, we trap for this in set_user_dir
+             */
             return DECLINED;
 #else                           /* WIN32 & NetWare */
             struct passwd *pw;





Mime
View raw message