Help with autoindex on; missing slash for directories

Maxim Dounin mdounin at mdounin.ru
Wed Oct 14 17:36:01 MSD 2009


Hello!

On Wed, Oct 14, 2009 at 04:41:03PM +0400, Igor Sysoev wrote:

> On Wed, Oct 14, 2009 at 04:22:47PM +0400, Maxim Dounin wrote:
> 
> > Hello!
> > 
> > On Wed, Oct 14, 2009 at 03:28:20PM +0400, Igor Sysoev wrote:
> > 
> > > On Wed, Oct 14, 2009 at 04:44:19AM +0400, Maxim Dounin wrote:
> > > 
> > > > Hello!
> > > > 
> > > > On Tue, Oct 13, 2009 at 11:21:57PM +0400, Igor Sysoev wrote:
> > > > 
> > > > > On Tue, Jul 21, 2009 at 10:08:06PM +0400, Maxim Dounin wrote:
> > > > > 
> > > > > > Hello!
> > > > > > 
> > > > > > On Fri, Jul 17, 2009 at 03:14:35PM +0400, Igor Sysoev wrote:
> > > > > > 
> > > > > > > On Fri, Jul 17, 2009 at 07:01:00AM +0400, Maxim Dounin wrote:
> > > > > > > 
> > > > > > > > Hello!
> > > > > > > > 
> > > > > > > > On Thu, Jul 16, 2009 at 04:25:16PM -0700, Yazz D. Atlas wrote:
> > > > > > > > 
> > > > > > > > > Maxim,
> > > > > > > > >
> > > > > > > > > Ok finally added the patch with the I believe the right stuff. Attached 
> > > > > > > > > is the patch and the log file.
> > > > > > > > >
> > > > > > > > > I just ran "GET http://localhost:88/static"
> > > > > > > > 
> > > > > > > > Ok, thanx.  According to
> > > > > > > > 
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: ".svn", type 4
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "questionnaires", type 10
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "site", type 10
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "50x.html", type 8
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "rev.txt", type 8
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: ".", type 4
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "protocols", type 10
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "video", type 10
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "..", type 4
> > > > > > > > 2009/07/16 16:16:10 [debug] 20579#0: *2 http autoindex file: "content", type 10
> > > > > > > > 
> > > > > > > > the only directories here are '.svn', '.' and '..'.  It's symlinks 
> > > > > > > > to directories that has no slash now.
> > > > > > > > 
> > > > > > > > I'll take a look how to fix this properly.
> > > > > > > 
> > > > > > > I've reproduced this bug on FreeBSD too. Will look how to resolve this.
> > > > > > 
> > > > > > Attached patch fixes the problem.  It also fixes typo (DT_LINK 
> > > > > > instead of DT_LNK, not used in code) and removes Linux special 
> > > > > > case as dirent.d_type may be unset on other systems too (e.g. 
> > > > > > cd9660 on FreeBSD).
> > > > > > 
> > > > > > Also I've changed DT_UNKNOWN check to explicit one (instead of 
> > > > > > implicitly checking for 0) - on all systems I've seen it's 0, but 
> > > > > > AFAIK it's not guaranteed.
> > > > > > 
> > > > > > This patch was shamelessly tested with The CSRG Archives CD-ROM 1 
> > > > > > as shipped by Marshall Kirk McKusick.  :)
> > > > > 
> > > > > Another patch version.
> > > > > 
> > > > > 
> > > > > -- 
> > > > > Igor Sysoev
> > > > > http://sysoev.ru/en/
> > > > 
> > > > > Index: src/http/modules/ngx_http_random_index_module.c
> > > > > ===================================================================
> > > > > --- src/http/modules/ngx_http_random_index_module.c	(revision 2519)
> > > > > +++ src/http/modules/ngx_http_random_index_module.c	(working copy)
> > > > > @@ -175,7 +175,7 @@
> > > > >  
> > > > >          len = ngx_de_namelen(&dir);
> > > > >  
> > > > > -        if (!dir.valid_type) {
> > > > > +        if (dir.type == 0) {
> > > > 
> > > > Oh, I somehow missed random index module.
> > > 
> > > dirent.d_type had been actually introduced for random index.
> > > 
> > > > But please note that it's currently broken for symlinks and this 
> > > > patch doesn't fix it - links to files won't pass this check, and 
> > > > will be ignored by ngx_de_is_file() test later.
> > > 
> > > Yes, random index ignores symlinks.
> > 
> > It behaves inconsistently on systems with and without 
> > dirent.d_type...
> 
> OK, I have changed:
> 
>          len = ngx_de_namelen(&dir);
>  
> -        if (dir.type == 0) {
> +        if (dir.type == 0 || ngx_de_is_link(&dir)) {

Ok, this way it looks right and fairy consistent.  Thanks.

Maxim Dounin





More information about the nginx mailing list