LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-04-2010, 10:49 PM   #1
jmoschetti45
Member
 
Registered: Oct 2004
Location: Michigan
Distribution: Debian Squeeze (2.6.32-5)
Posts: 137
Blog Entries: 1

Rep: Reputation: 17
Apache2 Autoindex Mods/Custom


I'm trying to modify mod_autoindex.

That in itself isn't too hard, I just copied the source and changed what needed to be changed.

It's loaded in apache as mod_customindex now, and apache sees it and doesn't have a problem with it.

Now, the problem is: How do I get it to index dirs?

If I turn autoindex off on a dir, I get a 403.
 
Old 11-05-2010, 01:19 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

To stop getting a 403 error for a directory, you need
Code:
Options Indexes
for the DocumentRoot directory, or explicitly set
Code:
Options +Indexes
for that directory.

Regards
 
Old 11-06-2010, 03:07 PM   #3
jmoschetti45
Member
 
Registered: Oct 2004
Location: Michigan
Distribution: Debian Squeeze (2.6.32-5)
Posts: 137

Original Poster
Blog Entries: 1

Rep: Reputation: 17
That still uses the default autoindex, not customindex. How do I force it to use the custom one?

Edit: I think this will clarify it more. I need the standard autoindex for everything but a few dirs, and customindex for a select few dirs.

Last edited by jmoschetti45; 11-06-2010 at 03:11 PM.
 
Old 11-06-2010, 05:47 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

The mod_autoindex directives can be used in a per directory basis either in httpd.cond or through .htaccess.
I don't know what you've changed to create your custom autoindex module, but you should create custom directives in the modified module and use them to do what you're trying to do.

Regards
 
Old 11-06-2010, 09:32 PM   #5
jmoschetti45
Member
 
Registered: Oct 2004
Location: Michigan
Distribution: Debian Squeeze (2.6.32-5)
Posts: 137

Original Poster
Blog Entries: 1

Rep: Reputation: 17
I stripped a bunch of useless stuff out and changed the HTML.

I did change the options directives so they don't overlap with autoindex.

More or less, I think the problem is I'm not sure how the "Options +Indexes" part of the httpd config is handled.

If I enable Options +Indexes, autoindex takes over. If I don't, I get a 403.

I need to know how to "enable" the module for that folder I believe.

Edit: Some code

Code:
if (allow_opts & OPT_INDEXES) {
	int errstatus;
	if ((errstatus = ap_discard_request_body(r)) != OK) {
		return errstatus;
	}
	if (r->filename[strlen(r->filename) - 1] != '/') {
		r->filename = apr_pstrcat(r->pool, r->filename, "/", NULL);
	}
	return index_directory(r, d);
} else {
	ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Directory index forbidden by Options directive: %s", r->filename);
	return HTTP_FORBIDDEN;
}
That code is the same in autoindex and customindex. I can't change the OPT_INDEXES to anything else or I get the usual "error: 'OPT_INDEXES2' undeclared (first use in this function)" There's no other instance of OPT_INDEXES anywhere else in the file, so I have no idea where I'd have to define a new variable.

Code:
        <Directory /var/www/test/>
                Options Indexes
                MediaIndexOptions MinNameWidth=24 MaxNameWidth=128
                Order allow,deny
                allow from all
        </Directory>

This needs to work without having to recompile apache itself.

Last edited by jmoschetti45; 11-06-2010 at 09:55 PM.
 
Old 11-07-2010, 03:51 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

Does apache refuse to start complaining about MediaIndexOptions?
If not, then the directive is recognized (meaning that it uses your custom autoindex).
If the result is not what you expect it to be, then you should review your changes in the code.

Regards
 
Old 11-07-2010, 10:13 AM   #7
jmoschetti45
Member
 
Registered: Oct 2004
Location: Michigan
Distribution: Debian Squeeze (2.6.32-5)
Posts: 137

Original Poster
Blog Entries: 1

Rep: Reputation: 17
Those directives are properly interpited.

I think the problem has been narrowed down to the fact that autoindex runs before customindex.

I've tried simply compiling a second copy of autoindex with only 2 changes in the HTML to see if it would pull up, and it wont. Is there some way to set the order of the modules loaded? Or am I off on the wrong track?

If I replace mod_autoindex.so with a renamed version of mod_customindex.so it works fine, but then I lose the original entirely.
 
Old 11-07-2010, 11:25 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

I think that you're indeed on the wrong track.
This has nothing to do with the order modules are loaded, since you use custom directives that are available only in your custom modules. When apache encounters these directives it will use your module to parse the resulting page regardless of the modules order.

FYI apache loads the modules in the order of the LoadModule directives that exist in httpd.conf, so you can load your module before the default autoindex.so, but it's not going to work for the reason explained above.

If you want to customize the resulting html, better take a look here

Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with logging the output of a custom daemon with a custom init script d1s4st3r *BSD 3 04-30-2010 04:46 AM
Apache2 - have to restart apache2 process every 10 mins to clear /tmp directory.... levi dehaan Linux - Software 8 09-01-2009 06:34 PM
Replacement/Upgrade for Autoindex - Thumbnails RacoonSlurpee Linux - Software 0 05-22-2008 12:40 AM
Creating custom headers to match a custom kernel utanja Debian 2 06-08-2007 03:15 PM
Custom kernel image on custom slack build using CUSS nykey Slackware 2 07-15-2006 03:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration