commit dd6c05bd26697e8f4f1ee434b8382683f5b64f80
parent 0dcc22ba4ffc0e56bf2ad617e19abdb317160019
Author: kyle <kyle@getaddrinfo.net>
Date: Mon, 2 Nov 2015 20:23:21 -0700
fcgi: two small fixes
- run perl interpreter with -T as this daemon handles dirty input
- give the program half a chance to find the tt/ directory in a chroot
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/ps_fcgi b/ps_fcgi
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl -T
use strict;
use warnings;
@@ -58,9 +58,6 @@ my $uid = getpwnam($user) or die "error: user $user does not exist\n";
my $gid = getgrnam($group) or die "error: group $group does not exist\n";
chown $uid, $gid, $http_cfg{socket} or die "error: chown $uid:$gid: $!";
-my $config = { INCLUDE_PATH => "$http_cfg{htdocs}/tt" };
-my $template = Template->new($config) || die $Template::ERROR . "\n";
-
if (fork()) {
# parent
$0 = "ps_fcgi [priv]";
@@ -97,6 +94,14 @@ print "info: child: uid:gid appears to be $<:$(\n" if ($args{v});
$SIG{INT} = \&child_sig_handler;
$SIG{TERM} = \&child_sig_handler;
+# remove chroot dir from beginning of htdocs dir
+my $chroot_tt_dir = "$http_cfg{htdocs}/tt";
+$chroot_tt_dir =~ s/$http_cfg{chroot}//;
+print "chroot tt dir is $chroot_tt_dir\n";
+
+my $config = { INCLUDE_PATH => $chroot_tt_dir };
+my $template = Template->new($config) || die $Template::ERROR . "\n";
+
syslog(LOG_INFO, "child: ready");
print "info: child: ready\n" if ($args{v});