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

(#12881) Fix cron type default name error on windows #542

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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