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