52592b
# ./pullrev.sh 1842929 1842931
52592b
http://svn.apache.org/viewvc?view=revision&revision=1842929
52592b
http://svn.apache.org/viewvc?view=revision&revision=1842931
52592b
52592b
--- httpd-2.4.37/acinclude.m4.r1842929+
52592b
+++ httpd-2.4.37/acinclude.m4
52592b
@@ -45,6 +45,7 @@
52592b
   APACHE_SUBST(installbuilddir)
52592b
   APACHE_SUBST(runtimedir)
52592b
   APACHE_SUBST(proxycachedir)
52592b
+  APACHE_SUBST(statedir)
52592b
   APACHE_SUBST(other_targets)
52592b
   APACHE_SUBST(progname)
52592b
   APACHE_SUBST(prefix)
52592b
@@ -663,6 +664,7 @@
52592b
   APACHE_SUBST_EXPANDED_ARG(runtimedir)
52592b
   APACHE_SUBST_EXPANDED_ARG(logfiledir)
52592b
   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
52592b
+  APACHE_SUBST_EXPANDED_ARG(statedir)
52592b
 ])
52592b
 
52592b
 dnl 
52592b
--- httpd-2.4.37/config.layout.r1842929+
52592b
+++ httpd-2.4.37/config.layout
52592b
@@ -29,6 +29,7 @@
52592b
     includedir:    ${prefix}/include
52592b
     localstatedir: ${prefix}
52592b
     runtimedir:    ${localstatedir}/logs
52592b
+    statedir:      ${localstatedir}/state
52592b
     logfiledir:    ${localstatedir}/logs
52592b
     proxycachedir: ${localstatedir}/proxy
52592b
 </Layout>
52592b
@@ -54,6 +55,7 @@
52592b
     includedir:    ${prefix}/include+
52592b
     localstatedir: ${prefix}/var+
52592b
     runtimedir:    ${localstatedir}/run
52592b
+    statedir:      ${localstatedir}/state
52592b
     logfiledir:    ${localstatedir}/log
52592b
     proxycachedir: ${localstatedir}/proxy
52592b
 </Layout>
52592b
@@ -78,6 +80,7 @@
52592b
     includedir:    /System/Library/Frameworks/Apache.framework/Versions/2.0/Headers
52592b
     localstatedir: /var
52592b
     runtimedir:    ${prefix}/Logs
52592b
+    statedir:      ${prefix}/State
52592b
     logfiledir:    ${prefix}/Logs
52592b
     proxycachedir: ${prefix}/ProxyCache
52592b
 </Layout>
52592b
@@ -102,6 +105,7 @@
52592b
     includedir:    ${prefix}/include+
52592b
     localstatedir: /var
52592b
     runtimedir:    ${localstatedir}/run
52592b
+    statedir:      ${localstatedir}/state
52592b
     logfiledir:    ${localstatedir}/log+
52592b
     proxycachedir: ${runtimedir}/proxy
52592b
 </Layout>
52592b
@@ -126,6 +130,7 @@
52592b
     includedir:    ${prefix}/include/apache
52592b
     localstatedir: /var
52592b
     runtimedir:    ${localstatedir}/run
52592b
+    statedir:      ${localstatedir}/lib/httpd
52592b
     logfiledir:    ${localstatedir}/log/httpd
52592b
     proxycachedir: ${localstatedir}/cache/httpd
52592b
 </Layout>     
52592b
@@ -151,6 +156,7 @@
52592b
     includedir:    ${prefix}/include/httpd
52592b
     runtimedir:    /run/httpd
52592b
     logfiledir:    ${localstatedir}/log/httpd
52592b
+    statedir:      ${localstatedir}/lib/httpd
52592b
     proxycachedir: ${localstatedir}/cache/httpd/proxy
52592b
 </Layout>     
52592b
 
52592b
@@ -175,6 +181,7 @@
52592b
     localstatedir: /var${prefix}
52592b
     runtimedir:    ${localstatedir}/run
52592b
     logfiledir:    ${localstatedir}/logs
52592b
+    statedir:      ${localstatedir}/state
52592b
     proxycachedir: ${localstatedir}/proxy
52592b
 </Layout>
52592b
 
52592b
@@ -197,6 +204,7 @@
52592b
     cgidir:        ${datadir}/cgi-bin
