You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2012/02/28 13:06:54 UTC

svn commit: r1294600 - /httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c

Author: jim
Date: Tue Feb 28 12:06:53 2012
New Revision: 1294600

URL: http://svn.apache.org/viewvc?rev=1294600&view=rev
Log:
Merge r1243651 from trunk:

Check during config test that directories for access logs exist

PR 29941

Submitted by: sf
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c

Modified: httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c?rev=1294600&r1=1294599&r2=1294600&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c (original)
+++ httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c Tue Feb 28 12:06:53 2012
@@ -263,6 +263,8 @@ typedef struct {
     void *log_writer;
     char *condition_var;
     ap_expr_info_t *condition_expr;
+    /** place of definition or NULL if already checked */
+    const ap_directive_t *directive;
 } config_log_state;
 
 /*
@@ -1271,6 +1273,7 @@ static const char *add_custom_log(cmd_pa
 
     cls->fname = fn;
     cls->format_string = fmt;
+    cls->directive = cmd->directive;
     if (fmt == NULL) {
         cls->format = NULL;
     }
@@ -1678,9 +1681,59 @@ static int log_pre_config(apr_pool_t *p,
     return OK;
 }
 
+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;
+}
+
+static int log_check_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
+{
+    int rv = OK;
+    while (s) {
+        multi_log_state *mls = ap_get_module_config(s->module_config,
+                                                    &log_config_module);
+        /*
+         * We don't need to check mls->server_config_logs because it just
+         * points to the parent server's mls->config_logs.
+         */
+        apr_array_header_t *log_list = mls->config_logs;
+        config_log_state *clsarray = (config_log_state *) log_list->elts;
+        int i;
+        for (i = 0; i < log_list->nelts; ++i) {
+            if (check_log_dir(ptemp, s, &clsarray[i]) != OK)
+                rv = !OK;
+        }
+
+        s = s->next;
+    }
+    return rv;
+}
+
 static void register_hooks(apr_pool_t *p)
 {
     ap_hook_pre_config(log_pre_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
+    ap_hook_check_config(log_check_config,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_child_init(init_child,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_open_logs(init_config_log,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_log_transaction(multi_log_transaction,NULL,NULL,APR_HOOK_MIDDLE);



Re: svn commit: r1294600 - /httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Tue, Feb 28, 2012 at 8:42 AM, Jim Jagielski <ji...@jagunet.com> wrote:
>
> On Feb 28, 2012, at 7:14 AM, Jeff Trawick wrote:
>
>> On Tue, Feb 28, 2012 at 7:06 AM,  <ji...@apache.org> wrote:
>>> Author: jim
>>> Date: Tue Feb 28 12:06:53 2012
>>> New Revision: 1294600
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1294600&view=rev
>>> Log:
>>> Merge r1243651 from trunk:
>>>
>>> Check during config test that directories for access logs exist
>>>
>>> PR 29941
>>
>> CH CH CH CH CHANGES
>>
>> (some of the recent trunk fixes didn't have that, probably in
>> anticipation of having to remove it from trunk CHANGES in the short
>> term when merged to 2.4.x)
>>
>
> Most likely... but since CHANGES, as with most docs, are CTR,
> this shouldn't be a blocker or deep concern, imo.

Fixing CHANGES is part of the merge-to-stable-branch workflow. Miss it
then and it is too easy to forget about.  (Presumably me complaining
will result in the last couple of CHANGE-less backported fixes getting
tweaked appropriately ;) )

Re: svn commit: r1294600 - /httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Feb 28, 2012, at 7:14 AM, Jeff Trawick wrote:

> On Tue, Feb 28, 2012 at 7:06 AM,  <ji...@apache.org> wrote:
>> Author: jim
>> Date: Tue Feb 28 12:06:53 2012
>> New Revision: 1294600
>> 
>> URL: http://svn.apache.org/viewvc?rev=1294600&view=rev
>> Log:
>> Merge r1243651 from trunk:
>> 
>> Check during config test that directories for access logs exist
>> 
>> PR 29941
> 
> CH CH CH CH CHANGES
> 
> (some of the recent trunk fixes didn't have that, probably in
> anticipation of having to remove it from trunk CHANGES in the short
> term when merged to 2.4.x)
> 

Most likely... but since CHANGES, as with most docs, are CTR,
this shouldn't be a blocker or deep concern, imo.

Re: svn commit: r1294600 - /httpd/httpd/branches/2.4.x/modules/loggers/mod_log_config.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Tue, Feb 28, 2012 at 7:06 AM,  <ji...@apache.org> wrote:
> Author: jim
> Date: Tue Feb 28 12:06:53 2012
> New Revision: 1294600
>
> URL: http://svn.apache.org/viewvc?rev=1294600&view=rev
> Log:
> Merge r1243651 from trunk:
>
> Check during config test that directories for access logs exist
>
> PR 29941

CH CH CH CH CHANGES

(some of the recent trunk fixes didn't have that, probably in
anticipation of having to remove it from trunk CHANGES in the short
term when merged to 2.4.x)