Neither one nor Many
Software engineering blog about my projects, geometry, visualization and music.
With Apache (2.2) you could get an generic "Internal Server Error" error message in case the cgi sends the wrong headers. There is probably a setting for this in Apache as well, but I always create a bash wrapper script. For example someapp.cgi:
#!/bin/bash printf "Content-type: text/html\n\n" /path/to/actual_appl
This immediately makes the output visible and you can comment the printf statement once fixed. This trick only makes sense if you don't have quick access to a debugger or a core dump.
There are plugins for apache AFAIK for running cgi applications in a chroot. I didn't experiment with these, as I simply use my (probably lame) bash wrapper here as well:
#!/bin/bash sudo -E /usr/bin/chroot /usr/local/src/some_jail /usr/bin/some_appl 2>&1
The -E flag means "preserve environment". To allow this you have to configure sudoers properly (visudo). Something like this:
wwwrun ALL=(ALL) SETENV: ALL, NOPASSWD : /usr/bin/chroot