From: Eric Covener Date: Tue, 8 Feb 2011 02:58:51 +0000 (+0000) Subject: backport 1042090 from trunk: X-Git-Tag: 2.2.18~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14aefec26e4b3bf707c13c5715b0de513a190d05;p=thirdparty%2Fapache%2Fhttpd.git backport 1042090 from trunk: PR44076: allow "userdir disabled" or "userdir public_html" in global scope to be merged with lists of enabled users in virtual host context as one would expect. Reviewed by: covener, rpluem, poirier git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1068257 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 3d71af5169f..d89ae3a13a8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.18 + *) mod_userdir: Add merging of enable, disable, and filename arguments + to UserDir directive, leaving enable/disable of userlists unmerged. + PR 44076 [Eric Covener] + *) core: Honor 'AcceptPathInfo OFF' during internal redirects, such as per-directory mod_rewrite substitutions. PR 50349. [Eric Covener] diff --git a/STATUS b/STATUS index 59a362a2084..23418727d4e 100644 --- a/STATUS +++ b/STATUS @@ -108,12 +108,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: Trunk version of patch works +1: rpluem, jorton, covener - * mod_userdir: support merge of "userdir disabled" or "userdir public_html" - when userdir directives appear in vhost context. PR 44076 - Trunk patch: http://svn.apache.org/viewvc?rev=1042090&view=rev - 2.2.x patch: http://people.apache.org/~covener/patches/2.2.x-userdir_merge.diff - +1 covener, rpluem, poirier - * mod_dav: If an unknown Content-* header is received for a PUT request, we must not ignore it but reply with 501 per RFC 2616 9.6. PR: 42978 diff --git a/modules/mappers/mod_userdir.c b/modules/mappers/mod_userdir.c index 2270757d007..e479d3e23c5 100644 --- a/modules/mappers/mod_userdir.c +++ b/modules/mappers/mod_userdir.c @@ -81,6 +81,10 @@ #define DEFAULT_USER_DIR NULL #endif +#define O_DEFAULT 0 +#define O_ENABLE 1 +#define O_DISABLE 2 + module AP_MODULE_DECLARE_DATA userdir_module; typedef struct { @@ -100,7 +104,7 @@ static void *create_userdir_config(apr_pool_t *p, server_rec *s) { userdir_config *newcfg = apr_pcalloc(p, sizeof(*newcfg)); - newcfg->globally_disabled = 0; + newcfg->globally_disabled = O_DEFAULT; newcfg->userdir = DEFAULT_USER_DIR; newcfg->enabled_users = apr_table_make(p, 4); newcfg->disabled_users = apr_table_make(p, 4); @@ -108,9 +112,21 @@ static void *create_userdir_config(apr_pool_t *p, server_rec *s) return newcfg; } -#define O_DEFAULT 0 -#define O_ENABLE 1 -#define O_DISABLE 2 +static void *merge_userdir_config(apr_pool_t *p, void *basev, void *overridesv) +{ + userdir_config *cfg = apr_pcalloc(p, sizeof(userdir_config)); + userdir_config *base = basev, *overrides = overridesv; + + cfg->globally_disabled = (overrides->globally_disabled != O_DEFAULT) ? overrides->globally_disabled : base->globally_disabled; + cfg->userdir = (overrides->userdir != DEFAULT_USER_DIR) ? overrides->userdir : base->userdir; + + /* not merged */ + cfg->enabled_users = overrides->enabled_users; + cfg->disabled_users = overrides->disabled_users; + + return cfg; +} + static const char *set_user_dir(cmd_parms *cmd, void *dummy, const char *arg) { @@ -137,19 +153,15 @@ static const char *set_user_dir(cmd_parms *cmd, void *dummy, const char *arg) * need do no more at this point than record the fact. */ if (strlen(usernames) == 0) { - s_cfg->globally_disabled = 1; + s_cfg->globally_disabled = O_DISABLE; return NULL; } usertable = s_cfg->disabled_users; } else if ((!strcasecmp(kw, "enable")) || (!strcasecmp(kw, "enabled"))) { - /* - * The "disable" keyword can stand alone or take a list of names, but - * the "enable" keyword requires the list. Whinge if it doesn't have - * it. - */ if (strlen(usernames) == 0) { - return "UserDir \"enable\" keyword requires a list of usernames"; + s_cfg->globally_disabled = O_ENABLE; + return NULL; } usertable = s_cfg->enabled_users; } @@ -234,7 +246,7 @@ static int translate_userdir(request_rec *r) * If there's a global interdiction on UserDirs, check to see if this * name is one of the Blessed. */ - if (s_cfg->globally_disabled + if (s_cfg->globally_disabled == O_DISABLE && apr_table_get(s_cfg->enabled_users, w) == NULL) { return DECLINED; } @@ -363,7 +375,7 @@ module AP_MODULE_DECLARE_DATA userdir_module = { NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */ create_userdir_config, /* server config */ - NULL, /* merge server config */ + merge_userdir_config, /* merge server config */ userdir_cmds, /* command apr_table_t */ register_hooks /* register hooks */ };