httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1180681 - in /httpd/httpd/trunk: ./ include/ modules/arch/unix/ modules/ssl/ os/unix/ server/
Date Sun, 09 Oct 2011 18:35:24 GMT
Author: sf
Date: Sun Oct  9 18:35:23 2011
New Revision: 1180681

URL: http://svn.apache.org/viewvc?rev=1180681&view=rev
Log:
Add -D DUMP_RUN_CFG option to dump some configuration items
from the parsed (or default) config. This is useful for init scripts that
need to setup temporary directories and permissions, for example if those
temporary directories are located on a ram disk.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/include/util_mutex.h
    httpd/httpd/trunk/modules/arch/unix/mod_unixd.c
    httpd/httpd/trunk/modules/ssl/ssl_engine_config.c
    httpd/httpd/trunk/os/unix/unixd.h
    httpd/httpd/trunk/server/core.c
    httpd/httpd/trunk/server/main.c
    httpd/httpd/trunk/server/mpm_common.c
    httpd/httpd/trunk/server/util_mutex.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun Oct  9 18:35:23 2011
@@ -12,6 +12,10 @@ Changes with Apache 2.3.15
      PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener,
      <lowprio20 gmail.com>]
 
+  *) core, unixd: Add -D DUMP_RUN_CFG option to dump some configuration items
+     from the parsed (or default) config. This is useful for init scripts that
+     need to setup temporary directories and permissions. [Stefan Fritsch]
+
   *) core, mod_actions, mod_asis: Downgrade error log messages which accompany
      a 404 request status from loglevel error to info. PR: 35768. [Stefan
      Fritsch]

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Sun Oct  9 18:35:23 2011
@@ -356,7 +356,8 @@
  *                         ap_realloc()
  * 20110724.9 (2.3.15-dev) add ap_varbuf_pdup() and ap_varbuf_regsub()
  * 20110724.10(2.3.15-dev) Export ap_max_mem_free
- * 20111009.0 (2.3.15-dev) Remove ap_proxy_removestr()
+ * 20111009.0 (2.3.15-dev) Remove ap_proxy_removestr(),
+ *                         add ap_unixd_config.group_name
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Sun Oct  9 18:35:23 2011
@@ -290,6 +290,7 @@ const char *ap_mpm_set_max_requests(cmd_
 extern const char *ap_pid_fname;
 const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
                                const char *arg);
+void ap_mpm_dump_pidfile(apr_pool_t *p, apr_file_t *out);
 
 /*
  * The directory that the server changes directory to dump core.

Modified: httpd/httpd/trunk/include/util_mutex.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/util_mutex.h?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/include/util_mutex.h (original)
+++ httpd/httpd/trunk/include/util_mutex.h Sun Oct  9 18:35:23 2011
@@ -213,6 +213,8 @@ AP_DECLARE(apr_status_t) ap_proc_mutex_c
                                               apr_pool_t *pool,
                                               apr_int32_t options);
 
+AP_CORE_DECLARE(void) ap_dump_mutexes(apr_pool_t *p, server_rec *s, apr_file_t *out);
+
 #ifdef __cplusplus
 }
 #endif

Modified: httpd/httpd/trunk/modules/arch/unix/mod_unixd.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/arch/unix/mod_unixd.c?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/arch/unix/mod_unixd.c (original)
+++ httpd/httpd/trunk/modules/arch/unix/mod_unixd.c Sun Oct  9 18:35:23 2011
@@ -239,6 +239,7 @@ unixd_set_group(cmd_parms *cmd, void *du
         return err;
     }
 
+    ap_unixd_config.group_name = arg;
     ap_unixd_config.group_id = ap_gname2id(arg);
 
     return NULL;
@@ -289,6 +290,7 @@ unixd_pre_config(apr_pool_t *pconf, apr_
     apr_finfo_t wrapper;
     ap_unixd_config.user_name = DEFAULT_USER;
     ap_unixd_config.user_id = ap_uname2id(DEFAULT_USER);
+    ap_unixd_config.group_name = DEFAULT_GROUP;
     ap_unixd_config.group_id = ap_gname2id(DEFAULT_GROUP);
 
     ap_unixd_config.chroot_dir = NULL; /* none */
@@ -369,11 +371,30 @@ AP_DECLARE(int) ap_unixd_setup_child(voi
     return 0;
 }
 
