Skip to content

Commit

Permalink
bugfix: sudo-detection for target execution
Browse files Browse the repository at this point in the history
When running `inspec exec` without the `target` option but against remote endpoints OR when executing it with the `localhost://` target AND having `--sudo` active it would abort the execution. `--target` is a helper to set the Train parameters for `backend`, `host`, `user`, `port`, and potentially `password`. The detection would fail on providing any of these separately without specifying `--target`. The same holds true for the `localhost` train backend or just `localhost://` target.

This type of detection has since moved to Train. The driving reason was to have this very useful check for localhost vs sudo run for any type of inspec (or for that matter: train) execution.

This PR depends on inspec/train#179 and the next release of train.

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
  • Loading branch information
arlimus authored and aaronlippold committed Jun 8, 2017
1 parent 1c5ff76 commit 2f3fce0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion inspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.1'

spec.add_dependency 'train', '>=0.22.0', '<1.0'
spec.add_dependency 'train', '>=0.24.0', '<1.0'
spec.add_dependency 'thor', '~> 0.19'
spec.add_dependency 'json', '>= 1.8', '< 3.0'
spec.add_dependency 'rainbow', '~> 2'
Expand Down
7 changes: 0 additions & 7 deletions lib/inspec/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ def exec(*targets)
configure_logger(opts)
o = opts.dup

# print error if user passed --sudo but with no --target
if opts[:sudo] && opts[:target].nil?
Inspec::Log.error('--sudo is only valid when running against a remote host using --target')
Inspec::Log.error('To run InSpec locally with elevated privileges, run `sudo inspec exec ...`')
exit 1
end

# run tests
run_tests(targets, o)
rescue StandardError => e
Expand Down

0 comments on commit 2f3fce0

Please sign in to comment.