Bug 1015268

Summary: configtest does not fail if RewriteLog directive points to non-existent directory
Product: Red Hat Enterprise Linux 6 Reporter: stein
Component: httpdAssignee: Luboš Uhliarik <luhliari>
Status: CLOSED CURRENTRELEASE QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.4CC: jorton, stein
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-27 16:09:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description stein 2013-10-03 18:52:07 UTC
Description of problem:
'service httpd configtest' returns successfully with 'Syntax OK' if the mod_rewrite RewriteLog directive is used and points to a directory that does not exist.  However, Apache fails to start (service httpd start/restart) with this error in the configuration and logs "[error] (2)No such file or directory: mod_rewrite: could not open RewriteLog file /invalid/directory/rewrite.log"

Version-Release number of selected component (if applicable):
2.2.15.29.el6_4

How reproducible:
always

Steps to Reproduce:
1. Add a RewriteLog directive referencing an invalid directory, to an Apache configuration file:

 RewriteLog "/invalid/directory/rewrite.log"

2. Run 'service httpd configtest'.  It will not detect an error and returns 'Syntax OK'
 
3. Restart Apache, 'service httpd restart'

4. Apache fails to start and logs a "No such file or directory" error in the error_log


Actual results:
'service httpd configtest' returns 'Syntax OK'


Expected results:
'service httpd configtest' should return an error


Additional info:

Comment 1 Joe Orton 2013-10-03 20:15:59 UTC
Thanks for contacting us.

"configtest" aims to check whether the configuration file is syntactically valid, and does not guarantee the server will start up.

I am generally reluctant to try adding such validation features because it is impossible in many cases to guard against false positives.  Is there a particular problem you are trying to solve here?

Comment 2 stein 2013-10-03 21:13:39 UTC
I am using puppet to automate the management of some Apache config files.  When a config file changes, puppet is set up to restart Apache, but I also run a configtest first to make sure Apache will restart OK.

/sbin/service httpd configtest && /sbin/service httpd graceful

I expect configtest to catch any errors that would cause Apache to fail to start.

Another way of looking at this problem is whether mod_rewrite should cause Apache to fail if it encounters an invalid path in a RewriteLog directive.  Could mod_rewrite log the error, but allow Apache to continue to load?

Comment 5 Joe Orton 2014-10-27 16:09:12 UTC
Looking again: there's actually not a good place to hook in such a feature in 2.2 unfortunately. 

In 2.4 there is no RewriteLog directive any more, since we have fine-grained error log control.  But we do have a new hook which allows more sophisticated validation of directives, and ErrorLog does have a specific check for directory existence.

So probably an unsatisfactory answer, sorry, but "upgrade to RHEL 7" is probably the best answer we have here.