You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ruben Safir <ru...@mrbrklyn.com> on 2014/09/15 06:22:26 UTC

lost directory indexes

I added a perl handler to my apache setup and I can't understand why I'm
losing the directory listings in my image and doc directories.  I need
to both squelch  rougue web querries

The apache conf looks like this:

<VirtualHost *:80>
    ServerAdmin ruben@mrbrklyn.com
    DocumentRoot "/usr/local/apache/htdocs/brooklyn"
    ServerName brooklyn-living.com
    DirectoryIndex index.html
    PerlModule Embperl
    Embperl_UseEnv        on
    ErrorLog logs/brooklyn_error_log
    CustomLog logs/brooklyn_access_log common
    <Directory /usr/local/apache/htdocs/brooklyn>
           Options     Indexes ExecCGI
           DirectoryIndex index.html
           <Files *.html>
           SetHandler  perl-script
           PerlResponseHandler URL_BLOCK
           PerlHandler Embperl
           </Files>
           AllowOverride None
           Order allow,deny
           Allow from all
    </Directory>
 <Directory /usr/local/apache/htdocs/brooklyn/images>
        Options Indexes FollowSymLinks
        SetHandler  perl-script
        PerlResponseHandler URL_BLOCK
    </Directory>
</VirtualHost>


and the URL_BLOCK script looks like this:
package URL_BLOCK;

use strict;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Const -compile => qw(:common);

sub handler{
        my $r = shift;
        my $gate = $r->unparsed_uri;
        print STDERR "YO $gate\n";
        return Apache2::Const::DECLINED unless defined $gate;
        if ($gate =~ m{///}){
                print STDERR "I have a match\n";
                $r->log_reason("Access Forbidden", $r->filename);
                return Apache2::Const::FORBIDDEN;
        }
        return Apache2::Const::DECLINED;

}

1;



RE: lost directory indexes

Posted by Mark Hedges <Ma...@Ticketmaster.com>.
On Mon, Sep 15, 2014 at 10:03:35PM -0400, Joseph Schaefer wrote:
> You have to recompile mod perl so its response handler
> hook runs before mod dir's.  Have them run first or really
> first instead of middle.

Could you XS-bind mod_dir and use it directly if there were no
further path args after the requested URI?

It looks like embperl did it, but I didn't look too far into it.

HTH.
Mark Hedges

Re: lost directory indexes

Posted by Ruben Safir <ru...@mrbrklyn.com>.
:)

You put almost as much effort into this as I, and I have to admit, this 
is fairly fustrating, and it is just an old bug, one that should
have been resolved long ago.  And I think the bug is in apache, not
mod_perl, but I could be wrong.  I was going to, on my next attempt on
this, try recompiling the apache and modperl code with some alterations
but then I discovered that I might not have correct information.

Is it that mod_dir has to run first BEFORE embperl
or does embperl have to run first, which is what 
we have been concluding.

I think mod_dir has to run FIRST... why?

Because if you get a directory, it needs to translate it to an html file
FIRST, fetched anded off to embperl and mod_perl.

My regular perl module though needs to go FIRST and then hand off to
mod_dir.  Why?  Because it is examining the url for nastiness.  Once it 
is ok, it should hand off to mod_dir... which seems to be what is
broken.

When I run embperl, which will only work with 

sethandler perl-script, and never with addhandler:  see below
it functions fine until I add the mod_perl module I wrote.  So 
mod_dir is probably supposed to be sliced between them.

<VirtualHost *:80>
    ServerAdmin ruben@mrbrklyn.com
    DocumentRoot "/usr/local/apache/htdocs/nylxs"
    ServerName www.nylxs.com
    DirectoryIndex index.html
    PerlModule Embperl
    Embperl_UseEnv        on
    ErrorLog logs/nylxs_error_log
    CustomLog logs/nylxs_access_log common
    <Directory /usr/local/apache/htdocs/nylxs>
           Options     Indexes ExecCGI
           DirectoryIndex index.html
           <Files *.html>
           SetHandler perl-script
