Mailing List Archive



Back to the month index Back to the list index

Brian Candler (B.Candler@pobox.com)
Mon, 27 Jan 1997 10:36:03 +0000 (GMT)


From: Brian Candler <B.Candler@pobox.com>
Message-Id: <199701271036.KAA00279@gazebo.candler.co.uk>
Subject: Re: [mSQL] mSQL from chroot'd httpd Server
Date: Mon, 27 Jan 1997 10:36:03 +0000 (GMT)

> Does anyone run mSQL 1 from a chroot'd httpd server using a local connection?
> There was some discussion on the mailing list last April but
> I didn't see a solution or that it was definitely possible.
>
> I'm getting the mSQL message "Can't connect to local MSQL server"
> on the connect call for /dev/msql from msql, relshow and php.
> Everything works fine if a host (even localhost) is specified).

Looks to me like the client code can't find the unix domain socket to
communicate with the server. By default for msql2 this is
/usr/local/Hughes/msql2.sock and is set in msql.conf; for msql1 it defaults
to /dev/msql and you have to edit common/site.h to change MSQL_UNIX_ADDR

If the server is chroot'd into another directory, then clearly it can't
access this file (well not really a file, but it's accessed through the
filesystem). But it *can* still open TCP connections; this is why
"localhost" works.

Proposed solution: move the socket file inside the chroot'd directory. Then
it should be accessible to the client, although it will have a different
path name (relative to the chroot'd directory rather than to the real root).
This is easily done in msql2 because you'd just have a different msql.conf
for the client and the server. With msql1 you might have to recompile with a
different common/site.h

e.g. if your server chroots to /var/httpd then you may wish to make the
socket file /var/httpd/conf/msql2.sock - but the chroot'd client would
access it as /conf/msql2.sock

For msql1, I think you may be able to cheat. Recompile msql with
common/site.h having "#define MSQL_UNIX_ADDR /var/httpd/conf/msql1.sock"

Then make a symlink from /var/httpd/var/httpd/conf/msql1.sock to
../../../conf/msql1.sock (yes that is /var/httpd/var/httpd... !)

   mkdir /var/httpd/var
   mkdir /var/httpd/var/httpd
   mkdir /var/httpd/var/httpd/conf
   ln -s ../../../conf/msql1.sock /var/httpd/var/httpd/conf/msql1.sock

The idea is that when the server starts, it will create
/var/httpd/conf/msql1.sock

When the chrooted client opens /var/httpd/conf/msql1.sock it will actually
be accessing [/var/httpd]/var/httpd/conf/msql1.sock, but the symlink will
redirect it back to [/var/httpd]/conf/msql1.sock

I've not tested this in a chroot() environment, but I have just tried making
a symlink to the socket for msql2 and changing msql.conf to access the
symlink, and it does work. But you must have the _client_ access the
symlink. If the server finds a symlink where it expects the socket to be
when it starts up, it will just replace it with the socket.

Brian.
--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!