Re: Running inside a chroot

2007-11-14 Thread Paul Whittaker
On 13/11/2007, Janusz Gumkowski <[EMAIL PROTECTED]> wrote:
> Looking at your directory tree, you should add:
> Control {
> Alias /
> Location /
> }
> inside Virtual{} block.

Thanks - that's what I was missing.

> Actually, I don't really think this is what you want, because the above will
> serve your whole chroot() tree to the world, including /etc and log files.
> Storing html files in a specified directory (say: /html) will definitely be
> a better choice:  Alias /Location /html

As it turns out, it's not only better because of that separation -
it's better because specifying a location of "/" causes Mathopd to
respond with 404 errors, even for valid requests!  This appears to be
a bug.  I have now got things working, and I observe the following
behaiour (Mathopd v1.5p5, Ubuntu 7.04 (Feisty), 2.6.20 kernel) using
the config file you posted:

  Location set to "/html" - works fine, as you demonstrated.

  Location set to "/" - gives me nothing but 404 Not Found errors

  Location set to "/." - works fine, if you did want to serve the root
directory.

Does anyone else get this behaviour?

Once again, thanks again for your help getting this working!

Paul.

> # cat mathopd.conf
> User www
> StayRoot Off
> RootDirectory /test
>
> Log /access.log
> ErrorLog /error.log
> Control {
>Types {
>text/html { * }
> }
> IndexNames  { index.html }
> }
>
> Server {
>Port 80
>Address 0.0.0.0
>Virtual {
> AnyHost
> Control {
> Alias /
> Location /html
> }
>}
> }


Re: Running inside a chroot

2007-11-13 Thread Janusz Gumkowski
On Sun, Nov 11, 2007 at 01:22:40PM +, Paul Whittaker wrote:
> Hello,
> 
> I'm looking for some help getting mathopd to serve pages when it's
> running inside a chroot using the RootDirectory config option.
> 
> [...]


> User www-data
> StayRoot Off  # Reduce possibility of leaving chroot if compromised.
> RootDirectory /var/www
> 
> Log access.log
> ErrorLog errors.log


Just to be safe, I would define these two with a full path, relative to the
chroot:  /access.log and /errors.log


> Control {
>Types {
>text/html { * }
>}

For your convenience, you might wish to add index declaration here:

IndexNames  { index.html }

> }
> 
> Server {
>Port 80
>Address 0.0.0.0
>Virtual {
>AnyHost # Without this I get a 400 Bad Request instead

And here is why it doesn't work:  you missed a Control{} block, so mathopd
doesn't know where your html files are stored.
Looking at your directory tree, you should add:
Control {
Alias /
Location /
}
inside Virtual{} block.
Actually, I don't really think this is what you want, because the above will
serve your whole chroot() tree to the world, including /etc and log files.
Storing html files in a specified directory (say: /html) will definitely be
a better choice:  Alias /Location /html


>}
> }



Here is my minimalistic working example:  (OpenBSD, sparc64 architecture,
mathopd 1.5p5, command-line: /usr/local/sbin/mathopd -n < /test/mathopd.conf)

# pwd
/test

# find . -ls
2412804 drwxr-xr-x3 root wheel 512 Nov 13 08:46 .
2412834 drwxr-xr-x2 root wheel 512 Nov 13 08:45 ./html
2412844 -rw-r--r--1 root wheel   8 Nov 13 08:45 
./html/index.html
2412854 -rw-r--r--1 www  wheel 815 Nov 13 08:50 ./access.log
2412864 -rw-r--r--1 www  wheel 519 Nov 13 08:50 ./error.log
2412824 -rw-r--r--1 root wheel 322 Nov 13 08:50 
./mathopd.conf

# cat mathopd.conf
User www
StayRoot Off
RootDirectory /test

Log /access.log
ErrorLog /error.log
Control {
   Types {
   text/html { * }
}
IndexNames  { index.html }
}

Server {
   Port 80
   Address 0.0.0.0
   Virtual {
AnyHost
Control {
Alias /
Location /html
}
   }
}





-- 
Janusz Gumkowski
http://www.am.torun.pl/~ja   PGP key ID: 0x61DF6E3A