#          PerlResponseHandler URL_BLOCK
           PerlHandler Embperl
           </Files>
           AllowOverride None
           Order allow,deny
           Allow from all
    </Directory>
</Virtualhost>



When I use AddHanlder with my custom mod_perl url module, the mod_dir
stuff works and it seems to handoff to mod_dir correctly

For example:
<VirtualHost *:80>
    ServerAdmin ruben@mrbrklyn.com
    DocumentRoot "/usr/local/apache/htdocs"
    ServerName www.mrbrklyn.com
    Options Indexes
    AddHandler perl-script *
    PerlTransHandler +URL_BLOCK
           <Files *.html>
           AddHandler perl-script *
           PerlHandler Embperl
           </Files>
    <Location "/resources">
        Options +Indexes +FollowSymLinks
    </Location>
    <Location "/images">
    #    AddHandler perl-script *
#       PerlTransHandler URL_BLOCK
    </Location>
    <Location "/pharmacy/sales">
           Deny from All
    </Location>
    ErrorLog logs/error_log
    CustomLog logs/access_log common
</VirtualHost>

~~~~~~~~~~~~``

Here, embperl silently fails (see http://www.mrbrklyn.com and the
localtime command is visable).
the URL_BLOCK works (try http://www.mrbrklyn.com/////index.html)
mod_dir functions
try: http://www.mrbrklyn.com/images/


On Thu, Sep 18, 2014 at 02:15:43AM -0400, Rick Myers wrote:
> On Wed, Sep 17, 2014 at 09:18:38PM -0400, Ruben Safir wrote:
> > On 09/17/2014 03:08 PM, Rick Myers wrote:
> > > o, just declining from the perl response simply drops you off
> > > into the void since there are no other responses even set up.
> > > 
> > > Does that make sense? I hope so. :-)
> > 
> > 
> > that has been my assessment thusly...
> 
> Just for fun, I dusted off the old mod_perl machine and took a stab at
> this.
> 
> If I put a new Location section in an existing VirtualHost, I got the
> same sort of result you're seeing. That is, mod_perl above the
> directory, mod_perl below the directory, but a 500 error on the
> directory itself.
> 
> The 500 was because it was trying to run the Perl code. And that was
> running Template, which didn't like being handed a directory.
> 
> No matter what I did though, I couldn't figure out how to get a
> directory index. I tried Trans, Fixup, MapToStorage, returning OK,
> returning DECLINED - I even read the Fine Manual - all with the same
> result. It insisted on running the Perl code.
> 
> Even after I gave up, it still bugged me. I eventually got around to
> setting up a new VirtualHost. Like so...
> 
>     <VirtualHost *>
> 
>         ServerName www.example.com
>         ServerAlias example.com
>         ServerAdmin webmaster@example.com
> 
>         DocumentRoot /home/dev/perl/lib/Experimental/public
> 
>         <Directory />
>             Order deny,allow
>             Deny from all
>             Options None
>             AllowOverride None
>         </Directory>
> 
>         <Directory /home/dev/perl/lib/Experimental/public>
>             Order allow,deny
>             Allow from all
>             Options Indexes
>             AllowOverride None
>         </Directory>
> 
>         <Location /mp>
>             SetHandler modperl
>             PerlResponseHandler Experimental::ResponseHandler
>         </Location>
> 
>     </VirtualHost>
> 
> And a module...
> 
>     package Experimental::ResponseHandler;
>     use strict;
>     use warnings;
> 
>     use Apache2::Const -compile => qw/OK DECLINED/;
> 
>     sub handler {
>         my $r = shift;
>         my $f = $r->filename;
>         warn "FILE: $f\n";
> 
>         if ( -d $f ) {
>             warn "DIR!\n";
>             return Apache2::Const::DECLINED;
>         }
> 
>         $r->print( 'Hi!' );
>         return Apache2::Const::OK;
>     }
> 
>     1;
> 
> And the index on /mp worked perfectly. Files below the directory got the
> Perl-generated response, and files above didn't trigger the handler.
> 
> >From there I tried to break it, without much success. The only thing I
> did that made any difference was to add a <Location /> section below the
> existing /mp section. Even then, it gave me a 403 and logged 'index
> forbidden by Options'.
> 
> So all I can say is, Beats Me.
> 
> I do know though, I've pulled my hair out too many times trying to
> figure out what eventually wound up being configuration merging
> problems. It's pretty whacked sometimes.
> 
> If you want to track it down further, go for it. I really don't care so
> much anymore after moving most of my stuff to Nginx/Dancer. I just
> thought I'd save you a few follicles. ;-)
> 
> HTH
> 
> Cheers,
> Rick
> 

