Skip to content

Commit

Permalink
Merge pull request #542 from jeffmccune/ticket/2.7rc/12881_fix_cron_m…
Browse files Browse the repository at this point in the history
…issing_provider_error_message

(#12881) Fix cron type default name error on windows
  • Loading branch information
slippycheeze committed Mar 2, 2012
2 parents 46903a3 + 2d8d9ce commit 51a3090
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/puppet/type/cron.rb
Expand Up @@ -352,7 +352,10 @@ def should_to_s(newvalue = @should)
The user defaults to whomever Puppet is running as."

defaultto { Etc.getpwuid(Process.uid).name || "root" }
defaultto {
struct = Etc.getpwuid(Process.uid)
struct.respond_to?(:name) && struct.name or 'root'
}
end

newproperty(:target) do
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/type/cron_spec.rb
Expand Up @@ -468,4 +468,10 @@
entry = described_class.new(:name => "test_entry", :ensure => :absent)
entry.value(:command).should == nil
end

it "should default to user => root if Etc.getpwuid(Process.uid) returns nil (#12357)" do
Etc.expects(:getpwuid).returns(nil)
entry = described_class.new(:name => "test_entry", :ensure => :present)
entry.value(:user).should eql "root"
end
end

0 comments on commit 51a3090

Please sign in to comment.