|
|
0e3136 |
diff --git a/Makefile.in b/Makefile.in
|
|
|
0e3136 |
index 6747aea..40c7076 100644
|
|
|
0e3136 |
--- a/Makefile.in
|
|
|
0e3136 |
+++ b/Makefile.in
|
|
|
0e3136 |
@@ -233,6 +233,7 @@ install-cgi:
|
|
|
0e3136 |
install-other:
|
|
|
0e3136 |
@test -d $(DESTDIR)$(logfiledir) || $(MKINSTALLDIRS) $(DESTDIR)$(logfiledir)
|
|
|
0e3136 |
@test -d $(DESTDIR)$(runtimedir) || $(MKINSTALLDIRS) $(DESTDIR)$(runtimedir)
|
|
|
0e3136 |
+ @test -d $(DESTDIR)$(statedir) || $(MKINSTALLDIRS) $(DESTDIR)$(statedir)
|
|
|
0e3136 |
@for ext in dll x; do \
|
|
|
0e3136 |
file=apachecore.$$ext; \
|
|
|
0e3136 |
if test -f $$file; then \
|
|
|
0e3136 |
diff --git a/acinclude.m4 b/acinclude.m4
|
|
|
0e3136 |
index b6ef442..98f1441 100644
|
|
|
0e3136 |
--- a/acinclude.m4
|
|
|
0e3136 |
+++ b/acinclude.m4
|
|
|
0e3136 |
@@ -45,6 +45,7 @@ AC_DEFUN([APACHE_GEN_CONFIG_VARS],[
|
|
|
0e3136 |
APACHE_SUBST(installbuilddir)
|
|
|
0e3136 |
APACHE_SUBST(runtimedir)
|
|
|
0e3136 |
APACHE_SUBST(proxycachedir)
|
|
|
0e3136 |
+ APACHE_SUBST(statedir)
|
|
|
0e3136 |
APACHE_SUBST(other_targets)
|
|
|
0e3136 |
APACHE_SUBST(progname)
|
|
|
0e3136 |
APACHE_SUBST(prefix)
|
|
|
0e3136 |
@@ -665,6 +666,7 @@ AC_DEFUN([APACHE_EXPORT_ARGUMENTS],[
|
|
|
0e3136 |
APACHE_SUBST_EXPANDED_ARG(runtimedir)
|
|
|
0e3136 |
APACHE_SUBST_EXPANDED_ARG(logfiledir)
|
|
|
0e3136 |
APACHE_SUBST_EXPANDED_ARG(proxycachedir)
|
|
|
0e3136 |
+ APACHE_SUBST_EXPANDED_ARG(statedir)
|
|
|
0e3136 |
])
|
|
|
0e3136 |
|
|
|
0e3136 |
dnl
|
|
|
0e3136 |
diff --git a/configure.in b/configure.in
|
|
|
0e3136 |
index 37346b2..f303784 100644
|
|
|
0e3136 |
--- a/configure.in
|
|
|
0e3136 |
+++ b/configure.in
|
|
|
0e3136 |
@@ -41,7 +41,7 @@ dnl Something seems broken here.
|
|
|
0e3136 |
AC_PREFIX_DEFAULT(/usr/local/apache2)
|
|
|
0e3136 |
|
|
|
0e3136 |
dnl Get the layout here, so we can pass the required variables to apr
|
|
|
0e3136 |
-APR_ENABLE_LAYOUT(Apache, [errordir iconsdir htdocsdir cgidir])
|
|
|
0e3136 |
+APR_ENABLE_LAYOUT(Apache, [errordir iconsdir htdocsdir cgidir statedir])
|
|
|
0e3136 |
|
|
|
0e3136 |
dnl reparse the configure arguments.
|
|
|
0e3136 |
APR_PARSE_ARGUMENTS
|
|
|
0e3136 |
diff --git a/include/ap_config_layout.h.in b/include/ap_config_layout.h.in
|
|
|
0e3136 |
index 2b4a70c..e076f41 100644
|
|
|
0e3136 |
--- a/include/ap_config_layout.h.in
|
|
|
0e3136 |
+++ b/include/ap_config_layout.h.in
|
|
|
0e3136 |
@@ -60,5 +60,7 @@
|
|
|
0e3136 |
#define DEFAULT_REL_LOGFILEDIR "@rel_logfiledir@"
|
|
|
0e3136 |
#define DEFAULT_EXP_PROXYCACHEDIR "@exp_proxycachedir@"
|
|
|
0e3136 |
#define DEFAULT_REL_PROXYCACHEDIR "@rel_proxycachedir@"
|
|
|
0e3136 |
+#define DEFAULT_EXP_STATEDIR "@exp_statedir@"
|
|
|
0e3136 |
+#define DEFAULT_REL_STATEDIR "@rel_statedir@"
|
|
|
0e3136 |
|
|
|
0e3136 |
#endif /* AP_CONFIG_LAYOUT_H */
|
|
|
0e3136 |
diff --git a/include/http_config.h b/include/http_config.h
|
|
|
0e3136 |
index 77657ae..384a90f 100644
|
|
|
0e3136 |
--- a/include/http_config.h
|
|
|
0e3136 |
+++ b/include/http_config.h
|
|
|
0e3136 |
@@ -757,6 +757,14 @@ AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
|
|
|
0e3136 |
*/
|
|
|
0e3136 |
AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *fname);
|
|
|
0e3136 |
|
|
|
0e3136 |
+/**
|
|
|
0e3136 |
+ * Compute the name of a persistent state file (e.g. a database or
|
|
|
0e3136 |
+ * long-lived cache) relative to the appropriate state directory.
|
|
|
0e3136 |
+ * Absolute paths are returned as-is. The state directory is
|
|
|
0e3136 |
+ * configured via the DefaultStateDir directive or at build time.
|
|
|
0e3136 |
+ */
|
|
|
0e3136 |
+AP_DECLARE(char *) ap_state_dir_relative(apr_pool_t *p, const char *fname);
|
|
|
0e3136 |
+
|
|
|
0e3136 |
/* Finally, the hook for dynamically loading modules in... */
|
|
|
0e3136 |
|
|
|
0e3136 |
/**
|
|
|
0e3136 |
diff --git a/modules/dav/fs/mod_dav_fs.c b/modules/dav/fs/mod_dav_fs.c
|
|
|
0e3136 |
index addfd7e..2389f8f 100644
|
|
|
0e3136 |
--- a/modules/dav/fs/mod_dav_fs.c
|
|
|
0e3136 |
+++ b/modules/dav/fs/mod_dav_fs.c
|
|
|
0e3136 |
@@ -29,6 +29,10 @@ typedef struct {
|
|
|
0e3136 |
|
|
|
0e3136 |
extern module AP_MODULE_DECLARE_DATA dav_fs_module;
|
|
|
0e3136 |
|
|
|
0e3136 |
+#ifndef DEFAULT_DAV_LOCKDB
|
|
|
0e3136 |
+#define DEFAULT_DAV_LOCKDB "davlockdb"
|
|
|
0e3136 |
+#endif
|
|
|
0e3136 |
+
|
|
|
0e3136 |
const char *dav_get_lockdb_path(const request_rec *r)
|
|
|
0e3136 |
{
|
|
|
0e3136 |
dav_fs_server_conf *conf;
|
|
|
0e3136 |
@@ -57,6 +61,24 @@ static void *dav_fs_merge_server_config(apr_pool_t *p,
|
|
|
0e3136 |
return newconf;
|
|
|
0e3136 |
}
|
|
|
0e3136 |
|
|
|
0e3136 |
+static apr_status_t dav_fs_post_config(apr_pool_t *p, apr_pool_t *plog,
|
|
|
0e3136 |
+ apr_pool_t *ptemp, server_rec *base_server)
|
|
|
0e3136 |
+{
|
|
|
0e3136 |
+ server_rec *s;
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ for (s = base_server; s; s = s->next) {
|
|
|
0e3136 |
+ dav_fs_server_conf *conf;
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ conf = ap_get_module_config(s->module_config, &dav_fs_module);
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ if (!conf->lockdb_path) {
|
|
|
0e3136 |
+ conf->lockdb_path = ap_state_dir_relative(p, DEFAULT_DAV_LOCKDB);
|
|
|
0e3136 |
+ }
|
|
|
0e3136 |
+ }
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ return OK;
|
|
|
0e3136 |
+}
|
|
|
0e3136 |
+
|
|
|
0e3136 |
/*
|
|
|
0e3136 |
* Command handler for the DAVLockDB directive, which is TAKE1
|
|
|
0e3136 |
*/
|
|
|
0e3136 |
@@ -87,6 +109,8 @@ static const command_rec dav_fs_cmds[] =
|
|
|
0e3136 |
|
|
|
0e3136 |
static void register_hooks(apr_pool_t *p)
|
|
|
0e3136 |
{
|
|
|
0e3136 |
+ ap_hook_post_config(dav_fs_post_config, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
0e3136 |
+
|
|
|
0e3136 |
dav_hook_gather_propsets(dav_fs_gather_propsets, NULL, NULL,
|
|
|
0e3136 |
APR_HOOK_MIDDLE);
|
|
|
0e3136 |
dav_hook_find_liveprop(dav_fs_find_liveprop, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
0e3136 |
diff --git a/server/core.c b/server/core.c
|
|
|
0e3136 |
index d135764..c2176b9 100644
|
|
|
0e3136 |
--- a/server/core.c
|
|
|
0e3136 |
+++ b/server/core.c
|
|
|
0e3136 |
@@ -142,6 +142,8 @@ AP_DECLARE_DATA int ap_main_state = AP_SQ_MS_INITIAL_STARTUP;
|
|
|
0e3136 |
AP_DECLARE_DATA int ap_run_mode = AP_SQ_RM_UNKNOWN;
|
|
|
0e3136 |
AP_DECLARE_DATA int ap_config_generation = 0;
|
|
|
0e3136 |
|
|
|
0e3136 |
+static const char *core_state_dir;
|
|
|
0e3136 |
+
|
|
|
0e3136 |
static void *create_core_dir_config(apr_pool_t *a, char *dir)
|
|
|
0e3136 |
{
|
|
|
0e3136 |
core_dir_config *conf;
|
|
|
0e3136 |
@@ -1444,13 +1446,16 @@ AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word)
|
|
|
0e3136 |
return res_buf;
|
|
|
0e3136 |
}
|
|
|
0e3136 |
|
|
|
0e3136 |
-static int reset_config_defines(void *dummy)
|
|
|
0e3136 |
+/* pconf cleanup - clear global variables set from config here. */
|
|
|
0e3136 |
+static apr_status_t reset_config(void *dummy)
|
|
|
0e3136 |
{
|
|
|
0e3136 |
ap_server_config_defines = saved_server_config_defines;
|
|
|
0e3136 |
saved_server_config_defines = NULL;
|
|
|
0e3136 |
server_config_defined_vars = NULL;
|
|
|
0e3136 |
ap_runtime_dir = NULL;
|
|
|
0e3136 |
- return OK;
|
|
|
0e3136 |
+ core_state_dir = NULL;
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ return APR_SUCCESS;
|
|
|
0e3136 |
}
|
|
|
0e3136 |
|
|
|
0e3136 |
/*
|
|
|
0e3136 |
@@ -3220,6 +3225,24 @@ static const char *set_runtime_dir(cmd_parms *cmd, void *dummy, const char *arg)
|
|
|
0e3136 |
return NULL;
|
|
|
0e3136 |
}
|
|
|
0e3136 |
|
|
|
0e3136 |
+static const char *set_state_dir(cmd_parms *cmd, void *dummy, const char *arg)
|
|
|
0e3136 |
+{
|
|
|
0e3136 |
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ if (err != NULL) {
|
|
|
0e3136 |
+ return err;
|
|
|
0e3136 |
+ }
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ if ((apr_filepath_merge((char**)&core_state_dir, NULL,
|
|
|
0e3136 |
+ ap_server_root_relative(cmd->temp_pool, arg),
|
|
|
0e3136 |
+ APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS)
|
|
|
0e3136 |
+ || !ap_is_directory(cmd->temp_pool, core_state_dir)) {
|
|
|
0e3136 |
+ return "DefaultStateDir must be a valid directory, absolute or relative to ServerRoot";
|
|
|
0e3136 |
+ }
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ return NULL;
|
|
|
0e3136 |
+}
|
|
|
0e3136 |
+
|
|
|
0e3136 |
static const char *set_timeout(cmd_parms *cmd, void *dummy, const char *arg)
|
|
|
0e3136 |
{
|
|
|
0e3136 |
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT);
|
|
|
0e3136 |
@@ -4521,6 +4544,8 @@ AP_INIT_TAKE1("ServerRoot", set_server_root, NULL, RSRC_CONF | EXEC_ON_READ,
|
|
|
0e3136 |
"Common directory of server-related files (logs, confs, etc.)"),
|
|
|
0e3136 |
AP_INIT_TAKE1("DefaultRuntimeDir", set_runtime_dir, NULL, RSRC_CONF | EXEC_ON_READ,
|
|
|
0e3136 |
"Common directory for run-time files (shared memory, locks, etc.)"),
|
|
|
0e3136 |
+AP_INIT_TAKE1("DefaultStateDir", set_state_dir, NULL, RSRC_CONF | EXEC_ON_READ,
|
|
|
0e3136 |
+ "Common directory for persistent state (databases, long-lived caches, etc.)"),
|
|
|
0e3136 |
AP_INIT_TAKE1("ErrorLog", set_server_string_slot,
|
|
|
0e3136 |
(void *)APR_OFFSETOF(server_rec, error_fname), RSRC_CONF,
|
|
|
0e3136 |
"The filename of the error log"),
|
|
|
0e3136 |
@@ -5055,8 +5080,7 @@ static int core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptem
|
|
|
0e3136 |
|
|
|
0e3136 |
if (!saved_server_config_defines)
|
|
|
0e3136 |
init_config_defines(pconf);
|
|
|
0e3136 |
- apr_pool_cleanup_register(pconf, NULL, reset_config_defines,
|
|
|
0e3136 |
- apr_pool_cleanup_null);
|
|
|
0e3136 |
+ apr_pool_cleanup_register(pconf, NULL, reset_config, apr_pool_cleanup_null);
|
|
|
0e3136 |
|
|
|
0e3136 |
ap_regcomp_set_default_cflags(AP_REG_DEFAULT);
|
|
|
0e3136 |
|
|
|
0e3136 |
@@ -5303,6 +5327,27 @@ AP_DECLARE(int) ap_state_query(int query)
|
|
|
0e3136 |
}
|
|
|
0e3136 |
}
|
|
|
0e3136 |
|
|
|
0e3136 |
+AP_DECLARE(char *) ap_state_dir_relative(apr_pool_t *p, const char *file)
|
|
|
0e3136 |
+{
|
|
|
0e3136 |
+ char *newpath = NULL;
|
|
|
0e3136 |
+ apr_status_t rv;
|
|
|
0e3136 |
+ const char *state_dir;
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ state_dir = core_state_dir
|
|
|
0e3136 |
+ ? core_state_dir
|
|
|
0e3136 |
+ : ap_server_root_relative(p, DEFAULT_REL_STATEDIR);
|
|
|
0e3136 |
+
|
|
|
0e3136 |
+ rv = apr_filepath_merge(&newpath, state_dir, file, APR_FILEPATH_TRUENAME, p);
|
|
|
0e3136 |
+ if (newpath && (rv == APR_SUCCESS || APR_STATUS_IS_EPATHWILD(rv)
|
|
|
0e3136 |
+ || APR_STATUS_IS_ENOENT(rv)
|
|
|
0e3136 |
+ || APR_STATUS_IS_ENOTDIR(rv))) {
|
|
|
0e3136 |
+ return newpath;
|
|
|
0e3136 |
+ }
|
|
|
0e3136 |
+ else {
|
|
|
0e3136 |
+ return NULL;
|
|
|
0e3136 |
+ }
|
|
|
0e3136 |
+}
|
|
|
0e3136 |
+
|
|
|
0e3136 |
static apr_random_t *rng = NULL;
|
|
|
0e3136 |
#if APR_HAS_THREADS
|
|
|
0e3136 |
static apr_thread_mutex_t *rng_mutex = NULL;
|