-- 
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com 

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive 
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com 

Being so tracked is for FARM ANIMALS and and extermination camps, 
but incompatible with living as a free human being. -RI Safir 2013


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: lost directory indexes

Posted by Ruben Safir <ru...@mrbrklyn.com>.
:)

You put almost as much effort into this as I, and I have to admit, this 
is fairly fustrating, and it is just an old bug, one that should
have been resolved long ago.  And I think the bug is in apache, not
mod_perl, but I could be wrong.  I was going to, on my next attempt on
this, try recompiling the apache and modperl code with some alterations
but then I discovered that I might not have correct information.

Is it that mod_dir has to run first BEFORE embperl
or does embperl have to run first, which is what 
we have been concluding.

I think mod_dir has to run FIRST... why?

Because if you get a directory, it needs to translate it to an html file
FIRST, fetched anded off to embperl and mod_perl.

My regular perl module though needs to go FIRST and then hand off to
mod_dir.  Why?  Because it is examining the url for nastiness.  Once it 
is ok, it should hand off to mod_dir... which seems to be what is
broken.

When I run embperl, which will only work with 

sethandler perl-script, and never with addhandler:  see below
it functions fine until I add the mod_perl module I wrote.  So 
mod_dir is probably supposed to be sliced between them.

<VirtualHost *:80>
    ServerAdmin ruben@mrbrklyn.com
    DocumentRoot "/usr/local/apache/htdocs/nylxs"
    ServerName www.nylxs.com
    DirectoryIndex index.html
    PerlModule Embperl
    Embperl_UseEnv        on
    ErrorLog logs/nylxs_error_log
    CustomLog logs/nylxs_access_log common
    <Directory /usr/local/apache/htdocs/nylxs>
           Options     Indexes ExecCGI
           DirectoryIndex index.html
           <Files *.html>
           SetHandler perl-script
#          PerlResponseHandler URL_BLOCK
           PerlHandler Embperl
           </Files>
           AllowOverride None
           Order allow,deny
           Allow from all
    </Directory>
</Virtualhost>



When I use AddHanlder with my custom mod_perl url module, the mod_dir
stuff works and it seems to handoff to mod_dir correctly

For example:
<VirtualHost *:80>
    ServerAdmin ruben@mrbrklyn.com
    DocumentRoot "/usr/local/apache/htdocs"
    ServerName www.mrbrklyn.com
    Options Indexes
    AddHandler perl-script *
    PerlTransHandler +URL_BLOCK
           <Files *.html>
           AddHandler perl-script *
           PerlHandler Embperl
           </Files>
    <Location "/resources">
        Options +Indexes +FollowSymLinks
    </Location>
    <Location "/images">
    #    AddHandler perl-script *
#       PerlTransHandler URL_BLOCK
    </Location>
    <Location "/pharmacy/sales">
           Deny from All
    </Location>
    ErrorLog logs/error_log
    CustomLog logs/access_log common
</VirtualHost>

~~~~~~~~~~~~``

