[cs631apue] Logging and Clarification on Instructions
Jan Schaumann
jschauma at stevens.edu
Mon Nov 12 18:09:51 EST 2012
tparisi <tparisi at stevens.edu> wrote:
> 1. What is the difference between the directory that is passed to ./sws
> and ~ in the HTTP message from the client? Is the ~ supposed to be
> translated into the path that was given to ./sws?
The directory given to sws(1) on the command-line is that from which all
requests are resolved. That is:
$ sws /usr/share/htdocs
would mean that requests would be resolved relative to that directory.
Requests for /~<username> however, are always resolved to a per-user
specific directory:
HTTP request absolute pathname
-----------------------------------------------------------------------
/ /usr/share/htdocs/index.html (or directory listing)
/foo.html /usr/share/htdocs/foo.html
/dir/bar.html /usr/share/htdocs/dir/bar.html
/~jschauma/ /home/jschauma/sws/index.html (or directory listing)
/~jschauma/foo.html /home/jschauma/sws/foo.html
/dir/../foo.html /usr/share/htdocs/foo.html
/../../../foo.html /usr/share/htdocs/foo.html
/~bob/../foo.html /usr/share/htdocs/foo.html
The last two are important: you must not allow a user to request files
outside of the directory given to sws(1) at startup.
> 2. Does the CGI directory have to be lower in the filesystem hierarchy
> than the directory given to ./sws? For example, can the CGI directory be
> /home/tparisi while the root directory for ./sws is /home/tparisi/sws.
The given root directory and the directory given to '-c' can be entirely
different and the cgi directory need not be a subdirectory of the root
directory (though it _can_ be):
$ pwd
/home/jschauma
$ sws -c ./cgi-bin ./sws
HTTP request absolute pathname
------------------------------------------------------------------------
/ /home/jschauma/sws/index.html (or directory listing)
/cgi-bin/foo /home/jschauma/cgi-bin/foo
$ pwd
/home/jschauma
$ sws -c ./sws/cgi-bin ./sws
HTTP request absolute pathname
------------------------------------------------------------------------
/ /home/jschauma/sws/index.html (or directory listing)
/cgi-bin/foo /home/jschauma/sws/cgi-bin/foo
> 3. What debug is to be printed when the -d flag is specified? Is the
> error messages when something goes wrong enough or is there something
> else to print?
Any information you consider useful when debugging the server.
> 4. As far as logging goes, is there a system call that does this? I
> found out there is an "openlog" system call however that does not allow
> the user to specify the file to use.
We'll discuss this in a few minutes. :-)
-Jan
More information about the cs631apue
mailing list