puppet 2.6.12 → 2.6.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (43) hide show
  1. data/CHANGELOG +30 -0
  2. data/CONTRIBUTING.md +299 -0
  3. data/conf/redhat/puppet.spec +4 -1
  4. data/ext/upload_facts.rb +120 -0
  5. data/lib/puppet.rb +1 -1
  6. data/lib/puppet/application/inspect.rb +5 -2
  7. data/lib/puppet/application/queue.rb +11 -1
  8. data/lib/puppet/application/resource.rb +3 -0
  9. data/lib/puppet/defaults.rb +2 -1
  10. data/lib/puppet/indirector/facts/inventory_service.rb +20 -0
  11. data/lib/puppet/indirector/report/processor.rb +2 -0
  12. data/lib/puppet/network/handler/filebucket.rb +2 -0
  13. data/lib/puppet/network/handler/fileserver.rb +1 -0
  14. data/lib/puppet/network/handler/master.rb +1 -0
  15. data/lib/puppet/network/handler/report.rb +2 -0
  16. data/lib/puppet/network/handler/runner.rb +1 -0
  17. data/lib/puppet/network/handler/status.rb +2 -0
  18. data/lib/puppet/network/http_server.rb +3 -0
  19. data/lib/puppet/network/http_server/mongrel.rb +129 -0
  20. data/lib/puppet/provider/exec/posix.rb +6 -3
  21. data/lib/puppet/provider/exec/shell.rb +11 -2
  22. data/lib/puppet/resource/catalog.rb +6 -3
  23. data/lib/puppet/ssl/host.rb +2 -0
  24. data/lib/puppet/type/cron.rb +13 -12
  25. data/lib/puppet/type/file.rb +2 -2
  26. data/lib/puppet/type/file/source.rb +1 -1
  27. data/lib/puppet/type/user.rb +8 -0
  28. data/lib/puppet/util.rb +16 -41
  29. data/lib/puppet/util/settings.rb +1 -1
  30. data/lib/puppet/util/suidmanager.rb +48 -14
  31. data/spec/unit/application/inspect_spec.rb +5 -0
  32. data/spec/unit/application/resource_spec.rb +25 -0
  33. data/spec/unit/configurer_spec.rb +5 -0
  34. data/spec/unit/indirector/facts/inventory_service_spec.rb +22 -0
  35. data/spec/unit/indirector/report/processor_spec.rb +7 -5
  36. data/spec/unit/resource/catalog_spec.rb +54 -7
  37. data/spec/unit/ssl/host_spec.rb +58 -9
  38. data/spec/unit/type/file_spec.rb +6 -0
  39. data/spec/unit/type/user_spec.rb +8 -0
  40. data/spec/unit/util/settings_spec.rb +11 -0
  41. data/spec/unit/util/suidmanager_spec.rb +210 -0
  42. metadata +11 -5
  43. data/test/puppet/tc_suidmanager.rb +0 -120
@@ -1190,4 +1190,10 @@ describe Puppet::Type.type(:file) do
1190
1190
  @file[:checksum].should be :md5lite
1191
1191
  end
1192
1192
  end
1193
+
1194
+ describe ".instances" do
1195
+ it 'should return an empty array' do
1196
+ Puppet::Type::File.instances.should == []
1197
+ end
1198
+ end
1193
1199
  end
@@ -290,6 +290,14 @@ describe user do
290
290
  @password.change_to_s("other", "mypass").should_not be_include("mypass")
291
291
  end
292
292
 
293
+ it "should redact the password when displaying the old value" do
294
+ @password.is_to_s("currentpassword").should =~ /^\[old password hash redacted\]$/
295
+ end
296
+
297
+ it "should redact the password when displaying the new value" do
298
+ @password.should_to_s("newpassword").should =~ /^\[new password hash redacted\]$/
299
+ end
300
+
293
301
  it "should fail if a ':' is included in the password" do
294
302
  lambda { @password.should = "some:thing" }.should raise_error(Puppet::Error)
295
303
  end
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
+ require 'ostruct'
4
5
 
5
6
  describe Puppet::Util::Settings do
