From dc799127a0e7b0599248dd9669652aeb4af59454 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 25 Jan 2013 23:27:03 +0000 Subject: [PATCH] run-mason.cgi: seems to work --- run-mason.cgi | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 run-mason.cgi diff --git a/run-mason.cgi b/run-mason.cgi new file mode 100755 index 0000000..3f42cc5 --- /dev/null +++ b/run-mason.cgi @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w + +use HTML::Mason::CGIHandler; +use strict; +use POSIX; + +my $script_filename = $ENV{'SCRIPT_FILENAME'}; +my $basis = shift @ARGV; +sub absify ($) { $_[0] =~ m#^/# ? $_[0] : "$basis/$_[0]"; } +my $perllib = absify shift @ARGV; +my $comp_root = absify shift @ARGV; + +unshift @INC, $perllib; + +my $pathsofar = $comp_root; +die "$pathsofar $!" unless stat $pathsofar; + +system 'printenv |sort >&2'; + +my $path_info = $ENV{'PATH_INFO'}; +$path_info='' if !defined $path_info; + +foreach my $pathcomp (split m#/#, $path_info) { + next if $pathcomp eq ''; + $pathcomp =~ m/^[,_0-9A-Za-z]/ or path_fail('bad initial character'); + $pathcomp =~ m/[-+:.,_0-9A-Za-z]$/ or path_fail('bad final character'); + $pathcomp ne 'autohandler' or path_fail('refers to autohandler'); + $pathcomp ne 'dhandler' or path_fail('refers to dhandler'); + $pathsofar .= "/$pathcomp"; + next if access($pathsofar, X_OK); + die "$pathsofar $!" unless $!==&ENOENT or $!==&ENOTDIR; + last; +} + +our $h; +$h or $h = HTML::Mason::CGIHandler->new(comp_root => $comp_root); +$h->handle_request(); -- 2.30.2