+static void unixd_dump_config(apr_pool_t *p, server_rec *s)
+{
+    apr_file_t *out = NULL;
+    apr_uid_t uid = ap_unixd_config.user_id;
+    apr_gid_t gid = ap_unixd_config.group_id;
+    char *no_root = "";
+    if (geteuid() != 0)
+        no_root = " not_used";
+    apr_file_open_stdout(&out, p);
+    apr_file_printf(out, "User: name=\"%s\" id=%lu%s\n",
+                    ap_unixd_config.user_name, (unsigned long)uid, no_root);
+    apr_file_printf(out, "Group: name=\"%s\" id=%lu%s\n",
+                    ap_unixd_config.group_name, (unsigned long)gid, no_root);
+    if (ap_unixd_config.chroot_dir)
+        apr_file_printf(out, "ChrootDir: \"%s\"%s\n",
+                        ap_unixd_config.chroot_dir, no_root);
+}
+
 static void unixd_hooks(apr_pool_t *pool)
 {
     ap_hook_pre_config(unixd_pre_config,
                        NULL, NULL, APR_HOOK_FIRST);
-
+    ap_hook_test_config(unixd_dump_config,
+                        NULL, NULL, APR_HOOK_FIRST);
     ap_hook_drop_privileges(unixd_drop_privileges,
                             NULL, NULL, APR_HOOK_MIDDLE);
 }

Modified: httpd/httpd/trunk/modules/ssl/ssl_engine_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_engine_config.c?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_engine_config.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_engine_config.c Sun Oct  9 18:35:23 2011
@@ -1724,6 +1724,7 @@ void ssl_hook_ConfigTest(apr_pool_t *pco
         return;
     }
     apr_file_open_stdout(&out, pconf);
+    apr_file_printf(out, "Server certificates:\n");
 
     /* Dump the filenames of all configured server certificates to
      * stdout. */
@@ -1735,7 +1736,7 @@ void ssl_hook_ConfigTest(apr_pool_t *pco
             int i;
 
             for (i = 0; (i < SSL_AIDX_MAX) && pks->cert_files[i]; i++) {
-                apr_file_printf(out, "%s\n", pks->cert_files[i]);
+                apr_file_printf(out, "  %s\n", pks->cert_files[i]);
             }
         }
 

