From: Eric Covener Date: Sat, 4 Dec 2010 03:30:40 +0000 (+0000) Subject: PR44076: allow "userdir disabled" or "userdir public_html" in global scope to X-Git-Tag: 2.3.10~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8270929a330957fb1c7a82b446f3c79c3fb939d2;p=apache 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1042090 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 03302dbf92..e026c79bf6 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.10 + *) mod_userdir: Add merging of enable, disable, and filename arguments + to UserDir directive, leave userlists unmerged. PR 44076 [Eric Covener] + *) httpd: When no -k option is provided on the httpd command line, the server was starting without checking for an existing pidfile. PR 50350 [Eric Covener] diff --git a/modules/mappers/mod_userdir.c b/modules/mappers/mod_userdir.c index e396b035f3..6b07253841 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 (!*usernames) { - 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 (!*usernames) { - 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 @@ AP_DECLARE_MODULE(userdir) = { 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 */ };