Menu

#110 ReadConfigFile damages case-sensitive values, specifically Pre_Ignore

v7.7
closed
nobody
None
5
2022-12-22
2022-10-01
No

Observed using Logwatch 7.5.5 (released 01/22/21) on Debian GNU/Linux 11 (bullseye) installed as package using apt.

ReadConfigFile systematically folds name and value of every configuration parameter to lower case.
This is inappropriate when the value may be case-sensitive, as for Pre_Ignore. Moreover, ReadConfigFile also hides this case-folding by showing the original name and value in the relevant debugging message. ReadConfigFile should (a) protect values corresponding to "special" names (as CleanVars does) and (b) avoid giving a debugging message which is likely to cause confusion.

Attached files show proposed patch and behaviour observed both before and after applying it.

3 Attachments

Discussion

  • Bjorn

    Bjorn - 2022-10-01

    Indeed, the lowercasing is confusing. But values and keys have been lower-cased in Logwatch for a very long time, perhaps starting when first written. Not sure why, but perhaps to accommodate case-insensitive filesystems. Changing that now would break a lot of configured systems.

    The CleanVars does allow preserving the case of the value. Can you try the attached patch?

     
    • Niall O'Reilly

      Niall O'Reilly - 2022-10-02

      By inspection (and confirmed by testing), this can't help. CleanVars() is invoked at lines 147, 185, and 275 of (v7.5.5 .. master) logwatch.pl. The service-specific configuration file (in the case of interest to me, $ConfigDir/conf/services/sudo.conf) is not read until line 380.

      Besides, ReadConfigFile() forces all names and values to lower case immediately on reading them (at lines 1112, 1113). Because of this, any necessary preservation of "special" configuration items has to be implemented there, and the invocations of CleanVars() at lines 185 and 275 seem to be redundant. The value of invoking CleanVars() at line 147 is not clear, since this invocation is prior to reading any files, so that only hard-coded default configuration values (which ought not to need "cleaning") can be available at that stage.

      Attached patch (which works for me) leaves each value untouched in ReadConfigFile(), for later attention in CleanVars(); includes Bjorn's suggested change to the latter; and invokes it again after reading each per-service configuration file.

      In other words:
      1. ReadConfigFile() no longer pre-empts and contradicts the intent of CleanVars();
      2. Values for "special" keys, including pre_ignore, are handled in one place in CleanVars(); and
      3. A missing "late" invocation of CleanVars() is added.

      I may have missed something.

       

      Last edit: Niall O'Reilly 2022-10-02
  • Bjorn

    Bjorn - 2022-10-04

    Thanks for your analysis, Niall.

    I was confused about CleanVars - it precludes the lower-casing of logwatch command options, not the service-specific configuration variables. So indeed the patch does not help; I haven't looked at that code in a while.

    For service-specific configuration file values, the way to prevent lower-casing is to use double-quotes on the value.

    Looks like the CleanVars on line 147 might be to clean up the $Conf variables set previously, either from ENV variables, or reading non-service configuration files prior to the invocation of this CleanVars.

     
    • Niall O'Reilly

      Niall O'Reilly - 2022-10-04

      Thanks, Bjorn.

      Using double-quotes is the magic I needed. I had overlooked or misunderstood line 977.
      I couldn't find mention of this in /usr/share/doc/logwatch/HOWTO-Customize-LogWatch.gz .

       
  • Bjorn

    Bjorn - 2022-12-22
    • status: open --> closed
     

Log in to post a comment.