sendmail uninitialized value (beta-7-4-2)

"gulikoza" <[email protected]> Wed, 7 Jan 2015 09:27:59 +0100
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Hi,

In revision 276 on the beta-7-4-2 branch, the 'use diagnostics;' line was
uncommented. This causes uninitialized value warnings like:

--------------------- sendmail Begin ------------------------

 Use of uninitialized value $RelayName in pattern match (m//) at
        /usr/share/logwatch/scripts/services/sendmail line 709, <STDIN> line
1284 (#1)
     (W uninitialized) An undefined value was used as if it were already
     defined.  It was interpreted as a "" or a 0, but maybe it was a
mistake.
     To suppress this warning assign a defined value to your variables.

     To help you figure out what was undefined, perl will try to tell you
the
     name of the variable (if any) that was undefined. In some cases it
cannot
     do this, so it also tells you what operation you used the undefined
value
     in.  Note, however, that perl optimizes your program and the operation
     displayed in the warning may not necessarily appear literally in your
     program.  For example, "that $foo" is usually optimized into "that "
     . $foo, and the warning will refer to the concatenation (.) operator,
     even though there is no . in your program.

 Use of uninitialized value $RelayName in pattern match (m//) at
        /usr/share/logwatch/scripts/services/sendmail line 709, <STDIN> line
1375 (#1)
 Use of uninitialized value $RelayName in pattern match (m//) at
        /usr/share/logwatch/scripts/services/sendmail line 709, <STDIN> line
1417 (#1)
 Use of uninitialized value $RelayName in pattern match (m//) at
..

I haven't exactly dug into the code but it would seem mailer=local and
mailer=prog are hitting this codepath and these entries do not contain
'relay='.

For some reason, some of the mailer=local lines have full e-mail address in
the 'to=' so they're probably hitting '($CleanTo =~ m/\w+\@[\w\.]+/)' regex
on line 709. Also some of my mailer=prog lines also contain e-mail addresses
(vacation messages with -a and -f switches).

A simple solution would be to add the '&& (defined $RelayName)' to those if
sentences before the $RelayName check, but I don't know if that captures the
intentions of this code...
Another solution would be to handle prog and local mailers differently...

Regards,
gulikoza


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net