Hi!
I need the web server to continue working if the user has deleted the
log directory.
I wrote a small patch. Are there any obvious errors in it that disrupt
the operation of the web server or lead to a memory / pointer leak?
Index: apache2-2.4.10/modules/loggers/mod_log_config.c
===================================================================
--- apache2-2.4.10.orig/modules/loggers/mod_log_config.c
+++ apache2-2.4.10/modules/loggers/mod_log_config.c
@@ -1367,7 +1367,10 @@ static config_log_state *open_config_log
cls->log_writer = log_writer_init(p, s, cls->fname);
if (cls->log_writer == NULL)
- return NULL;
+ /* Do not fail if can't open log files,
+ * just stop logging for that file.
+ */
+ cls->fname = NULL;
return cls;
}
@@ -1729,27 +1732,6 @@ static int log_pre_config(apr_pool_t *p,
static int check_log_dir(apr_pool_t *p, server_rec *s, config_log_state *cls)
{
- if (!cls->fname || cls->fname[0] == '|' || !cls->directive) {
- return OK;
- }
- else {
- char *abs = ap_server_root_relative(p, cls->fname);
- char *dir = ap_make_dirstr_parent(p, abs);
- apr_finfo_t finfo;
- const ap_directive_t *directive = cls->directive;
- apr_status_t rv = apr_stat(&finfo, dir, APR_FINFO_TYPE, p);
- cls->directive = NULL; /* Don't check this config_log_state again */
- if (rv == APR_SUCCESS && finfo.filetype != APR_DIR)
- rv = APR_ENOTDIR;
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, rv, s,
- APLOGNO(02297)
- "Cannot access directory '%s' for log file '%s' "
- "defined at %s:%d", dir, cls->fname,
- directive->filename, directive->line_num);
- return !OK;
- }
- }
return OK;
}
Index: apache2-2.4.10/server/log.c
===================================================================
--- apache2-2.4.10.orig/server/log.c
+++ apache2-2.4.10/server/log.c
@@ -430,7 +430,11 @@ static int open_error_log(server_rec *s,
ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00091)
"%s: could not open error log file %s.",
ap_server_argv0, fname);
- return DONE;
+ /* No error loggin if
+ * can't open log file
+ * do not fail!
+ */
+ s->error_log=NULL;
}
}
Index: apache2-2.4.10/server/core.c
===================================================================
--- apache2-2.4.10.orig/server/core.c
+++ apache2-2.4.10/server/core.c
@@ -4438,28 +4438,6 @@ AP_DECLARE(int) ap_sys_privileges_handle
static int check_errorlog_dir(apr_pool_t *p, server_rec *s)
{
- if (!s->error_fname || s->error_fname[0] == '|'
- || strcmp(s->error_fname, "syslog") == 0) {
- return APR_SUCCESS;
- }
- else {
- char *abs = ap_server_root_relative(p, s->error_fname);
- char *dir = ap_make_dirstr_parent(p, abs);
- apr_finfo_t finfo;
- apr_status_t rv = apr_stat(&finfo, dir, APR_FINFO_TYPE, p);
- if (rv == APR_SUCCESS && finfo.filetype != APR_DIR)
- rv = APR_ENOTDIR;
- if (rv != APR_SUCCESS) {
- const char *desc = "main error log";
- if (s->defn_name)
- desc = apr_psprintf(p, "error log of vhost defined at %s:%d",
- s->defn_name, s->defn_line_number);
- ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, rv,
- ap_server_conf, APLOGNO(02291)
- "Cannot access directory '%s' for %s", dir, desc);
- return !OK;
- }
- }
return OK;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]