I didn't think of this before, but there is one edge case this would miss: if 
someone (for whatever reason) wants a relative ErrorLog *file* named `syslog*', 
for example `ErrorLog "syslog-httpd.log"' or `ErrorLog "syslog.log"'. It 
appears that this is already broken in server/log.c, though. Also, log.c is 
using str(n)casecmp. The following would make things consistent and handle this 
weird edge case. Thoughts?

Index: server/core.c
===================================================================
--- server/core.c       (revision 1829431)
+++ server/core.c       (working copy)
@@ -4867,7 +4867,8 @@
 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) {
+        || strcasecmp(s->error_fname, "syslog") == 0
+        || strncasecmp(s->error_fname, "syslog:", 7) == 0) {
         return APR_SUCCESS;
     }
     else {
@@ -5281,7 +5282,9 @@
     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);
-    if (s->error_fname[0] != '|' && strcmp(s->error_fname, "syslog") != 0)
+    if (s->error_fname[0] != '|'
+        && strcasecmp(s->error_fname, "syslog") != 0
+        && strncasecmp(s->error_fname, "syslog:", 7) != 0)
         tmp = ap_server_root_relative(p, s->error_fname);
     else
         tmp = s->error_fname;
@@ -5456,4 +5459,3 @@
     core_cmds,                    /* command apr_table_t */
     register_hooks                /* register hooks */
 };
-
Index: server/log.c
===================================================================
--- server/log.c        (revision 1829431)
+++ server/log.c        (working copy)
@@ -396,7 +396,8 @@
     }

 #ifdef HAVE_SYSLOG
-    else if (!strncasecmp(s->error_fname, "syslog", 6)) {
+    else if (strcasecmp(s->error_fname, "syslog") == 0
+             || strncasecmp(s->error_fname, "syslog:", 7) == 0) {
         if ((fname = strchr(s->error_fname, ':'))) {
             /* s->error_fname could be [level]:[tag] (see #60525) */
             const char *tag;



> On 18 Apr 2018, at 04:57, elu...@apache.org wrote:
> 
> Author: elukey
> Date: Wed Apr 18 09:57:08 2018
> New Revision: 1829430
> 
> URL: http://svn.apache.org/viewvc?rev=1829430&view=rev
> Log:
> core-check_errorlog_dir_syslog.patch: add suggestions from STATUS
> 
> Credis to jhriggs and jailletc36
> 
> 
> Modified:
>    httpd/httpd/patches/2.4.x/core-check_errorlog_dir_syslog.patch
> 
> Modified: httpd/httpd/patches/2.4.x/core-check_errorlog_dir_syslog.patch
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/patches/2.4.x/core-check_errorlog_dir_syslog.patch?rev=1829430&r1=1829429&r2=1829430&view=diff
> ==============================================================================
> --- httpd/httpd/patches/2.4.x/core-check_errorlog_dir_syslog.patch (original)
> +++ httpd/httpd/patches/2.4.x/core-check_errorlog_dir_syslog.patch Wed Apr 18 
> 09:57:08 2018
> @@ -1,14 +1,23 @@
> Index: server/core.c
> ===================================================================
> ---- server/core.c   (revision 1829090)
> +--- server/core.c   (revision 1829429)
> +++ server/core.c   (working copy)
> @@ -4867,7 +4867,7 @@
>  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) {
> -+        || !strncmp(s->error_fname, "syslog", 6)) {
> ++        || strncmp(s->error_fname, "syslog", 6) == 0) {
>          return APR_SUCCESS;
>      }
>      else {
> +@@ -5281,7 +5281,7 @@
> +     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);
> +-    if (s->error_fname[0] != '|' && strcmp(s->error_fname, "syslog") != 0)
> ++    if (s->error_fname[0] != '|' && strncmp(s->error_fname, "syslog", 6) != 
> 0)
> +         tmp = ap_server_root_relative(p, s->error_fname);
> +     else
> +         tmp = s->error_fname;
> 


Reply via email to