From 208fb9d9a566b7fa73c3f2892e31cee4902120ed Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 19 Oct 2015 18:56:00 +0200 Subject: [PATCH 01/12] feature: unix command with sudo handling --- lib/train/extras.rb | 9 ++-- lib/train/extras/command_wrapper.rb | 59 ++++++++++++++++++++++++ test/unit/extras/command_wrapper_test.rb | 33 +++++++++++++ 3 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 lib/train/extras/command_wrapper.rb create mode 100644 test/unit/extras/command_wrapper_test.rb diff --git a/lib/train/extras.rb b/lib/train/extras.rb index 8d77234a..d5949cd2 100644 --- a/lib/train/extras.rb +++ b/lib/train/extras.rb @@ -3,10 +3,11 @@ # Author:: Dominik Richter () module Train::Extras - autoload :FileCommon, 'train/extras/file_common' - autoload :LinuxFile, 'train/extras/linux_file' - autoload :OSCommon, 'train/extras/os_common' - autoload :Stat, 'train/extras/stat' + autoload :CommandWrapper, 'train/extras/command_wrapper' + autoload :FileCommon, 'train/extras/file_common' + autoload :LinuxFile, 'train/extras/linux_file' + autoload :OSCommon, 'train/extras/os_common' + autoload :Stat, 'train/extras/stat' CommandResult = Struct.new(:stdout, :stderr, :exit_status) LoginCommand = Struct.new(:command, :arguments) diff --git a/lib/train/extras/command_wrapper.rb b/lib/train/extras/command_wrapper.rb new file mode 100644 index 00000000..a7ff01b6 --- /dev/null +++ b/lib/train/extras/command_wrapper.rb @@ -0,0 +1,59 @@ +# encoding: utf-8 +# author: Dominik Richter +# author: Christoph Hartmann + +require 'base64' + +module Train::Extras + class LinuxCommand + Train::Options.attach(self) + + option :sudo, default: false + option :sudo_options, default: nil + option :sudo_password, default: nil + + def initialize(backend, options) + @backend = backend + validate_options(options) + + @sudo = options[:sudo] + @sudo_options = options[:sudo_options] + @sudo_password = options[:sudo_password] + @prefix = build_prefix + end + + def run(command) + @prefix + command + end + + def self.active?(options) + options.is_a?(Hash) && options[:sudo] + end + + private + + def build_prefix + return '' unless @sudo + res = 'sudo ' + + res << @sudo_options.to_s + ' ' unless @sudo_options.nil? + + unless @sudo_password.nil? + b64pw = Base64.strict_encode64(@sudo_password) + res = "echo #{b64pw} | base64 -d | " + res + end + + res + end + end + + class CommandWrapper + include_options LinuxCommand + + def self.load(transport, options) + return nil unless LinuxCommand.active?(options) + return nil unless transport.os.unix? + LinuxCommand.new(transport, options) + end + end +end diff --git a/test/unit/extras/command_wrapper_test.rb b/test/unit/extras/command_wrapper_test.rb new file mode 100644 index 00000000..f611c88c --- /dev/null +++ b/test/unit/extras/command_wrapper_test.rb @@ -0,0 +1,33 @@ +# encoding: utf-8 +require 'helper' +require 'train/transports/mock' +require 'train/extras' +require 'base64' + +describe 'linux command' do + let(:cls) { Train::Extras::LinuxCommand } + let(:cmd) { rand.to_s } + let(:backend) { + backend = Train::Transports::Mock.new.connection + backend.mock_os({ family: 'linux' }) + backend + } + + it 'wraps commands in sudo' do + lc = cls.new(backend, { sudo: true }) + lc.run(cmd).must_equal "sudo #{cmd}" + end + + it 'wraps commands in sudo with all options' do + opts = rand.to_s + lc = cls.new(backend, { sudo: true, sudo_options: opts }) + lc.run(cmd).must_equal "sudo #{opts} #{cmd}" + end + + it 'runs commands in sudo with password' do + pw = rand.to_s + lc = cls.new(backend, { sudo: true, sudo_password: pw }) + bpw = Base64.strict_encode64(pw) + lc.run(cmd).must_equal "echo #{bpw} | base64 -d | sudo #{cmd}" + end +end From ead6702ce610a6d1266a181d28d778a944269a2e Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 19 Oct 2015 20:45:36 +0200 Subject: [PATCH 02/12] add command wrapper to docker, local, and ssh --- lib/train/transports/docker.rb | 6 ++++++ lib/train/transports/local.rb | 12 +++++++++--- lib/train/transports/ssh.rb | 4 ++++ lib/train/transports/ssh_connection.rb | 6 ++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/train/transports/docker.rb b/lib/train/transports/docker.rb index 27f5fb3a..f6d44714 100644 --- a/lib/train/transports/docker.rb +++ b/lib/train/transports/docker.rb @@ -11,6 +11,9 @@ class Docker < Train.plugin(1) option :host, required: true + # add options for submodules + include_options Train::Extras::CommandWrapper + def connection(state = {}, &block) opts = merge_options(options, state || {}) validate_options(opts) @@ -60,6 +63,8 @@ def initialize(conf) @container = ::Docker::Container.get(@id) || fail("Can't find Docker container #{@id}") @files = {} + @cmd_wrapper = nil + @cmd_wrapper = CommandWrapper.load(self, @options) self end @@ -76,6 +81,7 @@ def file(path) end def run_command(cmd) + cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil? stdout, stderr, exit_status = @container.exec([ '/bin/sh', '-c', cmd ]) diff --git a/lib/train/transports/local.rb b/lib/train/transports/local.rb index a5551d90..abeef744 100644 --- a/lib/train/transports/local.rb +++ b/lib/train/transports/local.rb @@ -10,20 +10,26 @@ module Train::Transports class Local < Train.plugin(1) name 'local' + # add options for submodules + include_options Train::Extras::CommandWrapper + autoload :File, 'train/transports/local_file' autoload :OS, 'train/transports/local_os' def connection(_ = nil) - @connection ||= Connection.new + @connection ||= Connection.new(@options) end class Connection < BaseConnection - def initialize - super + def initialize(options) + super(options) @files = {} + @cmd_wrapper = nil + @cmd_wrapper = CommandWrapper.load(self, options) end def run_command(cmd) + cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil? res = Mixlib::ShellOut.new(cmd) res.run_command CommandResult.new(res.stdout, res.stderr, res.exitstatus) diff --git a/lib/train/transports/ssh.rb b/lib/train/transports/ssh.rb index dcde4f5a..6e740a61 100644 --- a/lib/train/transports/ssh.rb +++ b/lib/train/transports/ssh.rb @@ -58,6 +58,9 @@ class SSH < Train.plugin(1) opts[:compression] ? 6 : 0 end + # add options for submodules + include_options Train::Extras::CommandWrapper + # (see Base#connection) def connection(state = {}, &block) opts = merge_options(options, state || {}) @@ -126,6 +129,7 @@ def connection_options(opts) keys: opts[:key_files], password: opts[:password], forward_agent: opts[:forward_agent], + transport_options: opts, } end diff --git a/lib/train/transports/ssh_connection.rb b/lib/train/transports/ssh_connection.rb index 9eb79518..54656166 100644 --- a/lib/train/transports/ssh_connection.rb +++ b/lib/train/transports/ssh_connection.rb @@ -39,6 +39,9 @@ def initialize(options) @max_wait_until_ready = @options.delete(:max_wait_until_ready) @files = {} @session = nil + @transport_options = @options.delete(:transport_options) + @cmd_wrapper = nil + @cmd_wrapper = CommandWrapper.load(self, @options) end # (see Base::Connection#close) @@ -66,6 +69,9 @@ def run_command(cmd) logger.debug("[SSH] #{self} (#{cmd})") session.open_channel do |channel| + # wrap commands if that is configured + cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil? + channel.exec(cmd) do |_, success| abort 'Couldn\'t execute command on SSH.' unless success From 86d444f8c75054ef3370649611fb380dffd41c73 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 20 Oct 2015 04:21:26 +0200 Subject: [PATCH 03/12] dont wrap root user in sudo commands --- lib/train/extras/command_wrapper.rb | 3 +++ lib/train/transports/docker.rb | 4 +--- lib/train/transports/local.rb | 1 - lib/train/transports/ssh.rb | 6 +++--- test/unit/extras/command_wrapper_test.rb | 5 +++++ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/train/extras/command_wrapper.rb b/lib/train/extras/command_wrapper.rb index a7ff01b6..87cd8e1a 100644 --- a/lib/train/extras/command_wrapper.rb +++ b/lib/train/extras/command_wrapper.rb @@ -11,6 +11,7 @@ class LinuxCommand option :sudo, default: false option :sudo_options, default: nil option :sudo_password, default: nil + option :user def initialize(backend, options) @backend = backend @@ -19,6 +20,7 @@ def initialize(backend, options) @sudo = options[:sudo] @sudo_options = options[:sudo_options] @sudo_password = options[:sudo_password] + @user = options[:user] @prefix = build_prefix end @@ -34,6 +36,7 @@ def self.active?(options) def build_prefix return '' unless @sudo + return '' if @user == 'root' res = 'sudo ' res << @sudo_options.to_s + ' ' unless @sudo_options.nil? diff --git a/lib/train/transports/docker.rb b/lib/train/transports/docker.rb index f6d44714..b1686d08 100644 --- a/lib/train/transports/docker.rb +++ b/lib/train/transports/docker.rb @@ -9,10 +9,8 @@ module Train::Transports class Docker < Train.plugin(1) name 'docker' - option :host, required: true - - # add options for submodules include_options Train::Extras::CommandWrapper + option :host, required: true def connection(state = {}, &block) opts = merge_options(options, state || {}) diff --git a/lib/train/transports/local.rb b/lib/train/transports/local.rb index abeef744..2f8ceda4 100644 --- a/lib/train/transports/local.rb +++ b/lib/train/transports/local.rb @@ -10,7 +10,6 @@ module Train::Transports class Local < Train.plugin(1) name 'local' - # add options for submodules include_options Train::Extras::CommandWrapper autoload :File, 'train/transports/local_file' diff --git a/lib/train/transports/ssh.rb b/lib/train/transports/ssh.rb index 6e740a61..298cfa7b 100644 --- a/lib/train/transports/ssh.rb +++ b/lib/train/transports/ssh.rb @@ -37,6 +37,9 @@ class SSH < Train.plugin(1) autoload :Connection, 'train/transports/ssh_connection' + # add options for submodules + include_options Train::Extras::CommandWrapper + # common target configuration option :host, required: true option :port, default: 22, required: true @@ -58,9 +61,6 @@ class SSH < Train.plugin(1) opts[:compression] ? 6 : 0 end - # add options for submodules - include_options Train::Extras::CommandWrapper - # (see Base#connection) def connection(state = {}, &block) opts = merge_options(options, state || {}) diff --git a/test/unit/extras/command_wrapper_test.rb b/test/unit/extras/command_wrapper_test.rb index f611c88c..1b97ca2d 100644 --- a/test/unit/extras/command_wrapper_test.rb +++ b/test/unit/extras/command_wrapper_test.rb @@ -18,6 +18,11 @@ lc.run(cmd).must_equal "sudo #{cmd}" end + it 'doesnt wrap commands in sudo if user == root' do + lc = cls.new(backend, { sudo: true, user: 'root' }) + lc.run(cmd).must_equal cmd + end + it 'wraps commands in sudo with all options' do opts = rand.to_s lc = cls.new(backend, { sudo: true, sudo_options: opts }) From 0b84c59c5217c777b5cc12b3cc2fb7ec10b691cc Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 20 Oct 2015 17:53:18 +0200 Subject: [PATCH 04/12] make test backends configurable --- test/integration/docker_test_container.rb | 4 ++-- test/integration/test_local.rb | 4 ++-- test/integration/test_ssh.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/integration/docker_test_container.rb b/test/integration/docker_test_container.rb index 12bf46c3..85cde8f4 100644 --- a/test/integration/docker_test_container.rb +++ b/test/integration/docker_test_container.rb @@ -12,9 +12,9 @@ puts '' backends = {} -backends[:docker] = proc { +backends[:docker] = proc { |*args| opt = Train.target_config({ host: container_id }) - Train.create('docker', opt).connection + Train.create('docker', opt).connection(args[0]) } backends.each do |type, get_backend| diff --git a/test/integration/test_local.rb b/test/integration/test_local.rb index e7f2e110..01e40937 100644 --- a/test/integration/test_local.rb +++ b/test/integration/test_local.rb @@ -6,8 +6,8 @@ backends = {} -backends[:local] = proc { - Train.create('local', {}).connection +backends[:local] = proc { |*opts| + Train.create('local', {}).connection(opts[0]) } tests = ARGV diff --git a/test/integration/test_ssh.rb b/test/integration/test_ssh.rb index ffdc59a6..54a45240 100644 --- a/test/integration/test_ssh.rb +++ b/test/integration/test_ssh.rb @@ -10,9 +10,9 @@ 'key_files' => '/root/.ssh/id_rsa', } -backends[:ssh] = proc { +backends[:ssh] = proc { |*args| conf = Train.target_config(backend_conf) - Train.create('ssh', conf).connection + Train.create('ssh', conf).connection(args[0]) } tests = ARGV From 5f505b8370d666d75c6fd38f2874d4121564a77d Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 20 Oct 2015 19:59:52 +0200 Subject: [PATCH 05/12] add sudo to test vm setup --- test/integration/cookbooks/test/metadata.rb | 4 ++++ .../cookbooks/test/recipes/default.rb | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/integration/cookbooks/test/metadata.rb diff --git a/test/integration/cookbooks/test/metadata.rb b/test/integration/cookbooks/test/metadata.rb new file mode 100644 index 00000000..a2f69016 --- /dev/null +++ b/test/integration/cookbooks/test/metadata.rb @@ -0,0 +1,4 @@ +name 'test' +version '0.0.0' + +depends 'sudo', '~> 2.7.2' diff --git a/test/integration/cookbooks/test/recipes/default.rb b/test/integration/cookbooks/test/recipes/default.rb index 30da1873..6d68a006 100644 --- a/test/integration/cookbooks/test/recipes/default.rb +++ b/test/integration/cookbooks/test/recipes/default.rb @@ -56,6 +56,23 @@ command 'ssh -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa vagrant@localhost "echo 1"' end +# prepare a few users +%w{ nopasswd passwd nosudo }.each do |name| + user name do + password '$1$7MCNTXPI$r./jqCEoVlLlByYKSL3sZ.' + end +end + +sudo 'nopasswd' do + user 'nopasswd' + nopasswd true +end + +sudo 'passwd' do + user 'passwd' + nopasswd false +end + # execute tests execute 'bundle install' do command '/opt/chef/embedded/bin/bundle install' From 97519abb89b91dd027c624180a66ffe83b0932c9 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 20 Oct 2015 20:18:02 +0200 Subject: [PATCH 06/12] use berkshelf for test cookbook resolution Signed-off-by: Dominik Richter --- test/integration/.kitchen.yml | 1 + test/integration/Berksfile | 3 +++ test/integration/cookbooks/test/metadata.rb | 3 --- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 test/integration/Berksfile diff --git a/test/integration/.kitchen.yml b/test/integration/.kitchen.yml index e486781d..2ad5640b 100644 --- a/test/integration/.kitchen.yml +++ b/test/integration/.kitchen.yml @@ -35,5 +35,6 @@ platforms: suites: - name: default run_list: + - recipe[sudo] - recipe[test] attributes: diff --git a/test/integration/Berksfile b/test/integration/Berksfile new file mode 100644 index 00000000..7ad64b06 --- /dev/null +++ b/test/integration/Berksfile @@ -0,0 +1,3 @@ +source 'https://supermarket.chef.io' +cookbook 'sudo', '~> 2.7.2' +cookbook 'test', path: 'cookbooks/test' diff --git a/test/integration/cookbooks/test/metadata.rb b/test/integration/cookbooks/test/metadata.rb index a2f69016..e7a82d6d 100644 --- a/test/integration/cookbooks/test/metadata.rb +++ b/test/integration/cookbooks/test/metadata.rb @@ -1,4 +1 @@ name 'test' -version '0.0.0' - -depends 'sudo', '~> 2.7.2' From 7ad6910be0f55d2d577f5f3aafbea6f7b04028e3 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 20 Oct 2015 21:36:21 +0200 Subject: [PATCH 07/12] ensure sudo includes sudoers.d and vagrant Signed-off-by: Dominik Richter --- test/integration/.kitchen.yml | 3 +++ test/integration/cookbooks/test/recipes/default.rb | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/integration/.kitchen.yml b/test/integration/.kitchen.yml index 2ad5640b..101295bf 100644 --- a/test/integration/.kitchen.yml +++ b/test/integration/.kitchen.yml @@ -38,3 +38,6 @@ suites: - recipe[sudo] - recipe[test] attributes: + authorization: + sudo: + include_sudoers_d: true diff --git a/test/integration/cookbooks/test/recipes/default.rb b/test/integration/cookbooks/test/recipes/default.rb index 6d68a006..ae36820f 100644 --- a/test/integration/cookbooks/test/recipes/default.rb +++ b/test/integration/cookbooks/test/recipes/default.rb @@ -60,12 +60,15 @@ %w{ nopasswd passwd nosudo }.each do |name| user name do password '$1$7MCNTXPI$r./jqCEoVlLlByYKSL3sZ.' + manage_home true end end -sudo 'nopasswd' do - user 'nopasswd' - nopasswd true +%w{nopasswd vagrant}.each do |name| + sudo name do + user '%'+name + nopasswd true + end end sudo 'passwd' do From de84754a23974758ca79b8cb7d71c54af7f67fe6 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 20 Oct 2015 22:18:11 +0200 Subject: [PATCH 08/12] add sudo tests for passwd and nopasswd --- .../cookbooks/test/recipes/default.rb | 8 ++++++++ test/integration/sudo/nopasswd.rb | 15 ++++++++++++++ test/integration/sudo/passwd.rb | 20 +++++++++++++++++++ test/integration/sudo/run_as.rb | 11 ++++++++++ 4 files changed, 54 insertions(+) create mode 100644 test/integration/sudo/nopasswd.rb create mode 100644 test/integration/sudo/passwd.rb create mode 100644 test/integration/sudo/run_as.rb diff --git a/test/integration/cookbooks/test/recipes/default.rb b/test/integration/cookbooks/test/recipes/default.rb index ae36820f..8db3dcb1 100644 --- a/test/integration/cookbooks/test/recipes/default.rb +++ b/test/integration/cookbooks/test/recipes/default.rb @@ -91,3 +91,11 @@ command '/opt/chef/embedded/bin/ruby -I lib test/integration/test_ssh.rb test/integration/tests/*_test.rb' cwd '/tmp/kitchen/data' end + +%w{passwd nopasswd}.each do |name| + execute "run local sudo tests as #{name}" do + command "/opt/chef/embedded/bin/ruby -I lib test/integration/sudo/#{name}.rb" + cwd '/tmp/kitchen/data' + user name + end +end diff --git a/test/integration/sudo/nopasswd.rb b/test/integration/sudo/nopasswd.rb new file mode 100644 index 00000000..ec0ce188 --- /dev/null +++ b/test/integration/sudo/nopasswd.rb @@ -0,0 +1,15 @@ +# encoding: utf-8 +# author: Dominik Richter + +require_relative 'run_as' + +describe 'run_command' do + it 'is running as non-root without sudo' do + run_as('whoami').stdout.wont_match /root/i + end + + it 'is running nopasswd sudo' do + run_as('whoami', { sudo: true }) + .stdout.must_match /root/i + end +end diff --git a/test/integration/sudo/passwd.rb b/test/integration/sudo/passwd.rb new file mode 100644 index 00000000..1b2f50a2 --- /dev/null +++ b/test/integration/sudo/passwd.rb @@ -0,0 +1,20 @@ +# encoding: utf-8 +# author: Dominik Richter + +require_relative 'run_as' + +describe 'run_command' do + it 'is running as non-root without sudo' do + run_as('whoami').stdout.wont_match /root/i + end + + it 'is not running sudo without password' do + run_as('whoami', { sudo: true }) + .exit_status.wont_equal 0 + end + + it 'is running passwd sudo' do + run_as('whoami', { sudo: true, sudo_password: 'password' }) + .stdout.must_match /root/i + end +end diff --git a/test/integration/sudo/run_as.rb b/test/integration/sudo/run_as.rb new file mode 100644 index 00000000..757f6a9d --- /dev/null +++ b/test/integration/sudo/run_as.rb @@ -0,0 +1,11 @@ +# encoding: utf-8 +# author: Dominik Richter + +require_relative '../helper' +require 'train' + +def run_as(cmd, opts = {}) + Train.create('local', opts) + .connection + .run_command(cmd) +end From 83fc857ce4f7f5776d0bc1f595caae4d4570f172 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 20 Oct 2015 22:21:35 +0200 Subject: [PATCH 09/12] bugfix: sudo + password without pty --- lib/train/extras/command_wrapper.rb | 9 +++++---- test/unit/extras/command_wrapper_test.rb | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/train/extras/command_wrapper.rb b/lib/train/extras/command_wrapper.rb index 87cd8e1a..9a99ab4c 100644 --- a/lib/train/extras/command_wrapper.rb +++ b/lib/train/extras/command_wrapper.rb @@ -37,15 +37,16 @@ def self.active?(options) def build_prefix return '' unless @sudo return '' if @user == 'root' - res = 'sudo ' - res << @sudo_options.to_s + ' ' unless @sudo_options.nil? + res = 'sudo ' unless @sudo_password.nil? - b64pw = Base64.strict_encode64(@sudo_password) - res = "echo #{b64pw} | base64 -d | " + res + b64pw = Base64.strict_encode64(@sudo_password + "\n") + res = "echo #{b64pw} | base64 -d | sudo -S " end + res << @sudo_options.to_s + ' ' unless @sudo_options.nil? + res end end diff --git a/test/unit/extras/command_wrapper_test.rb b/test/unit/extras/command_wrapper_test.rb index 1b97ca2d..ba7067e1 100644 --- a/test/unit/extras/command_wrapper_test.rb +++ b/test/unit/extras/command_wrapper_test.rb @@ -32,7 +32,7 @@ it 'runs commands in sudo with password' do pw = rand.to_s lc = cls.new(backend, { sudo: true, sudo_password: pw }) - bpw = Base64.strict_encode64(pw) - lc.run(cmd).must_equal "echo #{bpw} | base64 -d | sudo #{cmd}" + bpw = Base64.strict_encode64(pw + "\n") + lc.run(cmd).must_equal "echo #{bpw} | base64 -d | sudo -S #{cmd}" end end From ba915da6dfa01427e529e39a386eb72eb8eeea2f Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 21 Oct 2015 16:57:57 +0200 Subject: [PATCH 10/12] use transport options for command wrapper ssh --- lib/train/transports/ssh_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/train/transports/ssh_connection.rb b/lib/train/transports/ssh_connection.rb index 54656166..16bd5eb8 100644 --- a/lib/train/transports/ssh_connection.rb +++ b/lib/train/transports/ssh_connection.rb @@ -41,7 +41,7 @@ def initialize(options) @session = nil @transport_options = @options.delete(:transport_options) @cmd_wrapper = nil - @cmd_wrapper = CommandWrapper.load(self, @options) + @cmd_wrapper = CommandWrapper.load(self, @transport_options) end # (see Base::Connection#close) From 26935e8e432a6c3471d66da4907e260fb4916f1f Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 21 Oct 2015 16:59:04 +0200 Subject: [PATCH 11/12] fix indentation --- test/integration/cookbooks/test/recipes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/cookbooks/test/recipes/default.rb b/test/integration/cookbooks/test/recipes/default.rb index 8db3dcb1..1e2cff84 100644 --- a/test/integration/cookbooks/test/recipes/default.rb +++ b/test/integration/cookbooks/test/recipes/default.rb @@ -73,7 +73,7 @@ sudo 'passwd' do user 'passwd' - nopasswd false + nopasswd false end # execute tests From 9a37ca0c5de429e1ecb1162b4e0482d5f76d1b70 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 21 Oct 2015 16:59:58 +0200 Subject: [PATCH 12/12] fix file headers --- test/integration/sudo/nopasswd.rb | 1 + test/integration/sudo/passwd.rb | 1 + test/integration/sudo/run_as.rb | 1 + test/unit/extras/command_wrapper_test.rb | 3 +++ 4 files changed, 6 insertions(+) diff --git a/test/integration/sudo/nopasswd.rb b/test/integration/sudo/nopasswd.rb index ec0ce188..12e9df5e 100644 --- a/test/integration/sudo/nopasswd.rb +++ b/test/integration/sudo/nopasswd.rb @@ -1,5 +1,6 @@ # encoding: utf-8 # author: Dominik Richter +# author: Christoph Hartmann require_relative 'run_as' diff --git a/test/integration/sudo/passwd.rb b/test/integration/sudo/passwd.rb index 1b2f50a2..f2c89fc5 100644 --- a/test/integration/sudo/passwd.rb +++ b/test/integration/sudo/passwd.rb @@ -1,5 +1,6 @@ # encoding: utf-8 # author: Dominik Richter +# author: Christoph Hartmann require_relative 'run_as' diff --git a/test/integration/sudo/run_as.rb b/test/integration/sudo/run_as.rb index 757f6a9d..ec7554fa 100644 --- a/test/integration/sudo/run_as.rb +++ b/test/integration/sudo/run_as.rb @@ -1,5 +1,6 @@ # encoding: utf-8 # author: Dominik Richter +# author: Christoph Hartmann require_relative '../helper' require 'train' diff --git a/test/unit/extras/command_wrapper_test.rb b/test/unit/extras/command_wrapper_test.rb index ba7067e1..accf0481 100644 --- a/test/unit/extras/command_wrapper_test.rb +++ b/test/unit/extras/command_wrapper_test.rb @@ -1,4 +1,7 @@ # encoding: utf-8 +# author: Dominik Richter +# author: Christoph Hartmann + require 'helper' require 'train/transports/mock' require 'train/extras'