You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2012/03/26 00:24:14 UTC

svn commit: r1305164 - in /httpd/httpd/branches/2.4.x: CHANGES STATUS docs/manual/mod/core.xml include/ap_mmn.h include/http_config.h include/http_main.h server/config.c server/core.c

Author: minfrin
Date: Sun Mar 25 22:24:13 2012
New Revision: 1305164

URL: http://svn.apache.org/viewvc?rev=1305164&view=rev
Log:
Backport:
core: Add ap_runtime_dir_relative() and DefaultRuntimeDir.
Submitted by: trawick
Reviewed by: jim, minfrin

Modified:
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/docs/manual/mod/core.xml
    httpd/httpd/branches/2.4.x/include/ap_mmn.h
    httpd/httpd/branches/2.4.x/include/http_config.h
    httpd/httpd/branches/2.4.x/include/http_main.h
    httpd/httpd/branches/2.4.x/server/config.c
    httpd/httpd/branches/2.4.x/server/core.c

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Sun Mar 25 22:24:13 2012
@@ -6,6 +6,9 @@ Changes with Apache 2.4.2
      envvars: Fix insecure handling of LD_LIBRARY_PATH that could lead to the
      current working directory to be searched for DSOs. [Stefan Fritsch]
 
+  *) core: Add ap_runtime_dir_relative() and DefaultRuntimeDir.
+     [Jeff Trawick]
+
   *) core: Fix breakage of Listen directives with MPMs that use a
      per-directory config. PR 52904. [Stefan Fritsch]
 

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Sun Mar 25 22:24:13 2012
@@ -88,16 +88,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  * core: Add ap_runtime_dir_relative() and DefaultRuntimeDir
-    Trunk patch: http://svn.apache.org/viewvc?rev=1297955&view=rev
-                http://svn.apache.org/viewvc?rev=1297956&view=rev
-                http://svn.apache.org/viewvc?rev=1297959&view=rev
-                http://svn.apache.org/viewvc?rev=1298432&view=rev
-    2.4.x patch: http://people.apache.org/~jim/patches/runtime_dir.patch
-    +1: jim, trawick (docs may need adjusting depending how much exploitation
-        is possible vs. what is in 2.4.1; no need to tie possible adjustments
-        to the code though)
-    +1: minfrin
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:

Modified: httpd/httpd/branches/2.4.x/docs/manual/mod/core.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/mod/core.xml?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/mod/core.xml (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/mod/core.xml Sun Mar 25 22:24:13 2012
@@ -605,6 +605,37 @@ headers</description>
 </directivesynopsis>
 
 <directivesynopsis>
+<name>DefaultRuntimeDir</name>
+<description>Base directory for the server run-time files</description>
+<syntax>DefaultRuntimeDir <var>directory-path</var></syntax>
+<default>DefaultRuntimeDir DEFAULT_REL_RUNTIMEDIR (logs/)</default>
+<contextlist><context>server config</context></contextlist>
+
+<usage>
+    <p>The <directive>DefaultRuntimeDir</directive> directive sets the
+    directory in which the server will create various run-time files
+    (shared memory, locks, etc.). If set as a relative path, the full path
+    will be relative to <directive>ServerRoot</directive></p>
+
+    <example><title>Example</title>
+      DefaultRuntimeDir scratch/
+    </example>
+
+    <p>The default location of <directive>DefaultRuntimeDir</directive> may be
+    modified by changing the <code>DEFAULT_REL_RUNTIMEDIR</code> #define
+    at build time.</p>
+
+   <p>Note: <directive>ServerRoot</directive> should be specified before this
+   directive is used, otherwise the default value of <directive>ServerRoot</directive>
+   would be used to set the base directory.</p>
+
+</usage>
+<seealso><a href="../misc/security_tips.html#serverroot">the
+    security tips</a> for information on how to properly set
+    permissions on the <directive>ServerRoot</directive></seealso>
+</directivesynopsis>
+
+<directivesynopsis>
 <name>DefaultType</name>
 <description>This directive has no effect other than to emit warnings
 if the value is not <code>none</code>. In prior versions, DefaultType

Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Sun Mar 25 22:24:13 2012
@@ -390,7 +390,8 @@
  *                         move core_net rec definition to http_core.h;
  *                         add insert_network_bucket hook, AP_DECLINED
  * 20120211.0 (2.4.1-dev)  Change re_nsub in ap_regex_t from apr_size_t to int.
- * 20120211.1 (2.4.2)      Add AP_HAVE_C99
+ * 20120211.1 (2.4.2-dev)  Add AP_HAVE_C99
+ * 20120211.2 (2.4.2-dev)  Add ap_runtime_dir_relative
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -398,7 +399,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/branches/2.4.x/include/http_config.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/http_config.h?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/http_config.h (original)
+++ httpd/httpd/branches/2.4.x/include/http_config.h Sun Mar 25 22:24:13 2012
@@ -706,6 +706,14 @@ AP_DECLARE_NONSTD(const char *) ap_set_d
  */
 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 DefaultRuntimeDir 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... */
 
 /**

Modified: httpd/httpd/branches/2.4.x/include/http_main.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/http_main.h?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/http_main.h (original)
+++ httpd/httpd/branches/2.4.x/include/http_main.h Sun Mar 25 22:24:13 2012
@@ -43,6 +43,11 @@ extern "C" {
 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 */

Modified: httpd/httpd/branches/2.4.x/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/config.c?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/config.c (original)
+++ httpd/httpd/branches/2.4.x/server/config.c Sun Mar 25 22:24:13 2012
@@ -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_server_root_relati
     }
 }
 
+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;

Modified: httpd/httpd/branches/2.4.x/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/core.c?rev=1305164&r1=1305163&r2=1305164&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/core.c (original)
+++ httpd/httpd/branches/2.4.x/server/core.c Sun Mar 25 22:24:13 2012
@@ -2790,6 +2790,24 @@ static const char *set_server_root(cmd_p
     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);
@@ -3943,6 +3961,8 @@ AP_INIT_TAKE1("ServerSignature", set_sig
   "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"),