You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2011/02/08 03:58:51 UTC

svn commit: r1068257 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS modules/mappers/mod_userdir.c

Author: covener
Date: Tue Feb  8 02:58:51 2011
New Revision: 1068257

URL: http://svn.apache.org/viewvc?rev=1068257&view=rev
Log:
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

Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/modules/mappers/mod_userdir.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?rev=1068257&r1=1068256&r2=1068257&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Tue Feb  8 02:58:51 2011
@@ -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]

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=1068257&r1=1068256&r2=1068257&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Tue Feb  8 02:58:51 2011
@@ -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

Modified: httpd/httpd/branches/2.2.x/modules/mappers/mod_userdir.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/mappers/mod_userdir.c?rev=1068257&r1=1068256&r2=1068257&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/mappers/mod_userdir.c (original)
+++ httpd/httpd/branches/2.2.x/modules/mappers/mod_userdir.c Tue Feb  8 02:58:51 2011
@@ -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_p
 {
     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_p
     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_parm
          * 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
      * 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_mo
     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 */
 };