52592b
     includedir:    ${prefix}/include/apache
52592b
     localstatedir: /var/lib/httpd
52592b
+    statedir:      ${localstatedir}
52592b
     runtimedir:    /var/run
52592b
     logfiledir:    /var/log/httpd
52592b
     proxycachedir: /var/cache/httpd
52592b
@@ -223,6 +231,7 @@
52592b
     localstatedir: /var
52592b
     runtimedir:    ${localstatedir}/run
52592b
     logfiledir:    ${localstatedir}/log/httpd
52592b
+    statedir:      ${prefix}/state
52592b
     proxycachedir: ${localstatedir}/proxy
52592b
 </Layout>
52592b
 
52592b
@@ -246,6 +255,7 @@
52592b
     includedir:    ${exec_prefix}/include
52592b
     localstatedir: ${prefix}
52592b
     runtimedir:    /var/run
52592b
+    statedir:      ${datadir}/state
52592b
     logfiledir:    ${datadir}/logs
52592b
     proxycachedir: ${datadir}/proxy
52592b
 </Layout>
52592b
@@ -271,6 +281,7 @@
52592b
     localstatedir: ${prefix}
52592b
     runtimedir:    ${prefix}/logs
52592b
     logfiledir:    ${prefix}/logs
52592b
+    statedir:      ${prefix}/state
52592b
     proxycachedir: ${prefix}/proxy
52592b
 </Layout>
52592b
 
52592b
@@ -315,6 +326,7 @@
52592b
     cgidir:        ${prefix}/usr/lib/cgi-bin
52592b
     includedir:    ${exec_prefix}/include/apache2
52592b
     localstatedir: ${prefix}/var/lock/apache2
52592b
+    statedir:      ${prefix}/var/lib/apache2
52592b
     runtimedir:    ${prefix}/var/run/apache2
52592b
     logfiledir:    ${prefix}/var/log/apache2
52592b
     proxycachedir: ${prefix}/var/cache/apache2/proxy
52592b
@@ -343,6 +355,7 @@
52592b
     manualdir:     ${datadir}/manual
52592b
     cgidir:        ${datadir}/cgi-bin
52592b
     runtimedir:    ${localstatedir}/run
52592b
+    runtimedir:    ${localstatedir}/lib/httpd
52592b
     logfiledir:    ${localstatedir}/log/httpd
52592b
     proxycachedir: ${localstatedir}/cache/httpd/cache-root
52592b
 </Layout>
52592b
@@ -366,6 +379,7 @@
52592b
     manualdir:     ${prefix}/manual
52592b
     includedir:    ${prefix}/include
52592b
     localstatedir: /var/httpd
52592b
+    statedir:      ${localstatedir}/state
52592b
     runtimedir:    ${localstatedir}/run
52592b
     logfiledir:    ${localstatedir}/logs
52592b
     proxycachedir: ${localstatedir}/proxy
52592b
@@ -391,6 +405,7 @@
52592b
     includedir:      ${prefix}/include/httpd
52592b
     localstatedir:   /var
52592b
     runtimedir:      ${localstatedir}/run/httpd
52592b
+    statedir:        ${localstatedir}/lib/httpd
52592b
     logfiledir:      ${localstatedir}/log/httpd
52592b
     proxycachedir:   ${localstatedir}/cache/httpd
52592b
 </Layout>
52592b
--- httpd-2.4.37/configure.in.r1842929+
52592b
+++ httpd-2.4.37/configure.in
52592b
@@ -41,7 +41,7 @@
52592b
 AC_PREFIX_DEFAULT(/usr/local/apache2)
52592b
 
52592b
 dnl Get the layout here, so we can pass the required variables to apr
52592b
-APR_ENABLE_LAYOUT(Apache, [errordir iconsdir htdocsdir cgidir])
52592b
+APR_ENABLE_LAYOUT(Apache, [errordir iconsdir htdocsdir cgidir statedir])
52592b
 
52592b
 dnl reparse the configure arguments.
52592b
 APR_PARSE_ARGUMENTS
52592b
--- httpd-2.4.37/include/ap_config_layout.h.in.r1842929+
52592b
+++ httpd-2.4.37/include/ap_config_layout.h.in
52592b
@@ -60,5 +60,7 @@
52592b
 #define DEFAULT_REL_LOGFILEDIR "@rel_logfiledir@"