Here, embperl silently fails (see http://www.mrbrklyn.com and the
localtime command is visable).
the URL_BLOCK works (try http://www.mrbrklyn.com/////index.html)
mod_dir functions
try: http://www.mrbrklyn.com/images/


On Thu, Sep 18, 2014 at 02:15:43AM -0400, Rick Myers wrote:
> On Wed, Sep 17, 2014 at 09:18:38PM -0400, Ruben Safir wrote:
> > On 09/17/2014 03:08 PM, Rick Myers wrote:
> > > o, just declining from the perl response simply drops you off
> > > into the void since there are no other responses even set up.
> > > 
> > > Does that make sense? I hope so. :-)
> > 
> > 
> > that has been my assessment thusly...
> 
> Just for fun, I dusted off the old mod_perl machine and took a stab at
> this.
> 
> If I put a new Location section in an existing VirtualHost, I got the
> same sort of result you're seeing. That is, mod_perl above the
> directory, mod_perl below the directory, but a 500 error on the
> directory itself.
> 
> The 500 was because it was trying to run the Perl code. And that was
> running Template, which didn't like being handed a directory.
> 
> No matter what I did though, I couldn't figure out how to get a
> directory index. I tried Trans, Fixup, MapToStorage, returning OK,
> returning DECLINED - I even read the Fine Manual - all with the same
> result. It insisted on running the Perl code.
> 
> Even after I gave up, it still bugged me. I eventually got around to
> setting up a new VirtualHost. Like so...
> 
>     <VirtualHost *>
> 
>         ServerName www.example.com
>         ServerAlias example.com
>         ServerAdmin webmaster@example.com
> 
>         DocumentRoot /home/dev/perl/lib/Experimental/public
> 
>         <Directory />
>             Order deny,allow
>             Deny from all
>             Options None
>             AllowOverride None
>         </Directory>
> 
>         <Directory /home/dev/perl/lib/Experimental/public>
>             Order allow,deny
>             Allow from all
>             Options Indexes
>             AllowOverride None
>         </Directory>
> 
>         <Location /mp>
>             SetHandler modperl
>             PerlResponseHandler Experimental::ResponseHandler
>         </Location>
> 
>     </VirtualHost>
> 
> And a module...
> 
>     package Experimental::ResponseHandler;
>     use strict;
>     use warnings;
> 
>     use Apache2::Const -compile => qw/OK DECLINED/;
> 
>     sub handler {
>         my $r = shift;
>         my $f = $r->filename;
>         warn "FILE: $f\n";
> 
>         if ( -d $f ) {
>             warn "DIR!\n";
>             return Apache2::Const::DECLINED;
>         }
> 
>         $r->print( 'Hi!' );
>         return Apache2::Const::OK;
>     }
> 
>     1;
> 
> And the index on /mp worked perfectly. Files below the directory got the
> Perl-generated response, and files above didn't trigger the handler.
> 
> >From there I tried to break it, without much success. The only thing I
> did that made any difference was to add a <Location /> section below the
> existing /mp section. Even then, it gave me a 403 and logged 'index
> forbidden by Options'.
> 
> So all I can say is, Beats Me.
> 
> I do know though, I've pulled my hair out too many times trying to
> figure out what eventually wound up being configuration merging
> problems. It's pretty whacked sometimes.
> 
> If you want to track it down further, go for it. I really don't care so
> much anymore after moving most of my stuff to Nginx/Dancer. I just
> thought I'd save you a few follicles. ;-)
> 
> HTH
> 
> Cheers,
> Rick
> 

-- 
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com 

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive 
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com 

Being so tracked is for FARM ANIMALS and and extermination camps, 
but incompatible with living as a free human being. -RI Safir 2013


Re: lost directory indexes

Posted by Ruben Safir <ru...@mrbrklyn.com>.
On Mon, Sep 15, 2014 at 10:03:35PM -0400, Joseph Schaefer wrote:
> You have to recompile mod perl so its response handler hook runs before mod dir's.  Have them run first or really first instead of middle.


