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]
* 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" */
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.
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
return err;
}
+ ap_unixd_config.group_name = arg;
ap_unixd_config.group_id = ap_gname2id(arg);
return NULL;
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 */
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);
}
return;
}
apr_file_open_stdout(&out, pconf);
+ apr_file_printf(out, "Server certificates:\n");
/* Dump the filenames of all configured server certificates to
* stdout. */
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]);
}
}
typedef struct {
const char *user_name;
+ const char *group_name;
uid_t user_id;
gid_t group_id;
int suexec_enabled;
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);
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);
" -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,
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;
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':
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)
{
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]" : "");
+ }
+}