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
/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/libreadline.so.3.0
0cc64000 2cc74000 rlib 0 1 0 /usr/lib/libncursesw.so.12.0
03382000 2338b000 rlib 0 1 0 /usr/lib/libpthread.so.13.1
0bc20000 2bc56000 rlib 0 1 0 /usr/local/lib/mysql/libmysqlclient.so.20.0
06db6000 26dbe000 rlib 0 2 0 /usr/lib/libm.so.5.2
0d087000 2d093000 rlib 0 2 0 /usr/lib/libssl.so.16.0
0ee80000 2eebd000 rlib 0 2 0 /usr/lib/libcrypto.so.19.0
0f148000 2f14f000 rlib 0 2 0 /usr/lib/libz.so.4.1
0df80000 2dfb4000 rlib 0 1 0 /usr/lib/libc.so.58.0
07f9e000 07f9e000 rtld 0 1 0 /usr/libexec/ld.so

 

$ ldd /usr/local/bin/mysqldump
/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/libpthread.so.13.1
01d96000 21dcc000 rlib 0 1 0 /usr/local/lib/mysql/libmysqlclient.so.20.0
013ce000 213d6000 rlib 0 2 0 /usr/lib/libm.so.5.2
0e852000 2e85e000 rlib 0 2 0 /usr/lib/libssl.so.16.0
044bc000 244f9000 rlib 0 2 0 /usr/lib/libcrypto.so.19.0
0aec2000 2aec9000 rlib 0 2 0 /usr/lib/libz.so.4.1
0c5d0000 2c604000 rlib 0 1 0 /usr/lib/libc.so.58.0
039ec000 039ec000 rtld 0 1 0 /usr/libexec/ld.so

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/libmysqlclient.so.20.0 /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/libXpm.so.* /usr/X11R6/lib/libfreetype.so.* /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.