How do you do that.  Is the a change in the config file for the Apache
DSo to do that.  I compile modperl from apache.

Ruben
> 
> Sent from my iPhone
> 
> > On Sep 15, 2014, at 6:02 PM, Ruben Safir <ru...@mrbrklyn.com> wrote:
> > 
> > On Mon, Sep 15, 2014 at 05:40:00PM -0400, Ruben Safir wrote:
> >>>> 
> >>>> 
> >>>> Now the error log for an index request says:
> >>>> 
> >>>> [Mon Sep 15 12:14:09 2014] [error] [client 10.0.0.57] Attempt to serve
> >>>> directory: /usr/local/apache/htdocs/resources/, referer:
> >>>> http://www.mrbrklyn.com/
> >>>> INDEXES ON
> >>>> SYMLINKS OFF
> >>>> CGI OFF
> >>>> 
> >>>> 
> >>>> It knows that INDEXES is on but it is ignoring the config files fault.
> >>>> 
> >>>> I suppose I need to identify the directory request and then
> >>>> decline to respond to it.
> >>> 
> >>> Yes.
> >>> 
> >>>> But I have no idea how to do this.
> >>> 
> >>> Have you tried
> >>> 
> >>> return DECLINED; # ?
> >> 
> >> 
> >> I think I need return Apache2::Const::DECLINED;
> > 
> > This is the module that is failing to work
> > 
> > https://httpd.apache.org/docs/2.2/mod/mod_dir.html
> > 
> > As soon as you pull up mod_perl it stops working.  it will not pick up
> > from the response cycle once you interject a modperl module
> > 
> > 
> > 

-- 
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com 

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive 
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com 

Being so tracked is for FARM ANIMALS and and extermination camps, 
but incompatible with living as a free human being. -RI Safir 2013


Re: lost directory indexes

Posted by Joseph Schaefer <jo...@yahoo.com>.
You have to recompile mod perl so its response handler hook runs before mod dir's.  Have them run first or really first instead of middle.

Sent from my iPhone

> On Sep 15, 2014, at 6:02 PM, Ruben Safir <ru...@mrbrklyn.com> wrote:
> 
> On Mon, Sep 15, 2014 at 05:40:00PM -0400, Ruben Safir wrote:
>>>> 
>>>> 
>>>> Now the error log for an index request says:
>>>> 
>>>> [Mon Sep 15 12:14:09 2014] [error] [client 10.0.0.57] Attempt to serve
>>>> directory: /usr/local/apache/htdocs/resources/, referer:
>>>> http://www.mrbrklyn.com/
>>>> INDEXES ON
>>>> SYMLINKS OFF
>>>> CGI OFF
>>>> 
>>>> 
>>>> It knows that INDEXES is on but it is ignoring the config files fault.
>>>> 
>>>> I suppose I need to identify the directory request and then
>>>> decline to respond to it.
>>> 
>>> Yes.
>>> 
>>>> But I have no idea how to do this.
>>> 
>>> Have you tried
>>> 
>>> return DECLINED; # ?
>> 
>> 
>> I think I need return Apache2::Const::DECLINED;
> 
> This is the module that is failing to work
> 
> https://httpd.apache.org/docs/2.2/mod/mod_dir.html
> 
> As soon as you pull up mod_perl it stops working.  it will not pick up
> from the response cycle once you interject a modperl module
> 
> 
> 

Re: lost directory indexes

Posted by Ruben Safir <ru...@mrbrklyn.com>.
On Mon, Sep 15, 2014 at 05:40:00PM -0400, Ruben Safir wrote:
> > >
> > >
> > >Now the error log for an index request says:
> > >
> > >[Mon Sep 15 12:14:09 2014] [error] [client 10.0.0.57] Attempt to serve
> > >directory: /usr/local/apache/htdocs/resources/, referer:
> > >http://www.mrbrklyn.com/
> > >INDEXES ON
> > >SYMLINKS OFF
> > >CGI OFF
> > >
> > >
> > >It knows that INDEXES is on but it is ignoring the config files fault.
> > >
> > >I suppose I need to identify the directory request and then
> > >decline to respond to it.
> > 
> > Yes.
> > 
> > >But I have no idea how to do this.
> > 
> > Have you tried
> > 
> > return DECLINED; # ?
> > 
> 
> 
> I think I need return Apache2::Const::DECLINED;
> 