52592b
 #define DEFAULT_EXP_PROXYCACHEDIR "@exp_proxycachedir@"
52592b
 #define DEFAULT_REL_PROXYCACHEDIR "@rel_proxycachedir@"
52592b
+#define DEFAULT_EXP_STATEDIR "@exp_statedir@"
52592b
+#define DEFAULT_REL_STATEDIR "@rel_statedir@"
52592b
 
52592b
 #endif /* AP_CONFIG_LAYOUT_H */
52592b
--- httpd-2.4.37/include/http_config.h.r1842929+
52592b
+++ httpd-2.4.37/include/http_config.h
52592b
@@ -757,6 +757,14 @@
52592b
  */
52592b
 AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *fname);
52592b
 
52592b
+/**
52592b
+ * Compute the name of a persistent state file (e.g. a database or
52592b
+ * long-lived cache) relative to the appropriate state directory.
52592b
+ * Absolute paths are returned as-is.  The state directory is
52592b
+ * configured via the DefaultStateDir directive or at build time.
52592b
+ */
52592b
+AP_DECLARE(char *) ap_state_dir_relative(apr_pool_t *p, const char *fname);
52592b
+
52592b
 /* Finally, the hook for dynamically loading modules in... */
52592b
 
52592b
 /**
52592b
--- httpd-2.4.37/Makefile.in.r1842929+
52592b
+++ httpd-2.4.37/Makefile.in
52592b
@@ -213,6 +213,7 @@
52592b
 install-other:
52592b
 	@test -d $(DESTDIR)$(logfiledir) || $(MKINSTALLDIRS) $(DESTDIR)$(logfiledir)
52592b
 	@test -d $(DESTDIR)$(runtimedir) || $(MKINSTALLDIRS) $(DESTDIR)$(runtimedir)
52592b
+	@test -d $(DESTDIR)$(statedir) || $(MKINSTALLDIRS) $(DESTDIR)$(statedir)
52592b
 	@for ext in dll x; do \
52592b
 		file=apachecore.$$ext; \
52592b
 		if test -f $$file; then \
52592b
--- httpd-2.4.37/modules/dav/fs/mod_dav_fs.c.r1842929+
52592b
+++ httpd-2.4.37/modules/dav/fs/mod_dav_fs.c
52592b
@@ -29,6 +29,10 @@
52592b
 
52592b
 extern module AP_MODULE_DECLARE_DATA dav_fs_module;
52592b
 
52592b
+#ifndef DEFAULT_DAV_LOCKDB
52592b
+#define DEFAULT_DAV_LOCKDB "davlockdb"
52592b
+#endif
52592b
+
52592b
 const char *dav_get_lockdb_path(const request_rec *r)
52592b
 {
52592b
     dav_fs_server_conf *conf;
52592b
@@ -39,7 +43,11 @@
52592b
 
52592b
 static void *dav_fs_create_server_config(apr_pool_t *p, server_rec *s)
52592b
 {
52592b
-    return apr_pcalloc(p, sizeof(dav_fs_server_conf));
52592b
+    dav_fs_server_conf *conf = apr_pcalloc(p, sizeof(dav_fs_server_conf));
52592b
+
52592b
+    conf->lockdb_path = ap_state_dir_relative(p, DEFAULT_DAV_LOCKDB);
52592b
+
52592b
+    return conf;
52592b
 }
52592b
 
52592b
 static void *dav_fs_merge_server_config(apr_pool_t *p,
52592b
--- httpd-2.4.37/modules/md/mod_md_config.c.r1842929+
52592b
+++ httpd-2.4.37/modules/md/mod_md_config.c
52592b
@@ -54,10 +54,14 @@
52592b
 
52592b
 #define DEF_VAL     (-1)
52592b
 
52592b
+#ifndef MD_DEFAULT_BASE_DIR
52592b
+#define MD_DEFAULT_BASE_DIR "md"
52592b
+#endif
52592b
+
52592b
 /* Default settings for the global conf */
