summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-05-16 16:49:22 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-05-16 16:50:29 +1000
commit38545d9a81274c16a43f7f19889cd12e52871d76 (patch)
tree8a28ab3f3535b8e234f3394f87ff99b1633f0705
parent7897335318be2bb98187b570fb7c867ebe109c12 (diff)
downloadpuppet-38545d9a81274c16a43f7f19889cd12e52871d76.tar.gz
puppet-38545d9a81274c16a43f7f19889cd12e52871d76.tar.xz
puppet-38545d9a81274c16a43f7f19889cd12e52871d76.zip
Crontab provider: fix a parse error when a line begins with a space character
Tests for Bug #1216 Updated CHANGELOG
-rw-r--r--CHANGELOG14
-rwxr-xr-xlib/puppet/provider/cron/crontab.rb2
-rwxr-xr-xtest/ral/providers/cron/crontab.rb28
3 files changed, 40 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a0c5a1213..870afb92b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,14 @@
- Instead of deleting the init scripts (with --del) we should simply disable
- it with chkconfig service off, and respectfully do the same for enable
- => true;
+ Moving all confine code out of the Provider class, and fixing #1197.
+ Created a Confiner module for the Provider class methods, enhanced
+ the interface between it and the Confine class to make sure binary
+ paths are searched for fresh each time.
+
+ Crontab provider: fix a parse error when a line begins with a space
+ character (fixes #1216)
+
+ Instead of deleting the init scripts (with --del) we should simply
+ disable it with chkconfig service off, and respectfully do the same
+ for enable => true;
Added ldap providers for users and groups.
diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb
index 7ddcc0505..e2228b15e 100755
--- a/lib/puppet/provider/cron/crontab.rb
+++ b/lib/puppet/provider/cron/crontab.rb
@@ -30,7 +30,7 @@ Puppet::Type.type(:cron).provide(:crontab,
}
crontab = record_line :crontab, :fields => %w{minute hour monthday month weekday command},
- :match => %r{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$},
+ :match => %r{^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$},
:optional => %w{minute hour weekday month monthday}, :absent => "*"
class << crontab
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 53bd76c50..900a0478e 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -599,5 +599,33 @@ class TestCronParsedProvider < Test::Unit::TestCase
result = target.read
assert_equal("# Puppet Name: test\n* 4 * * * /bin/echo yay\n", result, "Did not write out environment setting")
end
+
+ # Testing #1216
+ def test_strange_lines
+ @provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram))
+ text = " 5 \t\t 1,2 * 1 0 /bin/echo funtest"
+
+ records = nil
+ assert_nothing_raised {
+ records = @provider.parse(text)
+ }
+
+ should = {
+ :minute => %w{5},
+ :hour => %w{1 2},
+ :monthday => :absent,
+ :month => %w{1},
+ :weekday => %w{0},
+ :command => "/bin/echo funtest"
+ }
+
+ is = records.shift
+ assert(is, "Did not get record")
+
+ should.each do |p, v|
+ assert_equal(v, is[p], "did not parse %s correctly" % p)
+ end
+ end
+
end