6
7
  describe "when specifying defaults" do
@@ -1115,4 +1116,14 @@ describe Puppet::Util::Settings do
1115
1116
 
1116
1117
  it "should cache the result"
1117
1118
  end
1119
+
1120
+ describe "#writesub" do
1121
+ it "should only pass valid arguments to File.open" do
1122
+ settings = Puppet::Util::Settings.new
1123
+ settings.stubs(:get_config_file_default).with(:privatekeydir).returns(OpenStruct.new(:mode => "750"))
1124
+
1125
+ File.expects(:open).with("/path/to/keydir", "w", 750).returns true
1126
+ settings.writesub(:privatekeydir, "/path/to/keydir")
1127
+ end
1128
+ end
1118
1129
  end
@@ -0,0 +1,210 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Puppet::Util::SUIDManager do
6
+ let :user do
7
+ Puppet::Type.type(:user).new(:name => 'name', :uid => 42, :gid => 42)
8
+ end
9
+
10
+ let :xids do
11
+ Hash.new {|h,k| 0}
12
+ end
13
+
14
+ before :each do
15
+ Puppet::Util::SUIDManager.stubs(:convert_xid).returns(42)
16
+ Puppet::Util::SUIDManager.stubs(:initgroups)
17
+
18
+ [:euid, :egid, :uid, :gid, :groups].each do |id|
19
+ Process.stubs("#{id}=").with {|value| xids[id] = value}
20
+ end
21
+ end
22
+
23
+ describe "#uid" do
24
+ it "should allow setting euid/egid" do
25
+ Puppet::Util::SUIDManager.egid = user[:gid]
26
+ Puppet::Util::SUIDManager.euid = user[:uid]
27
+
28
+ xids[:egid].should == user[:gid]
29
+ xids[:euid].should == user[:uid]
30
+ end
31
+ end
32
+
33
+ describe "#asuser" do
34
+ it "should set euid/egid when root" do
35
+ Process.stubs(:uid).returns(0)
36
+
37
+ Process.stubs(:egid).returns(51)
38
+ Process.stubs(:euid).returns(50)
39
+
40
+ Puppet::Util::SUIDManager.stubs(:convert_xid).with(:gid, 51).returns(51)
41
+ Puppet::Util::SUIDManager.stubs(:convert_xid).with(:uid, 50).returns(50)
42
+
43
+ yielded = false
44
+ Puppet::Util::SUIDManager.asuser(user[:uid], user[:gid]) do
45
+ xids[:egid].should == user[:gid]
46
+ xids[:euid].should == user[:uid]
47
+ yielded = true
48
+ end
49
+
50
+ xids[:egid].should == 51
51
+ xids[:euid].should == 50
52
+
53
+ # It's possible asuser could simply not yield, so the assertions in the
54
+ # block wouldn't fail. So verify those actually got checked.
55
+ yielded.should be_true
56
+ end
57
+
58
+ it "should not get or set euid/egid when not root" do
59
+ Process.stubs(:uid).returns(1)
60
+
61
+ Process.stubs(:egid).returns(51)
62
+ Process.stubs(:euid).returns(50)
63
+
64
+ Puppet::Util::SUIDManager.asuser(user[:uid], user[:gid]) {}
65
+
66
+ xids.should be_empty
67
+ end
68
+ end
69
+
70
+ describe "#change_group" do
71
+ describe "when changing permanently" do
72
+ it "should try to change_privilege if it is supported" do
73
+ Process::GID.expects(:change_privilege).with do |gid|
74
+ Process.gid = gid
75
+ Process.egid = gid
76
+ end
77
+
78
+ Puppet::Util::SUIDManager.change_group(42, true)
79
+
80
+ xids[:egid].should == 42
81
+ xids[:gid].should == 42
82
+ end
83
+
84
+ it "should change both egid and gid if change_privilege isn't supported" do
85
+ Process::GID.stubs(:change_privilege).raises(NotImplementedError)
86
+
87
+ Puppet::Util::SUIDManager.change_group(42, true)
88
+
89
+ xids[:egid].should == 42
90
+ xids[:gid].should == 42
91
+ end
92
+ end
93
+
94
+ describe "when changing temporarily" do
95
+ it "should change only egid" do
96
+ Puppet::Util::SUIDManager.change_group(42, false)
97
+
98
+ xids[:egid].should == 42
99
+ xids[:gid].should == 0
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "#change_user" do
105
+ describe "when changing permanently" do
106
+ it "should try to change_privilege if it is supported" do
107
+ Process::UID.expects(:change_privilege).with do |uid|
108
+ Process.uid = uid
109
+ Process.euid = uid
110
+ end
111
+
112
+ Puppet::Util::SUIDManager.change_user(42, true)
113
+
114
+ xids[:euid].should == 42
115
+ xids[:uid].should == 42
116
+ end
117
+
118
+ it "should change euid and uid and groups if change_privilege isn't supported" do
119
+ Process::UID.stubs(:change_privilege).raises(NotImplementedError)
120
+
121
+ Puppet::Util::SUIDManager.expects(:initgroups).with(42)
122
+
123
+ Puppet::Util::SUIDManager.change_user(42, true)
124
+
125
+ xids[:euid].should == 42
126
+ xids[:uid].should == 42
127
+ end
128
+ end
129
+
130
+ describe "when changing temporarily" do
131
+ it "should change only euid and groups" do
132
+ Puppet::Util::SUIDManager.change_user(42, false)
133
+
134
+ xids[:euid].should == 42
135
+ xids[:uid].should == 0
136
+ end
137
+
138
+ it "should set euid before groups if changing to root" do
139
+ Process.stubs(:euid).returns 50
140
+
141
+ when_not_root = sequence 'when_not_root'
142
+
143
+ Process.expects(:euid=).in_sequence(when_not_root)
144
+ Puppet::Util::SUIDManager.expects(:initgroups).in_sequence(when_not_root)
145
+
146
+ Puppet::Util::SUIDManager.change_user(0, false)
147
+ end
148
+
149
+ it "should set groups before euid if changing from root" do
150
+ Process.stubs(:euid).returns 0
151
+
152
+ when_root = sequence 'when_root'
153
+
154
+ Puppet::Util::SUIDManager.expects(:initgroups).in_sequence(when_root)
155
+ Process.expects(:euid=).in_sequence(when_root)
156
+
157
+ Puppet::Util::SUIDManager.change_user(50, false)
158
+ end
159
+ end
160
+ end
161
+
162
+ describe "when running commands" do
163
+ before :each do
164
+ # We want to make sure $CHILD_STATUS is set
165
+ Kernel.system '' if $CHILD_STATUS.nil?
166
+ end
167
+
168
+ describe "with #system" do
169
+ it "should set euid/egid when root" do
170
+ Process.stubs(:uid).returns(0)
171
+ Process.stubs(:egid).returns(51)
172
+ Process.stubs(:euid).returns(50)
173
+
174
+ Puppet::Util::SUIDManager.stubs(:convert_xid).with(:gid, 51).returns(51)
175
+ Puppet::Util::SUIDManager.stubs(:convert_xid).with(:uid, 50).returns(50)
176
+
177
+ Puppet::Util::SUIDManager.expects(:change_group).with(user[:uid])
178
+ Puppet::Util::SUIDManager.expects(:change_user).with(user[:uid])
179
+
180
+ Puppet::Util::SUIDManager.expects(:change_group).with(51)
181
+ Puppet::Util::SUIDManager.expects(:change_user).with(50)
182
+
183
+ Kernel.expects(:system).with('blah')
184
+ Puppet::Util::SUIDManager.system('blah', user[:uid], user[:gid])
185
+ end
186
+
187
+ it "should not get or set euid/egid when not root" do
188
+ Process.stubs(:uid).returns(1)
189
+ Kernel.expects(:system).with('blah')
190
+
191
+ Puppet::Util::SUIDManager.system('blah', user[:uid], user[:gid])
192
+
193
+ xids.should be_empty
194
+ end
195
+ end
196
+
197
+ describe "with #run_and_capture" do
198
+ it "should capture the output and return process status" do
199
+ Puppet::Util.
200
+ expects(:execute).
201
+ with('yay', :combine => true, :failonfail => false, :uid => user[:uid], :gid => user[:gid]).
202
+ returns('output')
203
+ output = Puppet::Util::SUIDManager.run_and_capture 'yay', user[:uid], user[:gid]
204
+
205
+ output.first.should == 'output'
206
+ output.last.should be_a(Process::Status)
207
+ end
208
+ end
209
+ end
210
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 6
9
- - 12
10
- version: 2.6.12
9
+ - 13
10
+ version: 2.6.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Puppet Labs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-22 00:00:00 Z
18
+ date: 2011-12-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: facter
@@ -53,6 +53,7 @@ extra_rdoc_files: []
53
53
  files:
