Bug 7675 - The -D/--debug option is mis-parsed in sa-learn, spamassassin, and possibly other scripts.
Summary: The -D/--debug option is mis-parsed in sa-learn, spamassassin, and possibly o...
Status: NEW
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamassassin (show other bugs)
Version: unspecified
Hardware: All All
: P2 major
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
Depends on:
Reported: 2019-01-02 20:19 UTC by Bill Cole
Modified: 2019-01-02 20:19 UTC (History)
0 users

Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Cole 2019-01-02 20:19:56 UTC
There is a logical error/pitfall in parsing the -D/--debug argument in AT LEAST the spamassassin and sa-learn scripts which needs to be either fixed or documented. If you do not follow the option with a list of debug channels, another option, or '--' (indicating the end of options,) it MUST be the last token on the command line. If there is one or more pathnames after --debug, the first will be interpreted as a debug channel. I do not see exactly how this could lead 

Conversely, the documentation for sa-learn does not actually cover the use case of feeding the messages to be learned to sa-learn via STDIN, although that does work. 

For 3.4.3 I think the best approach is to document that -D/--debug MUST have an argument rather than saying it defaults to 'all' when in fact that does not work in the sa-learn or spamassassin scripts if it is at all possible to interpret the following command line token as a channel. It could be disruptive in the terminal 3.x release to change the behavior, even if the existing behavior is arguably a bug. 

For 4.x we need to fix the behavior. Either remove the botched 'default to all' implementation which is inconsistent with the implementation of an extensible set of arbitrarily-named debug channels or fix the Getopt::Long-based command line parser to detect when the token after -D/--debug is a pathname.

I ran across this while investigating bug 7674, which may or may not be related.