This is the module that is failing to work

https://httpd.apache.org/docs/2.2/mod/mod_dir.html

As soon as you pull up mod_perl it stops working.  it will not pick up
from the response cycle once you interject a modperl module




Re: lost directory indexes

Posted by Ruben Safir <ru...@mrbrklyn.com>.
> >
> >
> >Now the error log for an index request says:
> >
> >[Mon Sep 15 12:14:09 2014] [error] [client 10.0.0.57] Attempt to serve
> >directory: /usr/local/apache/htdocs/resources/, referer:
> >http://www.mrbrklyn.com/
> >INDEXES ON
> >SYMLINKS OFF
> >CGI OFF
> >
> >
> >It knows that INDEXES is on but it is ignoring the config files fault.
> >
> >I suppose I need to identify the directory request and then
> >decline to respond to it.
> 
> Yes.
> 
> >But I have no idea how to do this.
> 
> Have you tried
> 
> return DECLINED; # ?
> 


I think I need return Apache2::Const::DECLINED;

It is recieving a DECLINED but it is not acting according to what you
wrote here.


> See first this : http://perl.apache.org/docs/2.0/user/handlers/http.html#HTTP_Request_Cycle_Phases


> 
> Leave that page open in a tab, to refer to it during the rest.
> 
> Then open this page in another tab, and read it, up to the RUN_ALL label.
> 
> (Really do this; it takes only a few minutes, and it will save you a
> lot of time in the long run)
> 
> Then see : http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlResponseHandler
> and then follow the RUN_FIRST links, to
> http://perl.apache.org/docs/2.0/user/handlers/intro.html#item_RUN_FIRST
> and then to
> http://perl.apache.org/docs/2.0/user/handlers/intro.html#C_RUN_FIRST_
>

Yes - I have poured over this docs today.
 
> Summary :
> 
> When you install you own mod_perl response handler, it gets pushed
> "on top" of the Apache default handler, so it gets called first.
> 
> If your response handler really generates a response, it should
> return OK, so that Apache does not run any more response handlers
> after that (not even the default handler, see below), and skips to
> the next phase (Logging). (Your handler can also return an error
> code, and that also aborts the Response phase and goes to Logging.)
> If your handler decides not to generate a response for this request
> (but leave it for another handler to do that), then it should
> respond DECLINED, 

