r-train 0.11.4 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -2
- data/lib/train/extras/command_wrapper.rb +4 -2
- data/lib/train/version.rb +1 -1
- data/test/integration/cookbooks/test/recipes/default.rb +9 -3
- data/test/integration/cookbooks/test/recipes/prep_files.rb +8 -1
- data/test/integration/sudo/customcommand.rb +15 -0
- data/test/unit/extras/command_wrapper_test.rb +21 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f599a09f2898092c2acb8062296eddde686a362
|
4
|
+
data.tar.gz: b1a3d340d9e4d62b3095ff5194f9b566fb117d08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ed0ba89f1c1533b4f6ed4535170c734f6e96355f267463a9080a07ae9a4716ccf08bd3b3b1e2c997c8c43486f22aee54427402081ba4ffbcaa3ef1162556846
|
7
|
+
data.tar.gz: 7f631bab01ea0c2fe9e278633eab0cab75a21c92a38eab6c160e09b3084d01f34d7f48055a8bbb2625eb18078ca7a2edb39ec446d9c637ba6f147d46645f4092
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.
|
4
|
-
[Full Changelog](https://github.com/chef/train/compare/v0.11.
|
3
|
+
## [0.12.0](https://github.com/chef/train/tree/0.12.0) (2016-05-16)
|
4
|
+
[Full Changelog](https://github.com/chef/train/compare/v0.11.4...0.12.0)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- Custom sudo command [\#107](https://github.com/chef/train/pull/107) ([jeremymv2](https://github.com/jeremymv2))
|
9
|
+
|
10
|
+
## [v0.11.4](https://github.com/chef/train/tree/v0.11.4) (2016-05-13)
|
11
|
+
[Full Changelog](https://github.com/chef/train/compare/v0.11.3...v0.11.4)
|
5
12
|
|
6
13
|
**Fixed bugs:**
|
7
14
|
|
@@ -9,6 +16,10 @@
|
|
9
16
|
- Add a space to avoid matching partial paths [\#104](https://github.com/chef/train/pull/104) ([alexpop](https://github.com/alexpop))
|
10
17
|
- Update README.md [\#102](https://github.com/chef/train/pull/102) ([mcquin](https://github.com/mcquin))
|
11
18
|
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- 0.11.4 [\#106](https://github.com/chef/train/pull/106) ([arlimus](https://github.com/arlimus))
|
22
|
+
|
12
23
|
## [v0.11.3](https://github.com/chef/train/tree/v0.11.3) (2016-05-10)
|
13
24
|
[Full Changelog](https://github.com/chef/train/compare/v0.11.2...v0.11.3)
|
14
25
|
|
@@ -32,6 +32,7 @@ module Train::Extras
|
|
32
32
|
option :sudo, default: false
|
33
33
|
option :sudo_options, default: nil
|
34
34
|
option :sudo_password, default: nil
|
35
|
+
option :sudo_command, default: nil
|
35
36
|
option :user
|
36
37
|
|
37
38
|
def initialize(backend, options)
|
@@ -41,6 +42,7 @@ module Train::Extras
|
|
41
42
|
@sudo = options[:sudo]
|
42
43
|
@sudo_options = options[:sudo_options]
|
43
44
|
@sudo_password = options[:sudo_password]
|
45
|
+
@sudo_command = options[:sudo_command]
|
44
46
|
@user = options[:user]
|
45
47
|
@prefix = build_prefix
|
46
48
|
end
|
@@ -83,11 +85,11 @@ module Train::Extras
|
|
83
85
|
return '' unless @sudo
|
84
86
|
return '' if @user == 'root'
|
85
87
|
|
86
|
-
res = 'sudo '
|
88
|
+
res = (@sudo_command || 'sudo') + ' '
|
87
89
|
|
88
90
|
unless @sudo_password.nil?
|
89
91
|
b64pw = Base64.strict_encode64(@sudo_password + "\n")
|
90
|
-
res = "echo #{b64pw} | base64 -d |
|
92
|
+
res = "echo #{b64pw} | base64 -d | #{res}-S "
|
91
93
|
end
|
92
94
|
|
93
95
|
res << @sudo_options.to_s + ' ' unless @sudo_options.nil?
|
data/lib/train/version.rb
CHANGED
@@ -26,7 +26,7 @@ execute 'test ssh connection' do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# prepare a few users
|
29
|
-
%w{ nopasswd passwd nosudo reqtty }.each do |name|
|
29
|
+
%w{ nopasswd passwd nosudo reqtty customcommand }.each do |name|
|
30
30
|
user name do
|
31
31
|
password '$1$7MCNTXPI$r./jqCEoVlLlByYKSL3sZ.'
|
32
32
|
manage_home true
|
@@ -53,6 +53,12 @@ sudo 'reqtty' do
|
|
53
53
|
defaults ['requiretty']
|
54
54
|
end
|
55
55
|
|
56
|
+
sudo 'customcommand' do
|
57
|
+
user 'customcommand'
|
58
|
+
nopasswd true
|
59
|
+
defaults ['!requiretty']
|
60
|
+
end
|
61
|
+
|
56
62
|
# execute tests
|
57
63
|
execute 'bundle install' do
|
58
64
|
command '/opt/chef/embedded/bin/bundle install --without integration tools'
|
@@ -69,7 +75,7 @@ execute 'run ssh tests' do
|
|
69
75
|
cwd '/tmp/kitchen/data'
|
70
76
|
end
|
71
77
|
|
72
|
-
%w{passwd nopasswd reqtty}.each do |name|
|
78
|
+
%w{passwd nopasswd reqtty customcommand}.each do |name|
|
73
79
|
execute "run local sudo tests as #{name}" do
|
74
80
|
command "/opt/chef/embedded/bin/ruby -I lib test/integration/sudo/#{name}.rb"
|
75
81
|
cwd '/tmp/kitchen/data'
|
@@ -87,7 +93,7 @@ execute 'fix sudoers for reqtty' do
|
|
87
93
|
end
|
88
94
|
|
89
95
|
# if it's fixed, it should behave like user 'nopasswd'
|
90
|
-
execute
|
96
|
+
execute 'run local sudo tests as reqtty, no longer requiring a tty' do
|
91
97
|
command "/opt/chef/embedded/bin/ruby -I lib test/integration/sudo/nopasswd.rb"
|
92
98
|
cwd '/tmp/kitchen/data'
|
93
99
|
user 'reqtty'
|
@@ -22,13 +22,20 @@ directory '/tmp/folder' do
|
|
22
22
|
group gid
|
23
23
|
end
|
24
24
|
|
25
|
-
link '/tmp/symlink'do
|
25
|
+
link '/tmp/symlink' do
|
26
26
|
to '/tmp/file'
|
27
27
|
owner 'root'
|
28
28
|
group gid
|
29
29
|
mode '0777'
|
30
30
|
end
|
31
31
|
|
32
|
+
link '/usr/bin/allyourbase' do
|
33
|
+
to '/usr/bin/sudo'
|
34
|
+
owner 'root'
|
35
|
+
group gid
|
36
|
+
mode '0777'
|
37
|
+
end
|
38
|
+
|
32
39
|
execute 'create pipe/fifo' do
|
33
40
|
command 'mkfifo /tmp/pipe'
|
34
41
|
not_if 'test -e /tmp/pipe'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Jeremy Miller
|
3
|
+
|
4
|
+
require_relative 'run_as'
|
5
|
+
|
6
|
+
describe 'run custom sudo command' do
|
7
|
+
it 'is running as non-root without sudo' do
|
8
|
+
run_as('whoami').stdout.wont_match(/root/i)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'is running nopasswd custom sudo command' do
|
12
|
+
run_as('whoami', { sudo: true, sudo_command: 'allyourbase' })
|
13
|
+
.stdout.must_match(/root/i)
|
14
|
+
end
|
15
|
+
end
|
@@ -38,6 +38,27 @@ describe 'linux command' do
|
|
38
38
|
bpw = Base64.strict_encode64(pw + "\n")
|
39
39
|
lc.run(cmd).must_equal "echo #{bpw} | base64 -d | sudo -S #{cmd}"
|
40
40
|
end
|
41
|
+
|
42
|
+
it 'wraps commands in sudo_command instead of sudo' do
|
43
|
+
sudo_command = rand.to_s
|
44
|
+
lc = cls.new(backend, { sudo: true, sudo_command: sudo_command })
|
45
|
+
lc.run(cmd).must_equal "#{sudo_command} #{cmd}"
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'wraps commands in sudo_command with all options' do
|
49
|
+
opts = rand.to_s
|
50
|
+
sudo_command = rand.to_s
|
51
|
+
lc = cls.new(backend, { sudo: true, sudo_command: sudo_command, sudo_options: opts })
|
52
|
+
lc.run(cmd).must_equal "#{sudo_command} #{opts} #{cmd}"
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'runs commands in sudo_command with password' do
|
56
|
+
pw = rand.to_s
|
57
|
+
sudo_command = rand.to_s
|
58
|
+
lc = cls.new(backend, { sudo: true, sudo_command: sudo_command, sudo_password: pw })
|
59
|
+
bpw = Base64.strict_encode64(pw + "\n")
|
60
|
+
lc.run(cmd).must_equal "echo #{bpw} | base64 -d | #{sudo_command} -S #{cmd}"
|
61
|
+
end
|
41
62
|
end
|
42
63
|
|
43
64
|
describe 'powershell command' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r-train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- test/integration/docker_test.rb
|
183
183
|
- test/integration/docker_test_container.rb
|
184
184
|
- test/integration/helper.rb
|
185
|
+
- test/integration/sudo/customcommand.rb
|
185
186
|
- test/integration/sudo/nopasswd.rb
|
186
187
|
- test/integration/sudo/passwd.rb
|
187
188
|
- test/integration/sudo/reqtty.rb
|
@@ -239,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
240
|
version: '0'
|
240
241
|
requirements: []
|
241
242
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.
|
243
|
+
rubygems_version: 2.4.6
|
243
244
|
signing_key:
|
244
245
|
specification_version: 4
|
245
246
|
summary: Transport interface to talk to different backends.
|
@@ -255,6 +256,7 @@ test_files:
|
|
255
256
|
- test/integration/docker_test.rb
|
256
257
|
- test/integration/docker_test_container.rb
|
257
258
|
- test/integration/helper.rb
|
259
|
+
- test/integration/sudo/customcommand.rb
|
258
260
|
- test/integration/sudo/nopasswd.rb
|
259
261
|
- test/integration/sudo/passwd.rb
|
260
262
|
- test/integration/sudo/reqtty.rb
|