Bug 429933

Summary: Logwatch does not escape regex metacharacters in postfix log processing
Product: [Fedora] Fedora Reporter: Benjamin Gordon <ben>
Component: logwatchAssignee: Ivana Varekova <varekova>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-01-28 11:30:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Benjamin Gordon 2008-01-23 21:00:10 UTC
Description of problem:

When processing the postfix log, logwatch embeds part of a log line into a regex without escaping 
metacharacters.  If the previously matched email address contains special characters like [, *, ?, etc, this 
can cause it to fail to process the log.

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

logwatch-7.3.6-17.noarch

How reproducible:

Always

Steps to Reproduce:
1. Get a line into /var/log/maillog that contains e.g. to=<*@wanadoo.fr>
2. Run logwatch
3.
  
Actual results:

Postfix section of output is replaced with an error message.

Expected results:

Line is correctly processed along with others.

Additional info:

This patch takes care of the problem, or at least the part that my particular log files were triggering:

--- scripts/services/postfix.orig	2008-01-23 13:48:17.000000000 -0700
+++ scripts/services/postfix	2008-01-23 13:19:48.000000000 -0700
@@ -2163,7 +2163,7 @@
    #print "HOSTREPLY: \"$hostreply\"\n";
    if (($host,$r1) = ($hostreply =~ /host (\S+) said: $re_DSN[\- ]"?(.*)"?$/o)) {
       # Strip recipient address from host's reply - we already have it in $recip.
-      $r1 =~ s/[<(]?$recip[>)]?\W*//ig;
+      $r1 =~ s/[<(]?\Q$recip\E[>)]?\W*//ig;
 
       # Strip and capture "in reply to XYZ command" from host's reply
       if ($r1 =~ s/\s*[(]?(in reply to .* command)[)]?//) {

Comment 1 Ivana Varekova 2008-01-28 11:30:16 UTC
Thanks - fixed in logwatch-7.3.6-18.fc9.