xref: /lighttpd1.4/src/mod_userdir.c (revision 1eda5074)
18abd06a7SGlenn Strauss #include "first.h"
28abd06a7SGlenn Strauss 
3be7eb108SGlenn Strauss #include "array.h"
4bcdc6a3bSJan Kneschke #include "buffer.h"
5be7eb108SGlenn Strauss #include "log.h"
667c0b149SGlenn Strauss #include "request.h"
7bcdc6a3bSJan Kneschke #include "response.h"
834750926SGlenn Strauss #include "stat_cache.h"
9bcdc6a3bSJan Kneschke 
10bcdc6a3bSJan Kneschke #include "plugin.h"
11bcdc6a3bSJan Kneschke 
1222e8b456SStefan Bühler #include <sys/types.h>
1322e8b456SStefan Bühler 
1422e8b456SStefan Bühler #include <stdlib.h>
1522e8b456SStefan Bühler #include <string.h>
1622e8b456SStefan Bühler 
17bcdc6a3bSJan Kneschke #ifdef HAVE_PWD_H
18bcdc6a3bSJan Kneschke # include <pwd.h>
19bcdc6a3bSJan Kneschke #endif
20bcdc6a3bSJan Kneschke 
21bcdc6a3bSJan Kneschke typedef struct {
22be7eb108SGlenn Strauss     const array *exclude_user;
23be7eb108SGlenn Strauss     const array *include_user;
24be7eb108SGlenn Strauss     const buffer *path;
25be7eb108SGlenn Strauss     const buffer *basepath;
26022742a5SElan Ruusamäe     unsigned short letterhomes;
2712c4a40bSStefan Bühler     unsigned short active;
28bcdc6a3bSJan Kneschke } plugin_config;
29bcdc6a3bSJan Kneschke 
30bcdc6a3bSJan Kneschke typedef struct {
31bcdc6a3bSJan Kneschke     PLUGIN_DATA;
32be7eb108SGlenn Strauss     plugin_config defaults;
33bcdc6a3bSJan Kneschke     plugin_config conf;
34309c1693SGlenn Strauss     unix_time64_t cache_ts[2];
354eeff345SGlenn Strauss     buffer cache_user[2];
364eeff345SGlenn Strauss     buffer cache_path[2];
37bcdc6a3bSJan Kneschke } plugin_data;
38bcdc6a3bSJan Kneschke 
INIT_FUNC(mod_userdir_init)39bcdc6a3bSJan Kneschke INIT_FUNC(mod_userdir_init) {
405e14db43SGlenn Strauss     return ck_calloc(1, sizeof(plugin_data));
41bcdc6a3bSJan Kneschke }
42bcdc6a3bSJan Kneschke 
FREE_FUNC(mod_userdir_free)434eeff345SGlenn Strauss FREE_FUNC(mod_userdir_free) {
444eeff345SGlenn Strauss     plugin_data * const p = p_d;
454eeff345SGlenn Strauss     free(p->cache_user[0].ptr);
464eeff345SGlenn Strauss     free(p->cache_user[1].ptr);
474eeff345SGlenn Strauss     free(p->cache_path[0].ptr);
484eeff345SGlenn Strauss     free(p->cache_path[1].ptr);
494eeff345SGlenn Strauss }
504eeff345SGlenn Strauss 
mod_userdir_merge_config_cpv(plugin_config * const pconf,const config_plugin_value_t * const cpv)51be7eb108SGlenn Strauss static void mod_userdir_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
52be7eb108SGlenn Strauss     switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
53be7eb108SGlenn Strauss       case 0: /* userdir.path */
54be7eb108SGlenn Strauss         pconf->path = cpv->v.b;
55be7eb108SGlenn Strauss         break;
56be7eb108SGlenn Strauss       case 1: /* userdir.exclude-user */
57be7eb108SGlenn Strauss         pconf->exclude_user = cpv->v.a;
58be7eb108SGlenn Strauss         break;
59be7eb108SGlenn Strauss       case 2: /* userdir.include-user */
60be7eb108SGlenn Strauss         pconf->include_user = cpv->v.a;
61be7eb108SGlenn Strauss         break;
62be7eb108SGlenn Strauss       case 3: /* userdir.basepath */
63be7eb108SGlenn Strauss         pconf->basepath = cpv->v.b;
64be7eb108SGlenn Strauss         break;
65be7eb108SGlenn Strauss       case 4: /* userdir.letterhomes */
66be7eb108SGlenn Strauss         pconf->letterhomes = cpv->v.u;
67be7eb108SGlenn Strauss         break;
68be7eb108SGlenn Strauss       case 5: /* userdir.active */
69be7eb108SGlenn Strauss         pconf->active = cpv->v.u;
70be7eb108SGlenn Strauss         break;
71be7eb108SGlenn Strauss       default:/* should not happen */
72be7eb108SGlenn Strauss         return;
73be7eb108SGlenn Strauss     }
74be7eb108SGlenn Strauss }
75bcdc6a3bSJan Kneschke 
mod_userdir_merge_config(plugin_config * const pconf,const config_plugin_value_t * cpv)76be7eb108SGlenn Strauss static void mod_userdir_merge_config(plugin_config * const pconf, const config_plugin_value_t *cpv) {
77be7eb108SGlenn Strauss     do {
78be7eb108SGlenn Strauss         mod_userdir_merge_config_cpv(pconf, cpv);
79be7eb108SGlenn Strauss     } while ((++cpv)->k_id != -1);
80be7eb108SGlenn Strauss }
81be7eb108SGlenn Strauss 
mod_userdir_patch_config(request_st * const r,plugin_data * const p)827c7f8c46SGlenn Strauss static void mod_userdir_patch_config(request_st * const r, plugin_data * const p) {
83be7eb108SGlenn Strauss     memcpy(&p->conf, &p->defaults, sizeof(plugin_config));
84be7eb108SGlenn Strauss     for (int i = 1, used = p->nconfig; i < used; ++i) {
857c7f8c46SGlenn Strauss         if (config_check_cond(r, (uint32_t)p->cvlist[i].k_id))
86be7eb108SGlenn Strauss             mod_userdir_merge_config(&p->conf, p->cvlist + p->cvlist[i].v.u2[0]);
87be7eb108SGlenn Strauss     }
88be7eb108SGlenn Strauss }
89be7eb108SGlenn Strauss 
SETDEFAULTS_FUNC(mod_userdir_set_defaults)90be7eb108SGlenn Strauss SETDEFAULTS_FUNC(mod_userdir_set_defaults) {
91be7eb108SGlenn Strauss     static const config_plugin_keys_t cpk[] = {
92be7eb108SGlenn Strauss       { CONST_STR_LEN("userdir.path"),
93be7eb108SGlenn Strauss         T_CONFIG_STRING,
94be7eb108SGlenn Strauss         T_CONFIG_SCOPE_CONNECTION }
95be7eb108SGlenn Strauss      ,{ CONST_STR_LEN("userdir.exclude-user"),
9603b4c993SGlenn Strauss         T_CONFIG_ARRAY_VLIST,
97be7eb108SGlenn Strauss         T_CONFIG_SCOPE_CONNECTION }
98be7eb108SGlenn Strauss      ,{ CONST_STR_LEN("userdir.include-user"),
9903b4c993SGlenn Strauss         T_CONFIG_ARRAY_VLIST,
100be7eb108SGlenn Strauss         T_CONFIG_SCOPE_CONNECTION }
101be7eb108SGlenn Strauss      ,{ CONST_STR_LEN("userdir.basepath"),
102be7eb108SGlenn Strauss         T_CONFIG_STRING,
103be7eb108SGlenn Strauss         T_CONFIG_SCOPE_CONNECTION }
104be7eb108SGlenn Strauss      ,{ CONST_STR_LEN("userdir.letterhomes"),
105be7eb108SGlenn Strauss         T_CONFIG_BOOL,
106be7eb108SGlenn Strauss         T_CONFIG_SCOPE_CONNECTION }
107be7eb108SGlenn Strauss      ,{ CONST_STR_LEN("userdir.active"),
108be7eb108SGlenn Strauss         T_CONFIG_BOOL,
109be7eb108SGlenn Strauss         T_CONFIG_SCOPE_CONNECTION }
110be7eb108SGlenn Strauss      ,{ NULL, 0,
111be7eb108SGlenn Strauss         T_CONFIG_UNSET,
112be7eb108SGlenn Strauss         T_CONFIG_SCOPE_UNSET }
113bcdc6a3bSJan Kneschke     };
114bcdc6a3bSJan Kneschke 
115be7eb108SGlenn Strauss     plugin_data * const p = p_d;
116be7eb108SGlenn Strauss     if (!config_plugin_values_init(srv, p, cpk, "mod_userdir"))
117be7eb108SGlenn Strauss         return HANDLER_ERROR;
118bcdc6a3bSJan Kneschke 
119af3df29aSGlenn Strauss     /* process and validate config directives
120af3df29aSGlenn Strauss      * (init i to 0 if global context; to 1 to skip empty global context) */
121af3df29aSGlenn Strauss     for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) {
122af3df29aSGlenn Strauss         config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0];
123af3df29aSGlenn Strauss         for (; -1 != cpv->k_id; ++cpv) {
124af3df29aSGlenn Strauss             switch (cpv->k_id) {
125af3df29aSGlenn Strauss               case 0: /* userdir.path */
126af3df29aSGlenn Strauss               case 1: /* userdir.exclude-user */
127af3df29aSGlenn Strauss               case 2: /* userdir.include-user */
128af3df29aSGlenn Strauss                 break;
129af3df29aSGlenn Strauss               case 3: /* userdir.basepath */
130af3df29aSGlenn Strauss                 if (buffer_is_blank(cpv->v.b))
131af3df29aSGlenn Strauss                     cpv->v.b = NULL;
132af3df29aSGlenn Strauss                 break;
133af3df29aSGlenn Strauss               case 4: /* userdir.letterhomes */
134af3df29aSGlenn Strauss               case 5: /* userdir.active */
135af3df29aSGlenn Strauss                 break;
136af3df29aSGlenn Strauss               default:/* should not happen */
137af3df29aSGlenn Strauss                 break;
138af3df29aSGlenn Strauss             }
139af3df29aSGlenn Strauss         }
140af3df29aSGlenn Strauss     }
141af3df29aSGlenn Strauss 
142be7eb108SGlenn Strauss     /* enabled by default for backward compatibility;
143be7eb108SGlenn Strauss      * if userdir.path isn't set userdir is disabled too,
14412c4a40bSStefan Bühler      * but you can't disable it by setting it to an empty string. */
145be7eb108SGlenn Strauss     p->defaults.active = 1;
146bcdc6a3bSJan Kneschke 
147be7eb108SGlenn Strauss     /* initialize p->defaults from global config context */
148be7eb108SGlenn Strauss     if (p->nconfig > 0 && p->cvlist->v.u2[1]) {
149be7eb108SGlenn Strauss         const config_plugin_value_t *cpv = p->cvlist + p->cvlist->v.u2[0];
150be7eb108SGlenn Strauss         if (-1 != cpv->k_id)
151be7eb108SGlenn Strauss             mod_userdir_merge_config(&p->defaults, cpv);
152bcdc6a3bSJan Kneschke     }
153bcdc6a3bSJan Kneschke 
154bcdc6a3bSJan Kneschke     return HANDLER_GO_ON;
155bcdc6a3bSJan Kneschke }
156bcdc6a3bSJan Kneschke 
mod_userdir_in_vlist_nc(const array * const a,const char * const k,const size_t klen)15728b7d0b6SGlenn Strauss static int mod_userdir_in_vlist_nc(const array * const a, const char * const k, const size_t klen) {
15828b7d0b6SGlenn Strauss     for (uint32_t i = 0, used = a->used; i < used; ++i) {
15928b7d0b6SGlenn Strauss         const data_string * const ds = (const data_string *)a->data[i];
16028b7d0b6SGlenn Strauss         if (buffer_eq_icase_slen(&ds->value, k, klen)) return 1;
16128b7d0b6SGlenn Strauss     }
16228b7d0b6SGlenn Strauss     return 0;
16328b7d0b6SGlenn Strauss }
16428b7d0b6SGlenn Strauss 
mod_userdir_in_vlist(const array * const a,const char * const k,const size_t klen)16528b7d0b6SGlenn Strauss static int mod_userdir_in_vlist(const array * const a, const char * const k, const size_t klen) {
16628b7d0b6SGlenn Strauss     for (uint32_t i = 0, used = a->used; i < used; ++i) {
16728b7d0b6SGlenn Strauss         const data_string * const ds = (const data_string *)a->data[i];
16828b7d0b6SGlenn Strauss         if (buffer_eq_slen(&ds->value, k, klen)) return 1;
16928b7d0b6SGlenn Strauss     }
17028b7d0b6SGlenn Strauss     return 0;
17128b7d0b6SGlenn Strauss }
17228b7d0b6SGlenn Strauss 
17328b7d0b6SGlenn Strauss __attribute_noinline__
mod_userdir_docroot_construct(request_st * const r,plugin_data * const p,const char * const uptr,const size_t ulen)1747c7f8c46SGlenn Strauss static handler_t mod_userdir_docroot_construct(request_st * const r, plugin_data * const p, const char * const uptr, const size_t ulen) {
17528b7d0b6SGlenn Strauss     char u[256];
17628b7d0b6SGlenn Strauss     if (ulen >= sizeof(u)) return HANDLER_GO_ON;
17728b7d0b6SGlenn Strauss 
17828b7d0b6SGlenn Strauss     memcpy(u, uptr, ulen);
17928b7d0b6SGlenn Strauss     u[ulen] = '\0';
18028b7d0b6SGlenn Strauss 
18128b7d0b6SGlenn Strauss     /* we build the physical path */
1827c7f8c46SGlenn Strauss     buffer * const b = r->tmp_buf;
18328b7d0b6SGlenn Strauss 
184af3df29aSGlenn Strauss     if (!p->conf.basepath) {
1857fd269cfSJan Kneschke       #ifdef HAVE_PWD_H
1864eeff345SGlenn Strauss         /* getpwnam() lookup is expensive; first check 2-element cache */
187309c1693SGlenn Strauss         const unix_time64_t cur_ts = log_monotonic_secs;
1884eeff345SGlenn Strauss         int cached = -1;
1894eeff345SGlenn Strauss         const int cache_sz =(int)(sizeof(p->cache_user)/sizeof(*p->cache_user));
1904eeff345SGlenn Strauss         for (int i = 0; i < cache_sz; ++i) {
1914eeff345SGlenn Strauss             if (cur_ts - p->cache_ts[i] < 60 && p->cache_user[i].used
1924eeff345SGlenn Strauss                 && buffer_eq_slen(&p->cache_user[i], u, ulen)) {
1934eeff345SGlenn Strauss                 cached = i;
1944eeff345SGlenn Strauss                 break;
1954eeff345SGlenn Strauss             }
1964eeff345SGlenn Strauss         }
1974eeff345SGlenn Strauss         struct passwd *pwd;
1984eeff345SGlenn Strauss         if (cached >= 0) {
199af3df29aSGlenn Strauss             buffer_copy_path_len2(b, BUF_PTR_LEN(&p->cache_path[cached]),
200af3df29aSGlenn Strauss                                      BUF_PTR_LEN(p->conf.path));
2014eeff345SGlenn Strauss         }
2024eeff345SGlenn Strauss         else if ((pwd = getpwnam(u))) {
2034eeff345SGlenn Strauss             const size_t plen = strlen(pwd->pw_dir);
204680e6b3bSGlenn Strauss             buffer_copy_path_len2(b, pwd->pw_dir, plen,
205af3df29aSGlenn Strauss                                      BUF_PTR_LEN(p->conf.path));
20634750926SGlenn Strauss             if (!stat_cache_path_isdir(b)) {
20728b7d0b6SGlenn Strauss                 return HANDLER_GO_ON;
20828b7d0b6SGlenn Strauss             }
2094eeff345SGlenn Strauss             /* update cache, replacing oldest entry */
2104eeff345SGlenn Strauss             cached = 0;
211309c1693SGlenn Strauss             unix_time64_t cache_ts = p->cache_ts[0];
2124eeff345SGlenn Strauss             for (int i = 1; i < cache_sz; ++i) {
2134eeff345SGlenn Strauss                 if (cache_ts > p->cache_ts[i]) {
2144eeff345SGlenn Strauss                     cache_ts = p->cache_ts[i];
2154eeff345SGlenn Strauss                     cached = i;
2164eeff345SGlenn Strauss                 }
2174eeff345SGlenn Strauss             }
2184eeff345SGlenn Strauss             p->cache_ts[cached] = cur_ts;
2194eeff345SGlenn Strauss             buffer_copy_string_len(&p->cache_path[cached], b->ptr, plen);
2204eeff345SGlenn Strauss             buffer_copy_string_len(&p->cache_user[cached], u, ulen);
22128b7d0b6SGlenn Strauss         }
22228b7d0b6SGlenn Strauss         else /* user not found */
2237fd269cfSJan Kneschke       #endif
22428b7d0b6SGlenn Strauss             return HANDLER_GO_ON;
22528b7d0b6SGlenn Strauss     } else {
22628b7d0b6SGlenn Strauss         /* check if the username is valid
22728b7d0b6SGlenn Strauss          * a request for /~../ should lead to a directory traversal
22828b7d0b6SGlenn Strauss          * limiting to [-_a-z0-9.] should fix it */
22928b7d0b6SGlenn Strauss         if (ulen <= 2 && (u[0] == '.' && (1 == ulen || u[1] == '.'))) {
23028b7d0b6SGlenn Strauss             return HANDLER_GO_ON;
23128b7d0b6SGlenn Strauss         }
23228b7d0b6SGlenn Strauss 
23328b7d0b6SGlenn Strauss         for (size_t i = 0; i < ulen; ++i) {
23428b7d0b6SGlenn Strauss             const int c = u[i];
23528b7d0b6SGlenn Strauss             if (!(light_isalnum(c) || c == '-' || c == '_' || c == '.')) {
23628b7d0b6SGlenn Strauss                 return HANDLER_GO_ON;
23728b7d0b6SGlenn Strauss             }
23828b7d0b6SGlenn Strauss         }
23928b7d0b6SGlenn Strauss 
2407c7f8c46SGlenn Strauss         if (r->conf.force_lowercase_filenames) {
24128b7d0b6SGlenn Strauss             for (size_t i = 0; i < ulen; ++i) {
242c58b95f2SGlenn Strauss                 if (light_isupper(u[i])) u[i] |= 0x20;
24328b7d0b6SGlenn Strauss             }
24428b7d0b6SGlenn Strauss         }
24528b7d0b6SGlenn Strauss 
24628b7d0b6SGlenn Strauss         buffer_copy_buffer(b, p->conf.basepath);
24728b7d0b6SGlenn Strauss         if (p->conf.letterhomes) {
24828b7d0b6SGlenn Strauss             if (u[0] == '.') return HANDLER_GO_ON;
24928b7d0b6SGlenn Strauss             buffer_append_path_len(b, u, 1);
25028b7d0b6SGlenn Strauss         }
25128b7d0b6SGlenn Strauss         buffer_append_path_len(b, u, ulen);
252af3df29aSGlenn Strauss         buffer_append_path_len(b, BUF_PTR_LEN(p->conf.path));
25328b7d0b6SGlenn Strauss     }
25428b7d0b6SGlenn Strauss 
2557c7f8c46SGlenn Strauss     buffer_copy_buffer(&r->physical.basedir, b);
2567c7f8c46SGlenn Strauss     buffer_copy_buffer(&r->physical.path, b);
25728b7d0b6SGlenn Strauss 
25828b7d0b6SGlenn Strauss     /* the physical rel_path is basically the same as uri.path;
25928b7d0b6SGlenn Strauss      * but it is converted to lowercase in case of force_lowercase_filenames
26028b7d0b6SGlenn Strauss      * and some special handling for trailing '.', ' ' and '/' on windows
26128b7d0b6SGlenn Strauss      * we assume that no docroot/physical handler changed this
262c752d469SGlenn Strauss      * (docroot should only set the docroot/server name, physical should only
263*1eda5074SGlenn Strauss      *  change the physical.path) */
2647c7f8c46SGlenn Strauss     buffer_append_slash(&r->physical.path);
26528b7d0b6SGlenn Strauss     /* if no second '/' is found, we assume that it was stripped from the
26628b7d0b6SGlenn Strauss      * uri.path for the special handling on windows.  we do not care about the
26728b7d0b6SGlenn Strauss      * trailing slash here on windows, as we already ensured it is a directory
26828b7d0b6SGlenn Strauss      *
26928b7d0b6SGlenn Strauss      * TODO: what to do with trailing dots in usernames on windows?
27028b7d0b6SGlenn Strauss      * they may result in the same directory as a username without them.
27128b7d0b6SGlenn Strauss      */
27228b7d0b6SGlenn Strauss     char *rel_url;
2737c7f8c46SGlenn Strauss     if (NULL != (rel_url = strchr(r->physical.rel_path.ptr + 2, '/'))) {
2747c7f8c46SGlenn Strauss         buffer_append_string(&r->physical.path, rel_url + 1); /* skip the / */
27528b7d0b6SGlenn Strauss     }
27628b7d0b6SGlenn Strauss 
27728b7d0b6SGlenn Strauss     return HANDLER_GO_ON;
27828b7d0b6SGlenn Strauss }
27928b7d0b6SGlenn Strauss 
URIHANDLER_FUNC(mod_userdir_docroot_handler)28028b7d0b6SGlenn Strauss URIHANDLER_FUNC(mod_userdir_docroot_handler) {
28128b7d0b6SGlenn Strauss     /* /~user/foo.html -> /home/user/public_html/foo.html */
282bcdc6a3bSJan Kneschke 
283c687e01cSGlenn Strauss   #ifdef __COVERITY__
284af3df29aSGlenn Strauss     if (buffer_is_blank(&r->uri.path)) return HANDLER_GO_ON;
285c687e01cSGlenn Strauss   #endif
2867fd269cfSJan Kneschke 
2877c7f8c46SGlenn Strauss     if (r->uri.path.ptr[0] != '/' ||
2887c7f8c46SGlenn Strauss         r->uri.path.ptr[1] != '~') return HANDLER_GO_ON;
28928b7d0b6SGlenn Strauss 
29028b7d0b6SGlenn Strauss     plugin_data * const p = p_d;
2917c7f8c46SGlenn Strauss     mod_userdir_patch_config(r, p);
292bcdc6a3bSJan Kneschke 
293ec5c74adSStefan Bühler     /* enforce the userdir.path to be set in the config, ugly fix for #1587;
294ec5c74adSStefan Bühler      * should be replaced with a clean .enabled option in 1.5
295ec5c74adSStefan Bühler      */
296af3df29aSGlenn Strauss     if (!p->conf.active || !p->conf.path) return HANDLER_GO_ON;
297ec5c74adSStefan Bühler 
2987c7f8c46SGlenn Strauss     const char * const uptr = r->uri.path.ptr + 2;
29928b7d0b6SGlenn Strauss     const char * const rel_url = strchr(uptr, '/');
30028b7d0b6SGlenn Strauss     if (NULL == rel_url) {
301c8a1cba0SGlenn Strauss         if (!*uptr) return HANDLER_GO_ON; /* "/~" is not a valid userdir path */
302bcdc6a3bSJan Kneschke         /* / is missing -> redirect to .../ as we are a user - DIRECTORY ! :) */
3037c7f8c46SGlenn Strauss         http_response_redirect_to_directory(r, 301);
304bcdc6a3bSJan Kneschke         return HANDLER_FINISHED;
305bcdc6a3bSJan Kneschke     }
3067fd269cfSJan Kneschke 
3077fd269cfSJan Kneschke     /* /~/ is a empty username, catch it directly */
30828b7d0b6SGlenn Strauss     const size_t ulen = (size_t)(rel_url - uptr);
30928b7d0b6SGlenn Strauss     if (0 == ulen) return HANDLER_GO_ON;
31028b7d0b6SGlenn Strauss 
31128b7d0b6SGlenn Strauss     /* vlists could be turned into sorted array at config time,
31228b7d0b6SGlenn Strauss      * but these lists are expected to be relatively short in most cases
31328b7d0b6SGlenn Strauss      * so there is not a huge benefit to doing so in the common case */
31428b7d0b6SGlenn Strauss 
31528b7d0b6SGlenn Strauss     if (p->conf.exclude_user) {
31628b7d0b6SGlenn Strauss         /* use case-insensitive comparison for exclude list
3177c7f8c46SGlenn Strauss          * if r->conf.force_lowercase_filenames */
3187c7f8c46SGlenn Strauss         if (!r->conf.force_lowercase_filenames
31928b7d0b6SGlenn Strauss             ? mod_userdir_in_vlist(p->conf.exclude_user, uptr, ulen)
32028b7d0b6SGlenn Strauss             : mod_userdir_in_vlist_nc(p->conf.exclude_user, uptr, ulen))
32128b7d0b6SGlenn Strauss             return HANDLER_GO_ON; /* user in exclude list */
3227fd269cfSJan Kneschke     }
3237fd269cfSJan Kneschke 
32428b7d0b6SGlenn Strauss     if (p->conf.include_user) {
32528b7d0b6SGlenn Strauss         if (!mod_userdir_in_vlist(p->conf.include_user, uptr, ulen))
32628b7d0b6SGlenn Strauss             return HANDLER_GO_ON; /* user not in include list */
327bcdc6a3bSJan Kneschke     }
328bcdc6a3bSJan Kneschke 
3297c7f8c46SGlenn Strauss     return mod_userdir_docroot_construct(r, p, uptr, ulen);
330bcdc6a3bSJan Kneschke }
331bcdc6a3bSJan Kneschke 
332bcdc6a3bSJan Kneschke 
333b82d7b8aSGlenn Strauss __attribute_cold__
33463f785a2SStefan Bühler int mod_userdir_plugin_init(plugin *p);
mod_userdir_plugin_init(plugin * p)335bcdc6a3bSJan Kneschke int mod_userdir_plugin_init(plugin *p) {
336bcdc6a3bSJan Kneschke 	p->version     = LIGHTTPD_VERSION_ID;
337e2de4e58SGlenn Strauss 	p->name        = "userdir";
338bcdc6a3bSJan Kneschke 
339bcdc6a3bSJan Kneschke 	p->init           = mod_userdir_init;
3404eeff345SGlenn Strauss 	p->cleanup        = mod_userdir_free;
341faa4d51eSJan Kneschke 	p->handle_physical = mod_userdir_docroot_handler;
342bcdc6a3bSJan Kneschke 	p->set_defaults   = mod_userdir_set_defaults;
343bcdc6a3bSJan Kneschke 
344bcdc6a3bSJan Kneschke 	return 0;
345bcdc6a3bSJan Kneschke }
346