[cs631apue] Request like /~user/

Jan Schaumann jschauma at stevens.edu
Thu Dec 6 10:19:07 EST 2012


Chao Cui <ccui1 at stevens.edu> wrote:
 
> Can we just make it easy by just picking the file name, ignoring the
> directories.

No, that doesn't work.  But if you think that this makes things easier,
then I'll let you guys off easy and allow you to do the following:

If a request is made for a ~user location, then the path will be
entirely below that user's sws directory;  that is, you will treat the
user's sws directory as the document root for this request, and any
relative paths will thus be rooted under /home/users/sws/.

So a request like

/~user/../user/../testdir1/../user/../testdir/../subdir

will be resolved to

/home/user/sws/subdir

That is, a ~user request followed by a ".." will not lead you to the
server's original document root, which means that all you have to do is
set the current document root to /home/user/sws and not worry about
pathname resolution outside of the directory.  "GET /~user/../../../
HTTP/1.0" will be identical to "GET /~user/ HTTP/1.0".

-Jan


More information about the cs631apue mailing list