54
54
  - CHANGELOG
55
55
  - CHANGELOG.old
56
+ - CONTRIBUTING.md
56
57
  - COPYING
57
58
  - LICENSE
58
59
  - Rakefile
@@ -156,6 +157,7 @@ files:
156
157
  - lib/puppet/indirector/facts/couch.rb
157
158
  - lib/puppet/indirector/facts/facter.rb
158
159
  - lib/puppet/indirector/facts/inventory_active_record.rb
160
+ - lib/puppet/indirector/facts/inventory_service.rb
159
161
  - lib/puppet/indirector/facts/memory.rb
160
162
  - lib/puppet/indirector/facts/rest.rb
161
163
  - lib/puppet/indirector/facts/yaml.rb
@@ -234,6 +236,8 @@ files:
234
236
  - lib/puppet/network/http/webrick.rb
235
237
  - lib/puppet/network/http.rb
236
238
  - lib/puppet/network/http_pool.rb
239
+ - lib/puppet/network/http_server/mongrel.rb
240
+ - lib/puppet/network/http_server.rb
237
241
  - lib/puppet/network/rest_authconfig.rb
238
242
  - lib/puppet/network/rest_authorization.rb
239
243
  - lib/puppet/network/rest_controller.rb
@@ -721,6 +725,7 @@ files:
721
725
  - ext/regexp_nodes/parameters/environment/prod
