I am unable to serve or execute a cgi file, and the cause seems to be that chroot is unable to find the cgi file when the permission is set to executable.$>ls -l /var/www/my/dir/test.cgi-rwxr-xr-x 1 root   daemon 67 May 19 15:45 /var/www/my/dir/test.cgi$> chroot /var/www/ /my/dir/test.cgichroot: /my/dir/test.cgi: No such file or directoryWhy can chroot not find the file?If I change the permissions to remove execution, $> chmod 644 /var/www/my/dir/test.cgi, then run the same chroot command, the file is found, but permission is denied.$> chroot /var/www/ /my/dir/test.cgichroot: /my/dir/test.cgi: Permission deniedThe system is OpenBSD 5.7. I was testing using chroot to try to mimic what the httpd webserver does, because in the log /var/log/daemon, there is a similar message from slowcgi after trying to access the file: slowcgi[15587] execve /my/dir/index.cgi: No such file or directory Thanks in advance.
chroot cannot find cgi file
webserver;chroot;openbsd;cgi
You also need perl and all the dependencies of it in your chroot.This files all have to be copied over to /var/www/usr/bin, /var/www/usr/lib and /var/www/usr/libexec:# ldd /usr/bin/perl/usr/bin/perl:        Start            End              Type Open Ref GrpRef Name        0000001b26c00000 0000001b27002000 exe  1    0   0      /usr/bin/perl        0000001da0006000 0000001da0418000 rlib 0    2   0      /usr/lib/libpthread.so.18.1        0000001d2b68b000 0000001d2bc26000 rlib 0    1   0      /usr/lib/libperl.so.17.0        0000001d6fed5000 0000001d702fd000 rlib 0    1   0      /usr/lib/libm.so.9.0        0000001d8d017000 0000001d8d423000 rlib 0    1   0      /usr/lib/libutil.so.12.1        0000001ddb924000 0000001ddbe10000 rlib 0    1   0      /usr/lib/libc.so.78.1        0000001d7f700000 0000001d7f700000 rtld 0    1   0      /usr/libexec/ld.so