Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the App-Info CPAN distribution.

Report information
The Basics
Id: 50632
Status: open
Priority: 0/
Queue: App-Info

People
Owner: Nobody in particular
Requestors: MTHURN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.55
Fixed in: (no value)



Subject: new methods for finding the Apache cgi-bin directory
Attached is a patch which adds two new methods to the HTTP::Apache module to return the virtual and physical directory for cgi-bin (aka ScriptAlias). Plus a little test case! Thank you for your consideration -- - - Martin 'Kingpin' Thurn
Subject: diff-u.patch
cd ~/Modules/Other-Peoples/App-Info-0.55-MTHURN/ diff -urw "c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55" "c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN" Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN: Build Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN: Build.bat Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN: Makefile Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN: _build Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN: blib diff -urw c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55/lib/App/Info/HTTPD/Apache.pm c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN/lib/App/Info/HTTPD/Apache.pm --- c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55/lib/App/Info/HTTPD/Apache.pm 2008-07-18 12:18:35.000000000 -0400 +++ c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN/lib/App/Info/HTTPD/Apache.pm 2009-10-18 22:05:33.796875000 -0400 @@ -782,15 +782,18 @@ qr/^\s*Group\s+(.*)$/, qr/^\s*Port\s+(.*)$/, qr/^\s*DocumentRoot\s+"?([^"]+)"?\s*$/, + qr/^\s*ScriptAlias\s+( \S+?)\s"?(?:[^"\r\n]+)"?\s*$/x, + qr/^\s*ScriptAlias\s+(?:\S+?)\s"?( [^"\r\n]+)"?\s*$/x, ); - my ($usr, $grp, $prt, $droot) = $u->multi_search_file($conf, @regexen); + my ($usr, $grp, $prt, $droot, $cgibinv, $cgibinp) = $u->multi_search_file($conf, @regexen); # Issue a warning if we couldn't find the user and group. $self->error("Cannot parse user from file '$conf'") unless $usr; $self->error("Cannot parse group from file '$conf'") unless $grp; $self->error("Cannot parse port from file '$conf'") unless $prt; $self->error("Cannot parse DocumentRoot from file '$conf'") unless $droot; + $self->error("Cannot parse ScriptAlias from file '$conf'") if (! ($cgibinv && $cgibinp)); # Assign them anyway. - @{$self}{qw(user group port doc_root)} = ($usr, $grp, $prt, $droot); + @{$self}{qw(user group port doc_root cgibinv cgibinp)} = ($usr, $grp, $prt, $droot, $cgibinv, $cgibinp); }; sub user { @@ -973,6 +976,118 @@ ############################################################################## +=head3 cgibin_virtual + +Returns the virtual path where cgi-bin programs are stored. This value is +collected from Apache configuration file as returned by C<conf_file()>. + +B<Events:> + +=over 4 + +=item info + +Searching for Apache configuration file + +Executing `httpd -V` + +Parsing Apache configuration file + +=item error + +No Apache config file found + +Cannot parse user from file + +Cannot parse group from file + +Cannot parse port from file + +Cannot parse ScriptAlias from file + +=item unknown + +Location of httpd.conf file? + +Enter ScriptAlias virtual directory + +=back + +=cut + +sub cgibin_virtual + { + my $self = shift; + return unless $self->{executable}; + $parse_conf_file->($self) unless exists $self->{cgibinv}; + # Handle an unknown value. + $self->{cgibinv} = + $self->unknown( key => 'virtual cgi-bin', + prompt => 'Enter ScriptAlias (cgi-bin) virtual directory', + callback => $is_dir, + error => "Not a directory") + unless $self->{cgibinv}; + return $self->{cgibinv}; + } # cgibin_virtual + +############################################################################## + +=head3 cgibin_physical + +Returns the physical path where cgi-bin programs are stored. This value is +collected from Apache configuration file as returned by C<conf_file()>. + +B<Events:> + +=over 4 + +=item info + +Searching for Apache configuration file + +Executing `httpd -V` + +Parsing Apache configuration file + +=item error + +No Apache config file found + +Cannot parse user from file + +Cannot parse group from file + +Cannot parse port from file + +Cannot parse ScriptAlias from file + +=item unknown + +Location of httpd.conf file? + +Enter ScriptAlias physical directory + +=back + +=cut + +sub cgibin_physical + { + my $self = shift; + return unless $self->{executable}; + $parse_conf_file->($self) unless exists $self->{cgibinp}; + # Handle an unknown value. + $self->{cgibinp} = + $self->unknown( key => 'physical cgi-bin', + prompt => 'Enter ScriptAlias (cgi-bin) physical directory', + callback => $is_dir, + error => "Not a directory") + unless $self->{cgibinp}; + return $self->{cgibinp}; + } # cgibin_physical + +############################################################################## + =head3 executable my $executable = $apache->executable; Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN: pod2htmd.tmp Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN: pod2htmi.tmp diff -urw c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55/t/apache.t c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN/t/apache.t --- c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55/t/apache.t 2008-07-18 12:18:35.000000000 -0400 +++ c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN/t/apache.t 2009-10-18 22:06:33.343750000 -0400 @@ -3,7 +3,7 @@ # $Id: apache.t 3913 2008-05-15 03:46:28Z david $ use strict; -use Test::More tests => 31; +use Test::More tests => 33; use File::Spec::Functions; BEGIN { use_ok('App::Info::HTTPD::Apache') } @@ -61,6 +61,8 @@ is( $apache->magic_number, '19990320:16', "Test magic number" ); is( $apache->port, '80', "Test port" ); is( $apache->doc_root, '/test/doc/root', 'Test doc_root' ); +is( $apache->cgibin_virtual, '/test/cgi-bin/', 'Test cgibin_virtual'); +is( $apache->cgibin_physical, '/this/is/a/test/cgi-bin/', 'Test cgibin_physical'); ok( $apache->mod_so, "Test mod_so" ); is( $apache->home_url, 'http://httpd.apache.org/', "Get home URL" ); is( $apache->download_url, 'http://www.apache.org/dist/httpd/', Only in c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN/t: scripts diff -urw c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55/t/testlib/httpd.conf c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN/t/testlib/httpd.conf --- c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55/t/testlib/httpd.conf 2008-07-18 12:18:35.000000000 -0400 +++ c:/DOCUMENTS/MARTIN/Modules/Other-Peoples/App-Info-0.55-MTHURN/t/testlib/httpd.conf 2009-10-18 22:03:35.265625000 -0400 @@ -2,3 +2,4 @@ User nobody Group nobody DocumentRoot "/test/doc/root" +ScriptAlias /test/cgi-bin/ /this/is/a/test/cgi-bin/ Diff finished at Sun Oct 18 22:11:21
Subject: Re: [rt.cpan.org #50632] new methods for finding the Apache cgi-bin directory
Date: Mon, 19 Oct 2009 10:10:55 -0700
To: bug-App-Info [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
On Oct 18, 2009, at 7:14 PM, Martin Thurn via RT wrote: Show quoted text
> Attached is a patch which adds two new methods to the HTTP::Apache > module to return the virtual and physical directory for cgi-bin (aka > ScriptAlias). Plus a little test case! > Thank you for your consideration
Ooh, a test. Thanks! Committed in r4732. Source [here](https://svn.kineticode.com/App-Info/trunk ). Best, David