It does this.  This is the code:

        if ($gate =~ m{///}){
                print STDERR "I have a match\n";
                $r->log_reason("Access Forbidden", $r->filename);
                return Apache2::Const::FORBIDDEN;
        }else{
                print STDERR "Declining: $gate \n";
                return Apache2::Const::DECLINED;
        }

> so that Apache runs the next handler in the chain.

Whatever apache is running after this is does not include anything
that is supposed to identify indexes or dir_module (the discovery of
index.html).  These things are not happening even as I change the handle
type from PerlResponseHandle to PerlAccessHandler to PerlTransHadler

None of it.

Even if I put 
 return Apache2::Const::DECLINED;

right at the top of the module:
package URL_BLOCK;

use strict;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Access;
use Apache2::Const -compile => qw(:common);
use Apache2::Const -compile => qw(:options);

sub handler{
        my $r = shift;
        return Apache2::Const::DECLINED;
        my $gate = $r->unparsed_uri;


....

Still it can no longer identify index.html or perform any fancy
indexing.

ONLY if I remove the perl handler from the location, only then will
indexing work correctly.




> Eventually, if all the installed Response handlers respond DECLINED,
> Apache will run its default response handler.

that default handler evidently does not include fancy indexing or 
option Indexes

> This default handler is always there, at the end of the Response
> handlers chain.  It is the one which tries to respond to the request
> by sending a static file (e.g. a html page on disk) or the content
> of a directory.
> That's what you want, here; so return DECLINED.

-- 
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com 

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive 
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com 

Being so tracked is for FARM ANIMALS and and extermination camps, 
but incompatible with living as a free human being. -RI Safir 2013


Re: lost directory indexes

Posted by André Warnier <aw...@ice-sa.com>.
Ruben Safir wrote:
> On Mon, Sep 15, 2014 at 12:24:13AM -0400, Ruben Safir wrote:
>> Oh yeah --
>>
>> Server version: Apache/2.2.23 (Unix)
>> Server built:   Dec  9 2012 17:26:38
>>
> 
> 
> 
> Continuing on this
> 
> I'm looking at what are the allowed options
> 
> I added:
> use Apache2::Access;
> use Apache2::Const -compile => qw(:common);
> use Apache2::Const -compile => qw(:options);
> 
> and
> 
>         if($r->allow_options & Apache2::Const::OPT_INDEXES){
>                 print STDERR "INDEXES ON\n";
>         }else {
>                 print STDERR "INDEXES OFF\n";
>         }
> 
> 
>         if($r->allow_options & Apache2::Const::OPT_SYM_LINKS){
>                 print STDERR "SYMLINS ON\n";
>         }else {
>                 print STDERR "SYMLINKS OFF\n";
>         }
> 
>         if($r->allow_options & Apache2::Const::OPT_EXECCGI){
>                 print STDERR "CGI ON\n"}
>         else {
>                 print STDERR "CGI OFF\n";
>         }
> 
> 
> Now the error log for an index request says:
> 
> [Mon Sep 15 12:14:09 2014] [error] [client 10.0.0.57] Attempt to serve
> directory: /usr/local/apache/htdocs/resources/, referer:
> http://www.mrbrklyn.com/
> INDEXES ON
> SYMLINKS OFF
> CGI OFF
> 
> 
> It knows that INDEXES is on but it is ignoring the config files fault.
> 
> I suppose I need to identify the directory request and then decline to 
> respond to it.

Yes.

> But I have no idea how to do this.

Have you tried

return DECLINED; # ?

See first this : 
http://perl.apache.org/docs/2.0/user/handlers/http.html#HTTP_Request_Cycle_Phases

Leave that page open in a tab, to refer to it during the rest.

Then open this page in another tab, and read it, up to the RUN_ALL label.

(Really do this; it takes only a few minutes, and it will save you a lot of time in the 
long run)

Then see : http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlResponseHandler
and then follow the RUN_FIRST links, to
http://perl.apache.org/docs/2.0/user/handlers/intro.html#item_RUN_FIRST
and then to
http://perl.apache.org/docs/2.0/user/handlers/intro.html#C_RUN_FIRST_

Summary :

When you install you own mod_perl response handler, it gets pushed "on top" of the Apache 
default handler, so it gets called first.

If your response handler really generates a response, it should return OK, so that Apache 
does not run any more response handlers after that (not even the default handler, see 
below), and skips to the next phase (Logging). (Your handler can also return an error 
code, and that also aborts the Response phase and goes to Logging.)
If your handler decides not to generate a response for this request (but leave it for 
another handler to do that), then it should respond DECLINED, so that Apache runs the next 
handler in the chain.
Eventually, if all the installed Response handlers respond DECLINED, Apache will run its 
default response handler.
This default handler is always there, at the end of the Response handlers chain.  It is 
the one which tries to respond to the request by sending a static file (e.g. a html page 
on disk) or the content of a directory.
That's what you want, here; so return DECLINED.

Re: lost directory indexes

Posted by Ruben Safir <ru...@mrbrklyn.com>.
On Mon, Sep 15, 2014 at 12:24:13AM -0400, Ruben Safir wrote:
> 
> Oh yeah --
> 
> Server version: Apache/2.2.23 (Unix)
> Server built:   Dec  9 2012 17:26:38
> 



Continuing on this

I'm looking at what are the allowed options

I added:
use Apache2::Access;
use Apache2::Const -compile => qw(:common);
use Apache2::Const -compile => qw(:options);

and

        if($r->allow_options & Apache2::Const::OPT_INDEXES){
                print STDERR "INDEXES ON\n";
        }else {
                print STDERR "INDEXES OFF\n";
        }


        if($r->allow_options & Apache2::Const::OPT_SYM_LINKS){
                print STDERR "SYMLINS ON\n";
        }else {
                print STDERR "SYMLINKS OFF\n";
        }

        if($r->allow_options & Apache2::Const::OPT_EXECCGI){
                print STDERR "CGI ON\n"}
        else {
                print STDERR "CGI OFF\n";
        }


Now the error log for an index request says:

[Mon Sep 15 12:14:09 2014] [error] [client 10.0.0.57] Attempt to serve
directory: /usr/local/apache/htdocs/resources/, referer:
http://www.mrbrklyn.com/
INDEXES ON
SYMLINKS OFF
CGI OFF


It knows that INDEXES is on but it is ignoring the config files fault.

I suppose I need to identify the directory request and then decline to 
respond to it.  But I have no idea how to do this.

There must me a mime type I am missing?

Any help would be appreciated.

Ruben

-- 
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com 

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive 
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com 

Being so tracked is for FARM ANIMALS and and extermination camps, 
but incompatible with living as a free human being. -RI Safir 2013


Re: lost directory indexes

Posted by Ruben Safir <ru...@mrbrklyn.com>.
On 09/15/2014 12:22 AM, Ruben Safir wrote:
> 
> I added a perl handler to my apache setup and I can't understand why I'm
> losing the directory listings in my image and doc directories.  I need
> to both squelch  rougue web querries
> 
> The apache conf looks like this:
> 
> <VirtualHost *:80>
>     ServerAdmin ruben@mrbrklyn.com
>     DocumentRoot "/usr/local/apache/htdocs/brooklyn"
>     ServerName brooklyn-living.com
>     DirectoryIndex index.html
>     PerlModule Embperl
>     Embperl_UseEnv        on
>     ErrorLog logs/brooklyn_error_log
>     CustomLog logs/brooklyn_access_log common
>     <Directory /usr/local/apache/htdocs/brooklyn>
>            Options     Indexes ExecCGI
>            DirectoryIndex index.html
>            <Files *.html>
>            SetHandler  perl-script
>            PerlResponseHandler URL_BLOCK
>            PerlHandler Embperl
>            </Files>
>            AllowOverride None
>            Order allow,deny
>            Allow from all
>     </Directory>
>  <Directory /usr/local/apache/htdocs/brooklyn/images>
>         Options Indexes FollowSymLinks
>         SetHandler  perl-script
>         PerlResponseHandler URL_BLOCK
>     </Directory>
> </VirtualHost>
> 
> 
> and the URL_BLOCK script looks like this:
> package URL_BLOCK;
> 
> use strict;
> use Apache2::RequestRec ();
> use Apache2::RequestIO ();
> use Apache2::Const -compile => qw(:common);
> 
> sub handler{
>         my $r = shift;
>         my $gate = $r->unparsed_uri;
>         print STDERR "YO $gate\n";
>         return Apache2::Const::DECLINED unless defined $gate;
>         if ($gate =~ m{///}){
>                 print STDERR "I have a match\n";
>                 $r->log_reason("Access Forbidden", $r->filename);
>                 return Apache2::Const::FORBIDDEN;
>         }
>         return Apache2::Const::DECLINED;
> 
> }
> 
> 1;
> 
> 

Oh yeah --

Server version: Apache/2.2.23 (Unix)
Server built:   Dec  9 2012 17:26:38