barely tested
--
Born in Roswell... married an alien...
Index: server/config.c
===================================================================
--- server/config.c (revision 1297483)
+++ server/config.c (working copy)
@@ -59,6 +59,7 @@
AP_DECLARE_DATA const char *ap_server_argv0 = NULL;
AP_DECLARE_DATA const char *ap_server_root = NULL;
+AP_DECLARE_DATA const char *ap_runtime_dir = NULL;
AP_DECLARE_DATA server_rec *ap_server_conf = NULL;
AP_DECLARE_DATA apr_pool_t *ap_pglobal = NULL;
@@ -1560,6 +1561,25 @@
}
}
+AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *file)
+{
+ char *newpath = NULL;
+ apr_status_t rv;
+ const char *runtime_dir = ap_runtime_dir ? ap_runtime_dir :
ap_server_root_relative(p, DEFAULT_REL_RUNTIMEDIR);
+
+ rv = apr_filepath_merge(&newpath, runtime_dir, file,
+ APR_FILEPATH_TRUENAME, p);
+ if (newpath && (rv == APR_SUCCESS || APR_STATUS_IS_EPATHWILD(rv)
+ || APR_STATUS_IS_ENOENT(rv)
+ || APR_STATUS_IS_ENOTDIR(rv))) {
+ return newpath;
+ }
+ else {
+ return NULL;
+ }
+}
+
+
AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive)
{
struct ap_varbuf vb;
Index: server/core.c
===================================================================
--- server/core.c (revision 1297483)
+++ server/core.c (working copy)
@@ -2775,6 +2775,24 @@
return NULL;
}
+static const char *set_runtime_dir(cmd_parms *cmd, void *dummy, const char
*arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+
+ if (err != NULL) {
+ return err;
+ }
+
+ if ((apr_filepath_merge((char**)&ap_runtime_dir, NULL,
+ ap_server_root_relative(cmd->pool, arg),
+ APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS)
+ || !ap_is_directory(cmd->temp_pool, ap_runtime_dir)) {
+ return "DefaultRuntimeDir must be a valid directory, absolute or
relative to ServerRoot";
+ }
+
+ return NULL;
+}
+
static const char *set_timeout(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
@@ -3928,6 +3946,8 @@
"En-/disable server signature (on|off|email)"),
AP_INIT_TAKE1("ServerRoot", set_server_root, NULL, RSRC_CONF | EXEC_ON_READ,
"Common directory of server-related files (logs, confs, etc.)"),
+AP_INIT_TAKE1("DefaultRuntimeDir", set_runtime_dir, NULL, RSRC_CONF |
EXEC_ON_READ,
+ "Common directory for run-time files (shared memory, locks, etc.)"),
AP_INIT_TAKE1("ErrorLog", set_server_string_slot,
(void *)APR_OFFSETOF(server_rec, error_fname), RSRC_CONF,
"The filename of the error log"),
Index: include/http_main.h
===================================================================
--- include/http_main.h (revision 1297483)
+++ include/http_main.h (working copy)
@@ -43,6 +43,11 @@
AP_DECLARE_DATA extern const char *ap_server_argv0;
/** The global server's ServerRoot */
AP_DECLARE_DATA extern const char *ap_server_root;
+/** The global server's DefaultRuntimeDir
+ * This is not usable directly in the general case; use
+ * ap_runtime_dir_relative() instead.
+ */
+AP_DECLARE_DATA extern const char *ap_runtime_dir;
/** The global server's server_rec */
AP_DECLARE_DATA extern server_rec *ap_server_conf;
/** global pool, for access prior to creation of server_rec */
Index: include/http_config.h
===================================================================
--- include/http_config.h (revision 1297483)
+++ include/http_config.h (working copy)
@@ -706,6 +706,14 @@
*/
AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
+/**
+ * Compute the name of a run-time file (e.g., shared memory "file") relative
+ * to the appropriate run-time directory. Absolute paths are returned as-is.
+ * The run-time directory is configured via the RuntimeDir directive or
+ * at build time.
+ */
+AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *fname);
+
/* Finally, the hook for dynamically loading modules in... */
/**
Index: include/ap_mmn.h
===================================================================
--- include/ap_mmn.h (revision 1297483)
+++ include/ap_mmn.h (working copy)
@@ -394,6 +394,7 @@
* add insert_network_bucket hook, AP_DECLINED
* 20120211.0 (2.5.0-dev) Change re_nsub in ap_regex_t from apr_size_t to int.
* 20120211.1 (2.5.0-dev) Add ap_palloc_debug, ap_pcalloc_debug
+ * 20120211.2 (2.5.0-dev) Add ap_runtime_dir_relative
*/
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */