41a6c3
--- httpd/modules/mappers/mod_rewrite.c  2015/03/06 08:55:34 1664564
41a6c3
+++ httpd/modules/mappers/mod_rewrite.c 2015/03/06 09:14:07 1664565
41a6c3
@@ -267,6 +267,8 @@
41a6c3
     const char *dbdq;              /* SQL SELECT statement for rewritemap */
41a6c3
     const char *checkfile2;        /* filename to check for map existence
41a6c3
                                       NULL if only one file               */
41a6c3
+    const char *user;              /* run RewriteMap program as this user */
41a6c3
+    const char *group;             /* run RewriteMap program as this group */
41a6c3
 } rewritemap_entry;
41a6c3
 
41a6c3
 /* special pattern types for RewriteCond */
41a6c3
@@ -1171,6 +1173,7 @@
41a6c3
 
41a6c3
 static apr_status_t rewritemap_program_child(apr_pool_t *p,
41a6c3
                                              const char *progname, char **argv,
41a6c3
+                                             const char *user, const char *group,
41a6c3
                                              apr_file_t **fpout,
41a6c3
                                              apr_file_t **fpin)
41a6c3
 {
41a6c3
@@ -1183,6 +1186,8 @@
41a6c3
                                                   APR_FULL_BLOCK, APR_NO_PIPE))
41a6c3
         && APR_SUCCESS == (rc=apr_procattr_dir_set(procattr,
41a6c3
                                              ap_make_dirstr_parent(p, argv[0])))
41a6c3
+        && (!user || APR_SUCCESS == (rc=apr_procattr_user_set(procattr, user, "")))
41a6c3
+        && (!group || APR_SUCCESS == (rc=apr_procattr_group_set(procattr, group)))
41a6c3
         && APR_SUCCESS == (rc=apr_procattr_cmdtype_set(procattr, APR_PROGRAM))
41a6c3
         && APR_SUCCESS == (rc=apr_procattr_child_errfn_set(procattr,
41a6c3
                                                            rewrite_child_errfn))
41a6c3
@@ -1240,6 +1245,7 @@
41a6c3
         }
41a6c3
 
41a6c3
         rc = rewritemap_program_child(p, map->argv[0], map->argv,
41a6c3
+                                      map->user, map->group,
41a6c3
                                       &fpout, &fpin);
41a6c3
         if (rc != APR_SUCCESS || fpin == NULL || fpout == NULL) {
41a6c3
             ap_log_error(APLOG_MARK, APLOG_ERR, rc, s, APLOGNO(00654)
41a6c3
@@ -3018,7 +3024,7 @@
41a6c3
 }
41a6c3
 
41a6c3
 static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1,
41a6c3
-                                  const char *a2)
41a6c3
+                                  const char *a2, const char *a3)
41a6c3
 {
41a6c3
     rewrite_server_conf *sconf;
41a6c3
     rewritemap_entry *newmap;
41a6c3
@@ -3124,6 +3130,11 @@
41a6c3
 
41a6c3
         newmap->type      = MAPTYPE_PRG;
41a6c3
         newmap->checkfile = newmap->argv[0];
41a6c3
+        if (a3) {
41a6c3
+            char *tok_cntx;
41a6c3
+            newmap->user = apr_strtok(apr_pstrdup(cmd->pool, a3), ":", &tok_cntx);
41a6c3
+            newmap->group = apr_strtok(NULL, ":", &tok_cntx);
41a6c3
+        }
41a6c3
     }
41a6c3
     else if (strncasecmp(a2, "int:", 4) == 0) {
41a6c3
         newmap->type      = MAPTYPE_INT;
41a6c3
@@ -5205,8 +5216,8 @@
41a6c3
                      "an input string and a to be applied regexp-pattern"),
41a6c3
     AP_INIT_RAW_ARGS("RewriteRule",     cmd_rewriterule,     NULL, OR_FILEINFO,
41a6c3
                      "an URL-applied regexp-pattern and a substitution URL"),
41a6c3
-    AP_INIT_TAKE2(   "RewriteMap",      cmd_rewritemap,      NULL, RSRC_CONF,
41a6c3
-                     "a mapname and a filename"),
41a6c3
+    AP_INIT_TAKE23(   "RewriteMap",      cmd_rewritemap,      NULL, RSRC_CONF,
41a6c3
+                     "a mapname and a filename and options"),
41a6c3
     { NULL }
41a6c3
 };
41a6c3