#! /bin/sh /usr/share/dpatch/dpatch-run
## 300_mod_userdir_fix.dpatch by  <cabeca@omega02.ist.utl.pt>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
Index: apache2-2.2.22/modules/mappers/mod_userdir.c
===================================================================
--- apache2-2.2.22.orig/modules/mappers/mod_userdir.c	2011-02-08 02:58:51.000000000 +0000
+++ apache2-2.2.22/modules/mappers/mod_userdir.c	2013-09-09 18:25:24.000000000 +0100
@@ -198,9 +198,11 @@ static int translate_userdir(request_rec
     const userdir_config *s_cfg;
     char *name = r->uri;
     const char *userdirs;
+    request_rec *notes_req;
     const char *w, *dname;
     char *redirect;
     apr_finfo_t statbuf;
+    
 
     /*
      * If the URI doesn't match our basic pattern, we've nothing to do with
@@ -324,8 +326,17 @@ static int translate_userdir(request_rec
             if (*userdirs && dname[0] == 0)
                 r->finfo = statbuf;
 
+            /* We could be servicing a sub-request; make sure we put notes
+             * on the main request.
+             */
+            if (r->main) {
+                notes_req = r->main;
+            } else {
+                notes_req = r;
+            }
+
             /* For use in the get_suexec_identity phase */
-            apr_table_setn(r->notes, "mod_userdir_user", w);
+            apr_table_setn(notes_req->notes, "mod_userdir_user", w);
 
             return OK;
         }