Modified: httpd/httpd/trunk/os/unix/unixd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/os/unix/unixd.h?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/os/unix/unixd.h (original)
+++ httpd/httpd/trunk/os/unix/unixd.h Sun Oct  9 18:35:23 2011
@@ -73,6 +73,7 @@ AP_DECLARE_HOOK(ap_unix_identity_t *, ge
 
 typedef struct {
     const char *user_name;
+    const char *group_name;
     uid_t user_id;
     gid_t group_id;
     int suexec_enabled;

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Sun Oct  9 18:35:23 2011
@@ -4674,6 +4674,43 @@ AP_DECLARE(apr_uint32_t) ap_random_pick(
     return number;
 }
 
+static void core_dump_config(apr_pool_t *p, server_rec *s)
+{
+    core_server_config *sconf = ap_get_core_module_config(s->module_config);
+    apr_file_t *out = NULL;
+    char *tmp;
+    const char **defines;
+    int i;
+    if (!ap_exists_config_define("DUMP_RUN_CFG"))
+        return;
+
+    apr_file_open_stdout(&out, p);
+    apr_file_printf(out, "ServerRoot: \"%s\"\n", ap_server_root);
+    tmp = ap_server_root_relative(p, sconf->ap_document_root);
+    apr_file_printf(out, "Main DocumentRoot: \"%s\"\n", tmp);
+    tmp = ap_server_root_relative(p, s->error_fname);
+    apr_file_printf(out, "Main ErrorLog: \"%s\"\n", tmp);
+    if (ap_scoreboard_fname) {
+        tmp = ap_server_root_relative(p, ap_scoreboard_fname);
+        apr_file_printf(out, "ScoreBoardFile: \"%s\"\n", tmp);
+    }
+    ap_dump_mutexes(p, s, out);
+    ap_mpm_dump_pidfile(p, out);
+
+    defines = (const char **)ap_server_config_defines->elts;
+    for (i = 0; i < ap_server_config_defines->nelts; i++) {
+        const char *name = defines[i];
+        const char *val = NULL;
+        if (server_config_defined_vars)
+           val = apr_table_get(server_config_defined_vars, name);
+        if (val)
+            apr_file_printf(out, "Define: %s=%s\n", name, val);
+        else
+            apr_file_printf(out, "Define: %s\n", name);
+    }
+
+}
+
 static void register_hooks(apr_pool_t *p)
 {
     errorlog_hash = apr_hash_make(p);
@@ -4694,6 +4731,7 @@ static void register_hooks(apr_pool_t *p
 
     ap_hook_pre_config(core_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
     ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
+    ap_hook_test_config(core_dump_config,NULL,NULL,APR_HOOK_FIRST);
     ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_open_logs(ap_open_logs,NULL,NULL,APR_HOOK_REALLY_FIRST);

Modified: httpd/httpd/trunk/server/main.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/main.c?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/server/main.c (original)
+++ httpd/httpd/trunk/server/main.c Sun Oct  9 18:35:23 2011
@@ -415,10 +415,11 @@ static void usage(process_rec *process)
                  "  -L                 : list available configuration "
                  "directives");
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "  -t -D DUMP_VHOSTS  : show parsed settings (currently only "
-                 "vhost settings)");
+                 "  -t -D DUMP_VHOSTS  : show parsed vhost settings");
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "  -S                 : a synonym for -t -D DUMP_VHOSTS");
+                 "  -t -D DUMP_RUN_CFG : show parsed run settings");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
+                 "  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG");
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "  -t -D DUMP_MODULES : show all loaded modules ");
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
@@ -511,11 +512,14 @@ int main(int argc, const char * const ar
         case 'D':
             new = (char **)apr_array_push(ap_server_config_defines);
             *new = apr_pstrdup(pcommands, opt_arg);
-            /* Setting -D DUMP_VHOSTS is equivalent to setting -S */
+            /* Setting -D DUMP_VHOSTS should work like setting -S */
             if (strcmp(opt_arg, "DUMP_VHOSTS") == 0)
                 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
+            /* Setting -D DUMP_RUN_CFG should work like setting -S */
+            else if (strcmp(opt_arg, "DUMP_RUN_CFG") == 0)
+                ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
             /* Setting -D DUMP_MODULES is equivalent to setting -M */
-            if (strcmp(opt_arg, "DUMP_MODULES") == 0)
+            else if (strcmp(opt_arg, "DUMP_MODULES") == 0)
                 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
             break;
 
@@ -563,6 +567,8 @@ int main(int argc, const char * const ar
             ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
             new = (char **)apr_array_push(ap_server_config_defines);
             *new = "DUMP_VHOSTS";
+            new = (char **)apr_array_push(ap_server_config_defines);
+            *new = "DUMP_RUN_CFG";
             break;
 
         case 'M':

Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Sun Oct  9 18:35:23 2011
@@ -299,6 +299,12 @@ const char *ap_mpm_set_pidfile(cmd_parms
     return NULL;
 }
 
+void ap_mpm_dump_pidfile(apr_pool_t *p, apr_file_t *out)
+{
+    apr_file_printf(out, "PidFile: \"%s\"\n",
+                    ap_server_root_relative(p, ap_pid_fname));
+}
+
 const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
                                     const char *arg)
 {

Modified: httpd/httpd/trunk/server/util_mutex.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_mutex.c?rev=1180681&r1=1180680&r2=1180681&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_mutex.c (original)
+++ httpd/httpd/trunk/server/util_mutex.c Sun Oct  9 18:35:23 2011
@@ -496,3 +496,65 @@ AP_DECLARE(apr_status_t) ap_proc_mutex_c
 
     return rv;
 }
+
+AP_CORE_DECLARE(void) ap_dump_mutexes(apr_pool_t *p, server_rec *s, apr_file_t *out)
+{
+    apr_hash_index_t *idx;
+    mutex_cfg_t *defcfg = apr_hash_get(mxcfg_by_type, "default", APR_HASH_KEY_STRING);
+    for (idx = apr_hash_first(p, mxcfg_by_type); idx; idx = apr_hash_next(idx))
+    {
+        mutex_cfg_t *mxcfg;
+        const char *name, *mech;
+        const void *name_;
+        const char *dir = "";
+        apr_hash_this(idx, &name_, NULL, NULL);
+        name = name_;
+        mxcfg = mxcfg_lookup(p, name);
+        if (mxcfg == defcfg && strcmp(name, "default") != 0) {
+            apr_file_printf(out, "Mutex %s: using_defaults\n", name);
+            continue;
+        }
+        if (mxcfg->none) {
+            apr_file_printf(out, "Mutex %s: none\n", name);
+            continue;
+        }
+        switch (mxcfg->mech) {
+        case APR_LOCK_DEFAULT:
+            mech = "default";
+            break;
+#if APR_HAS_FCNTL_SERIALIZE
+        case APR_LOCK_FCNTL:
+            mech = "fcntl";
+            break;
+#endif
+#if APR_HAS_FLOCK_SERIALIZE
+        case APR_LOCK_FLOCK:
+            mech = "flock";
+            break;
+#endif
+#if APR_HAS_POSIXSEM_SERIALIZE
+        case APR_LOCK_POSIXSEM:
+            mech = "posixsem";
+            break;
+#endif
+#if APR_HAS_SYSVSEM_SERIALIZE
+        case APR_LOCK_SYSVSEM:
+            mech = "sysvsem";
+            break;
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+        case APR_LOCK_PROC_PTHREAD:
+            mech = "pthread";
+            break;
+#endif
+        default:
+            ap_assert(0);
+        }
+
+        if (mxcfg->dir)
+            dir = ap_server_root_relative(p, mxcfg->dir);
+
+        apr_file_printf(out, "Mutex %s: dir=\"%s\" mechanism=%s %s\n", name, dir, mech,
+                        mxcfg->omit_pid ? "[OmitPid]" : "");
+    }
+}



Mime
View raw message