722
726
  - ext/regexp_nodes/parameters/environment/qa
723
727
  - ext/regexp_nodes/regexp_nodes.rb
728
+ - ext/upload_facts.rb
724
729
  - ext/vim/ftdetect/puppet.vim
725
730
  - ext/vim/ftplugin/puppet.vim
726
731
  - ext/vim/indent/puppet.vim
@@ -869,7 +874,6 @@ files:
869
874
  - test/other/transactions.rb
870
875
  - test/puppet/defaults.rb
871
876
  - test/puppet/errortest.rb
872
- - test/puppet/tc_suidmanager.rb
873
877
  - test/rails/rails.rb
874
878
  - test/rails/railsparameter.rb
875
879
  - test/Rakefile
@@ -1052,6 +1056,7 @@ files:
1052
1056
  - spec/unit/indirector/facts/couch_spec.rb
1053
1057
  - spec/unit/indirector/facts/facter_spec.rb
1054
1058
  - spec/unit/indirector/facts/inventory_active_record_spec.rb
1059
+ - spec/unit/indirector/facts/inventory_service_spec.rb
1055
1060
  - spec/unit/indirector/facts/rest_spec.rb
1056
1061
  - spec/unit/indirector/facts/yaml_spec.rb
1057
1062
  - spec/unit/indirector/file_bucket_file/file_spec.rb
@@ -1351,6 +1356,7 @@ files:
1351
1356
  - spec/unit/util/settings/file_setting_spec.rb
1352
1357
  - spec/unit/util/settings_spec.rb
1353
1358
  - spec/unit/util/storage_spec.rb
1359
+ - spec/unit/util/suidmanager_spec.rb
1354
1360
  - spec/unit/util/tagging_spec.rb
1355
1361
  - spec/unit/util/user_attr_spec.rb
1356
1362
  - spec/unit/util/warnings_spec.rb
