Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logrotate::Rule matches regex against number #44

Open
zaphod42 opened this issue Sep 2, 2014 · 0 comments
Open

Logrotate::Rule matches regex against number #44

zaphod42 opened this issue Sep 2, 2014 · 0 comments

Comments

@zaphod42
Copy link

zaphod42 commented Sep 2, 2014

At https://github.com/rodjek/puppet-logrotate/blob/master/manifests/rule.pp#L315-L321 the $rotate variable is checked if it is a number or the string 'undef' by using a regex (it happens again later for the $shredcycles as well). Unfortunately, under the future parser numbers are actually numbers and cannot have a regex applied to them since there is no automatic conversion to string. An issue (PUP-3083) filed against puppet provides a small snippet that shows the problem:

  $test = 1

case $test {
  /^\d+$/: {
    fail('MATCH')
  }
  default: {
    fail("Not MATCH")
  }
}

The example works (issues MATCH) on puppet 3.6's current parser but not the future parser (--parser future causes it to issue Not MATCH).

The most straightforward fix for this is to just quote the case value: case "$test", which forces it to stringify the value and allows a regex to be used. This is backwards compatible with the current parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant