boxgrinder-build 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/CHANGELOG +11 -0
  2. data/Manifest +6 -7
  3. data/Rakefile +11 -6
  4. data/bash_completion +37 -0
  5. data/bin/boxgrinder-build +20 -5
  6. data/boxgrinder-build.gemspec +4 -4
  7. data/lib/boxgrinder-build.rb +2 -1
  8. data/lib/boxgrinder-build/appliance.rb +26 -24
  9. data/lib/boxgrinder-build/helpers/augeas-helper.rb +1 -1
  10. data/lib/boxgrinder-build/helpers/ec2-helper.rb +2 -2
  11. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +1 -1
  12. data/lib/boxgrinder-build/helpers/s3-helper.rb +2 -2
  13. data/lib/boxgrinder-build/managers/plugin-manager.rb +1 -1
  14. data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +1 -1
  15. data/lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb +2 -2
  16. data/lib/boxgrinder-build/plugins/delivery/openstack/openstack-plugin.rb +3 -3
  17. data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +16 -10
  18. data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +1 -1
  19. data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +1 -1
  20. data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +1 -1
  21. data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +5 -1
  22. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +8 -3
  23. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb +1 -1
  24. data/lib/boxgrinder-build/plugins/os/sl/sl-plugin.rb +1 -1
  25. data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +1 -1
  26. data/lib/boxgrinder-build/util/concurrent/get_set.rb +46 -0
  27. data/lib/boxgrinder-build/util/permissions/fs-monitor.rb +182 -0
  28. data/lib/boxgrinder-build/util/permissions/fs-observer.rb +82 -0
  29. data/lib/boxgrinder-build/util/permissions/user-switcher.rb +42 -0
  30. data/rubygem-boxgrinder-build.spec +25 -3
  31. data/spec/appliance-spec.rb +69 -82
  32. data/spec/helpers/augeas-helper-spec.rb +0 -2
  33. data/spec/helpers/guestfs-helper-spec.rb +1 -3
  34. data/spec/helpers/image-helper-spec.rb +0 -2
  35. data/spec/helpers/linux-helper-spec.rb +0 -2
  36. data/spec/helpers/package-helper-spec.rb +0 -2
  37. data/spec/helpers/plugin-helper-spec.rb +0 -2
  38. data/spec/helpers/s3-helper-spec.rb +0 -2
  39. data/spec/managers/plugin-manager-spec.rb +0 -2
  40. data/spec/plugins/base-plugin-spec.rb +0 -2
  41. data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +0 -2
  42. data/spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb +3 -5
  43. data/spec/plugins/delivery/libvirt/libvirt-plugin-spec.rb +19 -17
  44. data/spec/plugins/delivery/local/local-plugin-spec.rb +0 -2
  45. data/spec/plugins/delivery/s3/s3-plugin-spec.rb +6 -8
  46. data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +0 -2
  47. data/spec/plugins/os/centos/centos-plugin-spec.rb +0 -2
  48. data/spec/plugins/os/fedora/fedora-plugin-spec.rb +0 -2
  49. data/spec/plugins/os/rhel/rhel-plugin-spec.rb +0 -2
  50. data/spec/plugins/os/rpm-based/kickstart-spec.rb +0 -2
  51. data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +16 -4
  52. data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +0 -2
  53. data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +0 -2
  54. data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +1 -3
  55. data/spec/plugins/platform/virtualpc/virtualpc-plugin-spec.rb +0 -1
  56. data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +25 -24
  57. data/spec/rcov_helper.rb +2 -0
  58. data/spec/spec_helper.rb +9 -0
  59. data/spec/util/concurrent/get-set-spec.rb +43 -0
  60. data/spec/util/permissions/fs-monitor-spec.rb +233 -0
  61. data/spec/util/permissions/fs-observer-spec.rb +141 -0
  62. data/spec/util/permissions/user-switcher-spec.rb +69 -0
  63. metadata +20 -5
@@ -0,0 +1,141 @@
1
+ #
2
+ # Copyright 2012 Red Hat, Inc.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU Lesser General Public License as
6
+ # published by the Free Software Foundation; either version 3 of
7
+ # the License, or (at your option) any later version.
8
+ #
9
+ # This software is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this software; if not, write to the Free
16
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
+
19
+ require 'boxgrinder-build/util/permissions/fs-observer'
20
+
21
+ module BoxGrinder
22
+ describe FSObserver do
23
+ let(:empty_set){ Set.new }
24
+ let(:init_filterset){ Set.new([%r(^/(etc|dev|sys|bin|sbin|etc|lib|lib64|boot|run|proc|selinux|tmp)(/|$))]) }
25
+
26
+ before(:each) do
27
+ @fs_observer = FSObserver.new('some-usr', 'some-grp')
28
+ end
29
+
30
+ subject{ @fs_observer }
31
+
32
+ its(:path_set){ should be_empty }
33
+ its(:filter_set){ should eq init_filterset }
34
+
35
+ context "#initialize" do
36
+ it "should merge extra :path" do
37
+ fso = FSObserver.new('j', 'u', :paths => '/a/b/c')
38
+ fso.path_set.should eql(mkset('/a/b/c'))
39
+ end
40
+
41
+ it "should merge extra :path array" do
42
+ fso = FSObserver.new('i', 'c', :paths => ['a/b/c', '/d/e/f'])
43
+ fso.path_set.should eql(mkset('a/b/c', '/d/e/f'))
44
+ end
45
+ end
46
+
47
+ context "#update" do
48
+ context ":command=:add_path" do
49
+ let(:simple_update) do
50
+ path_update(subject, '/the/great/escape')
51
+ end
52
+
53
+ it "should add the path to the path_set", :if => RSpec::Expectations::Version::STRING >= "2.7.0" do
54
+ expect{ simple_update }.to change(subject, :path_set).
55
+ from(empty_set).to(mkset('/the/great/escape'))
56
+ end
57
+
58
+ it "should add regex for all children of new path to the filter_set", :if => RSpec::Expectations::Version::STRING >= "2.7.0" do
59
+ expect_set = init_filterset + mkset(%r[^/the/great/escape/])
60
+
61
+ expect{ simple_update }.to change(subject, :filter_set).
62
+ from(init_filterset).to(expect_set)
63
+ end
64
+
65
+ context "rejecting blacklisted and filtered paths" do
66
+ before(:each) do
67
+ simple_update
68
+ end
69
+
70
+ it "should not add a path if it is a duplicate" do
71
+ expect{ simple_update }.to_not change(subject, :path_set)
72
+
73
+ expect{ simple_update }.to_not change(subject, :filter_set)
74
+ end
75
+
76
+ it "should not add a path if it is pre-filtered" do
77
+ expect{ path_update(subject, "/etc/sneaky/file") }.
78
+ to_not change(subject, :path_set)
79
+
80
+ expect{ path_update(subject, "/etc/sneaky/file") }.
81
+ to_not change(subject, :filter_set)
82
+ end
83
+
84
+ it "should not add a new path if it is a child of existing path" do
85
+ expect{ path_update(subject, "/the/great/escape/900") }.
86
+ to_not change(subject, :path_set)
87
+
88
+ expect{ path_update(subject, "/the/great/escape/900") }.
89
+ to_not change(subject, :filter_set)
90
+ end
91
+ end
92
+ end
93
+
94
+ context ":command=:stop_capture and :command=:chown" do
95
+ let(:update_a){ path_update(subject, '/a/path') }
96
+ let(:update_b){ path_update(subject, '/b/path') }
97
+
98
+ before(:each) do
99
+ update_a
100
+ update_b
101
+ end
102
+
103
+ context "all files exist" do
104
+ before(:each){ File.stub(:exist?).and_return(true) }
105
+
106
+ it "should change ownership of captured paths" do
107
+ subject.stub(:change_user)
108
+
109
+ FileUtils.should_receive(:chown_R).
110
+ with('some-usr', 'some-grp', '/a/path', :force => true).once
111
+
112
+ FileUtils.should_receive(:chown_R).
113
+ with('some-usr', 'some-grp', '/b/path', :force => true).once
114
+
115
+ subject.update({ :command => :stop_capture })
116
+ end
117
+ end
118
+
119
+ it "should ignore any paths that no longer exist" do
120
+ subject.stub(:change_user)
121
+
122
+ File.stub(:exist?).and_return(false)
123
+
124
+ FileUtils.should_not_receive(:chown_R)
125
+
126
+ update_a
127
+
128
+ subject.update({ :command => :stop_capture })
129
+ end
130
+ end
131
+ end
132
+
133
+ def path_update(subject, path)
134
+ subject.update({ :command => :add_path, :data => path })
135
+ end
136
+
137
+ def mkset(*vars)
138
+ Set.new(Array(vars))
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,69 @@
1
+ #
2
+ # Copyright 2012 Red Hat, Inc.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU Lesser General Public License as
6
+ # published by the Free Software Foundation; either version 3 of
7
+ # the License, or (at your option) any later version.
8
+ #
9
+ # This software is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this software; if not, write to the Free
16
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
+
19
+ require 'boxgrinder-build/util/permissions/user-switcher'
20
+
21
+ module BoxGrinder
22
+ describe UserSwitcher do
23
+ context "#change_user" do
24
+
25
+ before(:each) do
26
+ FileUtils.stub(:rm_rf)
27
+ end
28
+
29
+ it "should change from the current user to specified, then revert after the block" do
30
+ Process.stub(:uid).and_return(1, 1, 2)
31
+ Process.stub(:gid).and_return(3, 3, 4)
32
+
33
+ # First switch
34
+ Process.should_receive(:uid=).with(2)
35
+ Process.should_receive(:euid=).with(2)
36
+ Process.should_receive(:gid=).with(4)
37
+ Process.should_receive(:egid=).with(4)
38
+
39
+
40
+ # Change back
41
+ Process.should_receive(:uid=).with(1)
42
+ Process.should_receive(:euid=).with(1)
43
+ Process.should_receive(:gid=).with(3)
44
+ Process.should_receive(:egid=).with(3)
45
+
46
+ UserSwitcher.change_user(2, 4){}
47
+ end
48
+
49
+ it "should not change user if the uid and gid already match" do
50
+ Process.stub(:uid).and_return(1)
51
+ Process.stub(:gid).and_return(2)
52
+
53
+ Process.should_not_receive(:uid=)
54
+ Process.should_not_receive(:euid=)
55
+ Process.should_not_receive(:gid=)
56
+ Process.should_not_receive(:egid=)
57
+
58
+ UserSwitcher.change_user(1, 2){}
59
+ end
60
+ end
61
+
62
+ def stub_process_ids(u, g, eu=u, eg=g)
63
+ Process.stub(:uid => u)
64
+ Process.stub(:gid => g)
65
+ Process.stub(:euid => eu)
66
+ Process.stub(:egid => eg)
67
+ end
68
+ end
69
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxgrinder-build
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
- - 0
10
- version: 0.10.0
9
+ - 1
10
+ version: 0.10.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marek Goldmann
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-19 00:00:00 Z
18
+ date: 2012-03-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: boxgrinder-core
@@ -192,13 +192,19 @@ extra_rdoc_files:
192
192
  - lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk
193
193
  - lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx
194
194
  - lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb
195
+ - lib/boxgrinder-build/util/concurrent/get_set.rb
196
+ - lib/boxgrinder-build/util/permissions/fs-monitor.rb
197
+ - lib/boxgrinder-build/util/permissions/fs-observer.rb
198
+ - lib/boxgrinder-build/util/permissions/user-switcher.rb
195
199
  files:
196
200
  - CHANGELOG
197
201
  - LICENSE
198
202
  - Manifest
199
203
  - README.md
200
204
  - Rakefile
205
+ - bash_completion
201
206
  - bin/boxgrinder-build
207
+ - boxgrinder-build.gemspec
202
208
  - integ/appliances/gnome-fedora.appl
203
209
  - integ/appliances/jeos-centos5-files.appl
204
210
  - integ/appliances/jeos-centos5.appl
@@ -272,6 +278,10 @@ files:
272
278
  - lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk
273
279
  - lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx
274
280
  - lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb
281
+ - lib/boxgrinder-build/util/concurrent/get_set.rb
282
+ - lib/boxgrinder-build/util/permissions/fs-monitor.rb
283
+ - lib/boxgrinder-build/util/permissions/fs-observer.rb
284
+ - lib/boxgrinder-build/util/permissions/user-switcher.rb
275
285
  - rubygem-boxgrinder-build.spec
276
286
  - spec/appliance-spec.rb
277
287
  - spec/helpers/augeas-helper-spec.rb
@@ -309,8 +319,13 @@ files:
309
319
  - spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb
310
320
  - spec/plugins/platform/virtualpc/virtualpc-plugin-spec.rb
311
321
  - spec/plugins/platform/vmware/vmware-plugin-spec.rb
322
+ - spec/rcov_helper.rb
312
323
  - spec/rspec-plugin-helper.rb
313
- - boxgrinder-build.gemspec
324
+ - spec/spec_helper.rb
325
+ - spec/util/concurrent/get-set-spec.rb
326
+ - spec/util/permissions/fs-monitor-spec.rb
327
+ - spec/util/permissions/fs-observer-spec.rb
328
+ - spec/util/permissions/user-switcher-spec.rb
314
329
  homepage: http://boxgrinder.org/
315
330
  licenses: []
316
331