@@ -1,120 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.dirname(__FILE__) + '/../lib/puppettest'
4
-
5
- require 'puppet'
6
- require 'puppettest'
7
- require 'test/unit'
8
- require 'mocha'
9
-
10
- class TestSUIDManager < Test::Unit::TestCase
11
- include PuppetTest
12
-
13
- def setup
14
- the_id = 42
15
- Puppet::Util::SUIDManager.stubs(:convert_xid).returns(the_id)
16
- Puppet::Util::SUIDManager.stubs(:initgroups)
17
- @user = stub('user', :uid => the_id, :gid => the_id, :name => 'name')
18
- super
19
- end
20
-
21
- def test_metaprogramming_function_additions
22
- # NOTE: the way that we are dynamically generating the methods in
23
- # SUIDManager for the UID/GID calls was causing problems due to the
24
- # modification of a closure. Should the bug rear itself again, this
25
- # test will fail.
26
- Process.expects(:uid).times(2)
27
-
28
- assert_nothing_raised do
29
- Puppet::Util::SUIDManager.uid
30
- Puppet::Util::SUIDManager.uid
31
- end
32
- end
33
-
34
- def test_id_set
35
- Process.expects(:euid=).with(@user.uid)
36
- Process.expects(:egid=).with(@user.gid)
37
-
38
- assert_nothing_raised do
39
- Puppet::Util::SUIDManager.egid = @user.gid
40
- Puppet::Util::SUIDManager.euid = @user.uid
41
- end
42
- end
43
-
44
- def test_utiluid
45
- assert_not_equal(nil, Puppet::Util.uid(nonrootuser.name))
46
- end
47
-
48
- def test_asuser_as_root
49
- Process.stubs(:uid).returns(0)
50
- expects_id_set_and_revert @user.uid, @user.gid
51
- Puppet::Util::SUIDManager.asuser @user.uid, @user.gid do end
52
- rescue Errno::EPERM
53
- end
54
-
55
- def test_asuser_as_nonroot
56
- Process.stubs(:uid).returns(1)
57
- expects_no_id_set
58
- Puppet::Util::SUIDManager.asuser @user.uid, @user.gid do end
59
- end
60
-
61
-
62
- def test_system_as_root
63
- Process.stubs(:uid).returns(0)
64
- set_exit_status!
65
- expects_id_set_and_revert @user.uid, @user.gid
66
- Kernel.expects(:system).with('blah')
67
- Puppet::Util::SUIDManager.system('blah', @user.uid, @user.gid)
68
- end
69
-
70
- def test_system_as_nonroot
71
- Process.stubs(:uid).returns(1)
72
- set_exit_status!
73
- expects_no_id_set
74
- Kernel.expects(:system).with('blah')
75
- Puppet::Util::SUIDManager.system('blah', @user.uid, @user.gid)
76
- end
77
-
78
- def test_run_and_capture
79
- if (RUBY_VERSION <=> "1.8.4") < 0
80
- warn "Cannot run this test on ruby < 1.8.4"
81
- else
82
- set_exit_status!
83
- Puppet::Util.
84
- expects(:execute).
85
- with('yay',:combine => true, :failonfail => false, :uid => @user.uid, :gid => @user.gid).
86
- returns('output')
87
- output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid
88
-
89
- assert_equal 'output', output.first
90
- assert_kind_of Process::Status, output.last
91
- end
92
- end
93
-
94
- private
95
-
96
- def expects_id_set_and_revert(uid, gid)
97
- Process.stubs(:groups=)
98
- Process.expects(:euid).returns(99997)
99
- Process.expects(:egid).returns(99996)
100
-
101
- Process.expects(:euid=).with(uid)
102
- Process.expects(:egid=).with(gid)
103
-
104
- Process.expects(:euid=).with(99997)
105
- Process.expects(:egid=).with(99996)
106
- end
107
-
108
- def expects_no_id_set
109
- Process.expects(:egid).never
110
- Process.expects(:euid).never
111
- Process.expects(:egid=).never
112
- Process.expects(:euid=).never
113
- end
114
-
115
- def set_exit_status!
116
- # We want to make sure $CHILD_STATUS is set, this is the only way I know how.
117
- Kernel.system '' if $CHILD_STATUS.nil?
118
- end
119
- end
120
-