Mysqldump and GD+freetype support in Openbsd’s apache chroot jail

Guide how to make mysqldump (database dump) and GD library with  freetype  support (needed for generation of CAPCHA)work in apache chroot jail. In this example we’ll use Openbsd 4.9.

Lets start with mysql и mysqldump

First lets find out, what libraries they use:

(this is example output)

$ ldd /usr/local/bin/mysql
Start End Type Open Ref GrpRef Name
1c000000 3c00e000 exe 1 0 0 /usr/local/bin/mysql
0f08e000 2f097000 rlib 0 1 0 /usr/lib/
0cc64000 2cc74000 rlib 0 1 0 /usr/lib/
03382000 2338b000 rlib 0 1 0 /usr/lib/
0bc20000 2bc56000 rlib 0 1 0 /usr/local/lib/mysql/
06db6000 26dbe000 rlib 0 2 0 /usr/lib/
0d087000 2d093000 rlib 0 2 0 /usr/lib/
0ee80000 2eebd000 rlib 0 2 0 /usr/lib/
0f148000 2f14f000 rlib 0 2 0 /usr/lib/
0df80000 2dfb4000 rlib 0 1 0 /usr/lib/
07f9e000 07f9e000 rtld 0 1 0 /usr/libexec/


$ ldd /usr/local/bin/mysqldump
Start End Type Open Ref GrpRef Name
1c000000 3c00b000 exe 1 0 0 /usr/local/bin/mysqldump
083da000 283e3000 rlib 0 1 0 /usr/lib/
01d96000 21dcc000 rlib 0 1 0 /usr/local/lib/mysql/
013ce000 213d6000 rlib 0 2 0 /usr/lib/
0e852000 2e85e000 rlib 0 2 0 /usr/lib/
044bc000 244f9000 rlib 0 2 0 /usr/lib/
0aec2000 2aec9000 rlib 0 2 0 /usr/lib/
0c5d0000 2c604000 rlib 0 1 0 /usr/lib/
039ec000 039ec000 rtld 0 1 0 /usr/libexec/

In Openbsd’s apache web server works in chroot jail in /var/www

We’ll make same directory structure in /var/www
mkdir -p /var/www/usr/local/bin
mkdir -p /var/www/usr/lib
mkdir -p /var/www/usr/local/lib

then copy all  in /var/www
cp /usr/local/bin/mysql /var/www/usr/local/bin/
cp /usr/local/bin/mysqldump /var/www/usr/local/bin/
cp /usr/local/lib/mysql/ /var/www/usr/local/lib/mysql/

copy in the same way all other libraries /usr/lib -> /var/www/usr/lib/
Copy  “sh” binary
cp /bin/sh /var/www/bin/

GD lib with freetype
We’ll need libs from xbase4.9.tgz package, so the easy way is to install that package.

Copy libXpm and libfreetype libs in /var/www/usr/lib

cp -p /usr/X11R6/lib/* /usr/X11R6/lib/* /var/www/usr/lib

След това инсталирайте gd и php5-gd

Install GD and php5-gd packages

pkg_add -i gd
pkg_add -i php5-gd

Don’t choose php5-gd_NO_X11

Check with browser your php info, you should see freetype support in GD section.

Comment are closed.