SA Bugzilla – Bug 4192
require_version doesn't work as expected
Last modified: 2005-04-24 11:05:50 UTC
I have a problem restricting a config file to be used only in versions > 3 I put if (version < 3.000000) require_version 3.00 endif at the beginning of the config file. 2.64 simply ignores the if and endif lines and skips the config file, which is what I want. So does 3.00002, which is not what I want - and not what I expected: configuration file "/etc/spamassassin/test.cf" requires version 3.00 of SpamAssassin, but this is code version 3.000002. this is SA installed from a debian package: Installed: 3.0.2-1 see also http://www.rulesemporium.com/forums/showthread.php?s=dc9546ff91252eee23136adf643bf80f&threadid=108
Subject: Re: New: require_version doesn't work as expected On Mon, Mar 14, 2005 at 01:18:21PM -0800, bugzilla-daemon@bugzilla.spamassassin.org wrote: > I have a problem restricting a config file to be used only in versions > 3 > > at the beginning of the config file. 2.64 simply ignores the if and endif lines > and skips the config file, which is what I want. So does 3.00002, which is not > what I want - and not what I expected: > configuration file "/etc/spamassassin/test.cf" requires version 3.00 of > SpamAssassin, but this is code version 3.000002. The docs are quite clear about this: require_version n.nnnnnn Indicates that the entire file, from this line on, requires a certain version of SpamAssassin to run. If a different (older or newer) version of SpamAssassin tries to read the configuration from this file, it will output a warning instead, and ignore it. Note: The version used is in the internal SpamAssassin version format which is "x.yyyzzz", where x is major version, y is minor version, and z is maintenance version. So 3.0.0 is 3.000000, and 3.4.80 is 3.004080.
I want to make files useable in versions >= 3 without knowing the precise n.nnnnnn version, I have read the docs.
The docs are equally clear: > if (conditional perl expression) > Used to support conditional interpretation of the configuration file. Lines between this and a corresponding endif line, will be ignored unless the conditional expression evaluates as true (in the perl sense; that is, defined and non-0). I read this to mean that if a require_version line is inside a false if/endif, the require_version line would be ignored because of that false condition. Is that a wrong interpretation? Bob Menschel
Subject: Re: require_version doesn't work as expected On Tue, Mar 15, 2005 at 07:49:09PM -0800, bugzilla-daemon@bugzilla.spamassassin.org wrote: > The docs are equally clear: > > if (conditional perl expression) > > Used to support conditional interpretation of the configuration file. Lines > between this and a corresponding endif line, will be ignored unless the > conditional expression evaluates as true (in the perl sense; that is, defined > and non-0). > > I read this to mean that if a require_version line is inside a false if/endif, > the require_version line would be ignored because of that false condition. Is > that a wrong interpretation? Oh! I see what you're saying. I was so focused on the error message that I missed the big picture. Sorry. Ok, so the answer at the moment is: require_version is a specially treated "preprocessed" config option, so the if blocks don't apply to it. That said, I don't see a reason why they shouldn't be usable in the way you're trying to use them. I committed a patch to trunk (r157740) to fix this. I'll put the patch up on the ticket in a minute and reassign to the 3.0.3 queue.
reaiming
Created attachment 2704 [details] suggested patch simply moves the "skip_parsing" check up 1 block above require_version.
yeah, quite right. +1
This will requrie a documentation change. Currently it reads "[require_version] Indicates that the entire file, from this line on, requires a certain version of SpamAssassin to run." Now it's really "the current block, or the rest of the file if found outside of an IF block." Other than that +1. As an aside, the reporter doesn't need the require_version tag at all to do what he wants to do. He simply needs to put his 3.x statements inside the IF block and use "if (version > 2.999999)".
Subject: Re: require_version doesn't work as expected On Wed, Mar 16, 2005 at 11:19:10AM -0800, bugzilla-daemon@bugzilla.spamassassin.org wrote: > This will requrie a documentation change. Currently it reads "[require_version] > Indicates that the entire file, from this line on, requires a certain version of > SpamAssassin to run." > > Now it's really "the current block, or the rest of the file if found outside of > an IF block." It's still the entire file. The blocks are still controlable by the if statement, assuming v3 or higher. > As an aside, the reporter doesn't need the require_version tag at all to do what > he wants to do. He simply needs to put his 3.x statements inside the IF block > and use "if (version > 2.999999)". 2.x didn't have the if/endif, so it'll just plow through and try using them. I think that's the only reason you'd ever do the if ... { require_version ... } thing is to have config files that work with 2.x and 3.x at the same time.
committed. r164515