52592b
 static md_mod_conf_t defmc = {
52592b
     NULL,
52592b
-    "md",
52592b
+    NULL,
52592b
     NULL,
52592b
     NULL,
52592b
     80,
52592b
@@ -112,6 +116,7 @@
52592b
         memcpy(mod_md_config, &defmc, sizeof(*mod_md_config));
52592b
         mod_md_config->mds = apr_array_make(pool, 5, sizeof(const md_t *));
52592b
         mod_md_config->unused_names = apr_array_make(pool, 5, sizeof(const md_t *));
52592b
+        mod_md_config->base_dir = ap_state_dir_relative(pool, MD_DEFAULT_BASE_DIR);
52592b
         
52592b
         apr_pool_cleanup_register(pool, NULL, cleanup_mod_config, apr_pool_cleanup_null);
52592b
     }
52592b
--- httpd-2.4.37/server/core.c.r1842929+
52592b
+++ httpd-2.4.37/server/core.c
52592b
@@ -129,6 +129,8 @@
52592b
 AP_DECLARE_DATA int ap_run_mode = AP_SQ_RM_UNKNOWN;
52592b
 AP_DECLARE_DATA int ap_config_generation = 0;
52592b
 
52592b
+static const char *core_state_dir;
52592b
+
52592b
 static void *create_core_dir_config(apr_pool_t *a, char *dir)
52592b
 {
52592b
     core_dir_config *conf;
52592b
@@ -3104,6 +3106,24 @@
52592b
     return NULL;
52592b
 }
52592b
 
52592b
+static const char *set_state_dir(cmd_parms *cmd, void *dummy, const char *arg)
52592b
+{
52592b
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
52592b
+
52592b
+    if (err != NULL) {
52592b
+        return err;
52592b
+    }
52592b
+
52592b
+    if ((apr_filepath_merge((char**)&core_state_dir, NULL,
52592b
+                            ap_server_root_relative(cmd->temp_pool, arg),
52592b
+                            APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS)
52592b
+        || !ap_is_directory(cmd->temp_pool, core_state_dir)) {
52592b
+        return "DefaultStateDir must be a valid directory, absolute or relative to ServerRoot";
52592b
+    }
52592b
+
52592b
+    return NULL;
52592b
+}
52592b
+
52592b
 static const char *set_timeout(cmd_parms *cmd, void *dummy, const char *arg)
52592b
 {
52592b
     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT);
52592b
@@ -4398,6 +4418,8 @@
52592b
   "Common directory of server-related files (logs, confs, etc.)"),
52592b
 AP_INIT_TAKE1("DefaultRuntimeDir", set_runtime_dir, NULL, RSRC_CONF | EXEC_ON_READ,
52592b
   "Common directory for run-time files (shared memory, locks, etc.)"),
52592b
+AP_INIT_TAKE1("DefaultStateDir", set_state_dir, NULL, RSRC_CONF | EXEC_ON_READ,
52592b
+  "Common directory for persistent state (databases, long-lived caches, etc.)"),
52592b
 AP_INIT_TAKE1("ErrorLog", set_server_string_slot,
52592b
   (void *)APR_OFFSETOF(server_rec, error_fname), RSRC_CONF,
52592b
   "The filename of the error log"),
52592b
@@ -5150,6 +5172,27 @@
52592b
     }
52592b
 }
52592b
 
52592b
+AP_DECLARE(char *) ap_state_dir_relative(apr_pool_t *p, const char *file)
52592b
+{
52592b
+    char *newpath = NULL;
52592b
+    apr_status_t rv;
52592b
+    const char *state_dir;
52592b
+
52592b
+    state_dir = core_state_dir
52592b
+        ? core_state_dir
52592b
+        : ap_server_root_relative(p, DEFAULT_REL_STATEDIR);
52592b
+
52592b
+    rv = apr_filepath_merge(&newpath, state_dir, file, APR_FILEPATH_TRUENAME, p);
52592b
+    if (newpath && (rv == APR_SUCCESS || APR_STATUS_IS_EPATHWILD(rv)
52592b
+                                      || APR_STATUS_IS_ENOENT(rv)
52592b
+                                      || APR_STATUS_IS_ENOTDIR(rv))) {
52592b
+        return newpath;
52592b
+    }
52592b
+    else {
52592b
+        return NULL;
52592b
+    }
52592b
+}
52592b
+
52592b
 static apr_random_t *rng = NULL;
52592b
 #if APR_HAS_THREADS
52592b
 static apr_thread_mutex_t *rng_mutex = NULL;