thttpd CGI vs. perl

thttpd CGI vs. perl

Post by David W Talmag » Tue, 26 Oct 1999 04:00:00



Would any of you with experience using thttpd with the '-r' (chroot)
option *and* perl scripts in cgi-bin please write to me and tell me
how you made it work.  I'm trying to do this under NetBSD.  I've
mirrored my /usr/pkg/lib/perl5 tree in /usr/pkg/www/usr/pkg/lib/perl5.
I've copied /usr/pkg/bin/perl* to /usr/pkg/www/usr/pkg/bin.  I've put
perl in /usr/pkg/www/cgi-bin.  All I get when I run my script is a
blank web page.  Blah.

The script works with the '-nor' (nochroot) option but I'm uneasy
about using that.

FWIF, my script uses strict, MIME::Base64, and CGI qw(:standard).

I couldn't find an answer in dejanews.

I asked the author, Mr. Poskanzer.  He suggested watching the open()s
revealed by truss and copying all that stuff to the www tree.  I think
I've done that by mirroring /usr/pkg/lib/perl5.

--

ITT Industries, Inc., Systems Division
Unsolicited advertising e-mail is not welcome.

 
 
 

thttpd CGI vs. perl

Post by Marc Slem » Tue, 26 Oct 1999 04:00:00



>Would any of you with experience using thttpd with the '-r' (chroot)
>option *and* perl scripts in cgi-bin please write to me and tell me
>how you made it work.  I'm trying to do this under NetBSD.  I've
>mirrored my /usr/pkg/lib/perl5 tree in /usr/pkg/www/usr/pkg/lib/perl5.
>I've copied /usr/pkg/bin/perl* to /usr/pkg/www/usr/pkg/bin.  I've put
>perl in /usr/pkg/www/cgi-bin.  All I get when I run my script is a
>blank web page.  Blah.

Well, stick a shell in the chrooted tree, chroot so you have
a shell in that chrooted tree (either using the chroot command if your
system has one or by writing a little C program that does it), and
try it.  

Quote:>The script works with the '-nor' (nochroot) option but I'm uneasy
>about using that.

I'm not sure how much trust I place in thttpd's request parsing
routines, so that may be wise.

 
 
 

thttpd CGI vs. perl

Post by Jef Poskanze » Wed, 27 Oct 1999 04:00:00



Quote:}I'm not sure how much trust I place in thttpd's request parsing
}routines, so that may be wise.

Mrow!!
---
Jef


       "Nuclear war would really set back cable." -- Ted Turner

 
 
 

thttpd CGI vs. perl

Post by David W Talmag » Wed, 27 Oct 1999 04:00:00




> >Would any of you with experience using thttpd with the '-r' (chroot)
> >option *and* perl scripts in cgi-bin please write to me and tell me
> >how you made it work.  I'm trying to do this under NetBSD.  I've
> >...
> Well, stick a shell in the chrooted tree, chroot so you have
> a shell in that chrooted tree (either using the chroot command if your
> system has one or by writing a little C program that does it), and
> try it.  

This is exactly the hint that I needed.  Thank you Mr. Slemko!  It
turns out that perl needed some libs from /usr/lib and it also needed
/usr/libexec/ld.so.  I copied them to /usr/pkg/www/usr/{lib,libexec}
and it all worked!  The next time I need to do something like this,
I'll be sure to run ldd on the executable.

In summary, to run Perl scripts from cgi-bin under thttpd with the
'-r' option, I duplicated /usr/pkg/lib/perl5 in
/usr/pkg/www/usr/pkg/lib/perl5, copied the libraries that ldd told me
that perl needed to /usr/pkg/www/usr/lib, copied perl* to
/usr/pkg/www/usr/pkg/bin (probably overkill, this), and copied perl to
/usr/pkg/www/cgi-bin.

If you point your browser at http://madison.dynip.com after about 8PM
US Eastern time tonight, you can see that I made it work by playing
with a working copy of Ben Reser's Echelon Armor thingie.  Mr. Reser
offers the source at http://ben.reser.org/echelon/.

David Talmage