]> git.pld-linux.org Git - packages/lighttpd.git/blob - dirlist-hide.patch
- updated config from 1.3.14-20050420-191708 snap
[packages/lighttpd.git] / dirlist-hide.patch
1 Index: src/config.c
2 ===================================================================
3 --- src/config.c        (revision 107)
4 +++ src/config.c        (working copy)
5 @@ -74,6 +74,7 @@
6                 
7                 { "dir-listing.hide-dotfiles",   NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 39 */
8                 { "dir-listing.external-css",    NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },  /* 40 */
9 +               { "dir-listing.hide",            NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },   /* 41 */
10                 
11                 { "server.host",                 "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
12                 { "server.docroot",              "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
13 @@ -120,6 +121,7 @@
14                 s->hide_dotfiles = 1;
15                 s->indexfiles    = array_init();
16                 s->mimetypes     = array_init();
17 +               s->dirlist_hide  = array_init();
18                 s->server_name   = buffer_init();
19                 s->ssl_pemfile   = buffer_init();
20                 s->ssl_ca_file   = buffer_init();
21 @@ -173,6 +175,7 @@
22                 cv[38].destination = s->ssl_ca_file;
23                 cv[39].destination = &(s->hide_dotfiles);
24                 cv[40].destination = s->dirlist_css;
25 +               cv[41].destination = s->dirlist_hide;
26                 
27                 srv->config_storage[i] = s;
28         
29 @@ -196,6 +199,7 @@
30         PATCH(dir_listing);
31         PATCH(dirlist_css);
32         PATCH(hide_dotfiles);
33 +       PATCH(dirlist_hide);
34         PATCH(indexfiles);
35         PATCH(max_keep_alive_requests);
36         PATCH(max_keep_alive_idle);
37 @@ -245,6 +249,8 @@
38                                 PATCH(hide_dotfiles);
39                         } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("dir-listing.external-css"))) {
40                                 PATCH(dirlist_css);
41 +                       } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("dir-listing.hide"))) {
42 +                               PATCH(dirlist_hide);
43                         } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.error-handler-404"))) {
44                                 PATCH(error_handler);
45                         } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.indexfiles"))) {
46 Index: src/base.h
47 ===================================================================
48 --- src/base.h  (revision 107)
49 +++ src/base.h  (working copy)
50 @@ -216,6 +216,7 @@
51  typedef struct {
52         array *indexfiles;
53         array *mimetypes;
54 +       array *dirlist_hide;
55         
56         /* virtual-servers */
57         buffer *document_root;
58 Index: src/response.c
59 ===================================================================
60 --- src/response.c      (revision 107)
61 +++ src/response.c      (working copy)
62 @@ -643,6 +643,29 @@
63         );
64  }
65  
66 +static int http_list_directory_ishidden(array *hidden, const char *filename, size_t len) {
67 +       size_t i;
68 +       size_t ct_len;
69 +       data_string *ds;
70 +
71 +       for (i = 0; i < hidden->used; i++) {
72 +               ds = (data_string*) hidden->data[i];
73 +
74 +               if (ds->value->used == 0)
75 +                       continue;
76 +
77 +               ct_len = ds->value->used - 1;
78 +               if (len < ct_len)
79 +                       continue;
80 +
81 +               if (strncmp(filename + len - ct_len, ds->value->ptr, ct_len) == 0) {
82 +                       return 1;
83 +               }
84 +       }
85 +
86 +       return 0;
87 +}
88 +
89  static int http_list_directory(server *srv, connection *con, buffer *dir) {
90         DIR *dp;
91         buffer *out;
92 @@ -656,6 +679,8 @@
93         char sizebuf[sizeof("999.9K")];
94         char datebuf[sizeof("2005-Jan-01 22:23:24")];
95         size_t k;
96 +       size_t ct_len;
97 +       data_string *ds;
98         const char *content_type;
99  #ifdef HAVE_XATTR
100         char attrval[128];
101 @@ -706,6 +731,10 @@
102                 i = strlen(dent->d_name);
103                 if (i > NAME_MAX)
104                         continue;
105 +
106 +               if (http_list_directory_ishidden(con->conf.dirlist_hide, dent->d_name, i))
107 +                       continue;
108 +
109                 memcpy(path_file, dent->d_name, i + 1);
110                 if (stat(path, &st) != 0)
111                         continue;
112 @@ -780,8 +809,7 @@
113  #endif
114                         content_type = "application/octet-stream";
115                         for (k = 0; k < con->conf.mimetypes->used; k++) {
116 -                               data_string *ds = (data_string *)con->conf.mimetypes->data[k];
117 -                               size_t ct_len;
118 +                               ds = (data_string *)con->conf.mimetypes->data[k];
119  
120                                 if (ds->key->used == 0)
121                                         continue;
122 Index: src/server.c
123 ===================================================================
124 --- src/server.c        (revision 107)
125 +++ src/server.c        (working copy)
126 @@ -244,6 +244,7 @@
127                         buffer_free(s->dirlist_css);
128                         array_free(s->indexfiles);
129                         array_free(s->mimetypes);
130 +                       array_free(s->dirlist_hide);
131                         
132                         free(s);
133                 }
134 Index: doc/configuration.txt
135 ===================================================================
136 --- doc/configuration.txt       (revision 107)
137 +++ doc/configuration.txt       (working copy)
138 @@ -191,6 +191,12 @@
139  dir-listing.external-css
140    path to an external css stylesheet for the directory listing
141  
142 +dir-listing.hide
143 +  list of extensions to hide in directory listing.
144 +  e.g.: ::
145 +
146 +  dir-listing.hide = ( "CVS", ".xyz" ) 
147 +
148  server.follow-symlink
149    allow to follow-symlinks
150    
This page took 0.03565 seconds and 3 git commands to generate.