Bug 9299 - UserDir cmd doesn't allow alternate dirs in some cases
Summary: UserDir cmd doesn't allow alternate dirs in some cases
Status: CLOSED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_userdir (show other bugs)
Version: 2.0.36
Hardware: Other Linux
: P5 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2002-05-22 04:25 UTC by jay ball
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jay ball 2002-05-22 04:25:48 UTC
In the source to mod_userdir, the usage comments says that you may 
combine UserDir entries to allow alternates.  The given example is:

UserDir public_html /usr/web http://www.xyz.com/users

which says to search for ~username/public_html then /usr/web/
username and finally do a redirect to http://www.xyz.com/users/username.  
However, this example does not work in Apache 2.0.36.

Imagine that we have "real" users of aaa and bbb (that is, with a login/
homedir), a set of "fake" users yyy and zzz with only a directory under /usr/
web, and a set of redirected users mmm and nnn.  Now, using the above 
configuration, point a browser to http://host/~aaa and ~bbb - it works.  
However ~yyy ~zzz ~mmm ~nnn do not work.  If you swap /usr/web and 
public_html, now ~yyy and ~zzz work, yet ~mmm and ~nnn do not work.  
Thus, there is no way to make all three alternates work on the same 
system and no way to do preference of order of search either.

The solution is to change the "return DECLINED" in the #if 
APR_HAS_USER section of mod_user to a "continue".  The diff -u is:

--- mod_userdir.c.orig  Tue May 21 16:03:22 2002
+++ mod_userdir.c       Tue May 21 16:03:50 2002
@@ -330,10 +330,10 @@
                 filename = apr_pstrcat(r->pool, homedir, "/", userdir,
                         NULL);
             }
             else {
                 -                return DECLINED;
                 +                continue;
                              }
 #else
-            return DECLINED;
+            continue;
 #endif
         }

-----end-diff----

Currently, /usr/web or /web/*/html style UserDir entries will search for the 
exact file for the username+dir and if it is not found, it move on to the next 
entry on the UserDir line.

However, for the "public_html" style UserDir entry, if we do not find 
~username/public_html then we decline to process this request and do 
not go to the next entry on the UserDir line.  So, end of request, 404.  If we 
change the "return DECLINED" to "continue" as above, then we can move
on to the next UserDir entry.

Entries in the form of http:// are redirects and must come last.  Apache
does not know if the user exists on the remote machine, thus it must
come last on the line.  This fact should be mentioned in the docs and
source.

Yet, the ability to even use alternates in not mentioned in the docs,
only in the source.  This needs to be added too.  I can write a paragraph if 
someone wants

(oh, and while we're working on mod_userdir.c, around line 351, can we 
change the tabs to spaces?  ;-)
Comment 1 rea 2002-07-15 23:38:51 UTC
Yes
I have set UserDir to public_html but in order the access the users web site 
you must add a / at the end line
~user/ instead of just ~user

Bug or my fault?
Comment 2 Joshua Slive 2002-07-16 14:14:46 UTC
rea: Please don't modify someone else's bug unless you are sure you are adding
useful information.  The problem you are reporting has nothing to do with the
original bug and is answered at
http://httpd.apache.org/docs/misc/FAQ.html#set-servername
Comment 3 Ryan Bloom 2002-09-28 06:11:18 UTC
I have committed the patch below with a slight modification, along with some
documentation.  Thank you for the bug report, and thank you for using Apache 2.0.