train-core 3.2.27 → 3.3.6
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.
- checksums.yaml +4 -4
- data/lib/train/extras/command_wrapper.rb +4 -4
- data/lib/train/file/remote/unix.rb +8 -2
- data/lib/train/platforms/detect/helpers/os_common.rb +13 -5
- data/lib/train/platforms/detect/specifications/os.rb +2 -1
- data/lib/train/transports/cisco_ios_connection.rb +3 -0
- data/lib/train/transports/ssh.rb +12 -1
- data/lib/train/transports/ssh_connection.rb +1 -1
- data/lib/train/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6481551d7379b4a6cdee61568a1252e7feae2dc2d83def688417945eced8776
|
4
|
+
data.tar.gz: 3bec9acaea41dba70ed5c55cb7d6460d40e1c900002a172356419c80da222f7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09b0f40e16fc0533bb474a460d3526fd767cacd2e2c18e35a6f9aa825e953adc7de241116d12a832c179c6e7383afbb7357ecf31bdeb75347854083fee328caa'
|
7
|
+
data.tar.gz: c1bcbb41f3c7e3e832f1adf70b5f02634906e6f40d8ed989ff7aafb56b2e5008ba4cab5ce483dc39badaf8142e8e685a7f262c1f154d28c078ce0d899d9561fc
|
@@ -72,14 +72,14 @@ module Train::Extras
|
|
72
72
|
rawerr = "#{res.stdout} #{res.stderr}".strip
|
73
73
|
|
74
74
|
case rawerr
|
75
|
-
when
|
75
|
+
when /Sorry, try again/
|
76
76
|
["Wrong sudo password.", :bad_sudo_password]
|
77
|
-
when
|
77
|
+
when /sudo: no tty present and no askpass program specified/
|
78
78
|
["Sudo requires a password, please configure it.", :sudo_password_required]
|
79
|
-
when
|
79
|
+
when /sudo: command not found/
|
80
80
|
["Can't find sudo command. Please either install and "\
|
81
81
|
"configure it on the target or deactivate sudo.", :sudo_command_not_found]
|
82
|
-
when
|
82
|
+
when /sudo: sorry, you must have a tty to run sudo/
|
83
83
|
["Sudo requires a TTY. Please see the README on how to configure "\
|
84
84
|
"sudo to allow for non-interactive usage.", :sudo_no_tty]
|
85
85
|
else
|
@@ -22,8 +22,14 @@ module Train
|
|
22
22
|
def exist?
|
23
23
|
@exist ||= begin
|
24
24
|
f = @follow_symlink ? "" : " || test -L #{@spath}"
|
25
|
-
@backend.
|
26
|
-
|
25
|
+
if @backend.platform.solaris?
|
26
|
+
# Solaris does not support `-e` flag in default `test`,
|
27
|
+
# so we specify by running /usr/bin/test:
|
28
|
+
# https://github.com/inspec/train/issues/587
|
29
|
+
@backend.run_command("/usr/bin/test -e #{@spath}" + f)
|
30
|
+
else
|
31
|
+
@backend.run_command("test -e #{@spath}" + f)
|
32
|
+
end.exit_status == 0
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
@@ -34,16 +34,24 @@ module Train::Platforms::Detect::Helpers
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def command_output(cmd)
|
37
|
-
res = @backend.run_command(cmd)
|
37
|
+
res = @backend.run_command(cmd)
|
38
|
+
stdout = res.stdout
|
39
|
+
stderr = res.stderr
|
38
40
|
# When you try to execute command using ssh connction as root user and you have provided ssh user identity file
|
39
41
|
# it gives standard output to login as authorised user other than root. To show this standard ouput as an error
|
40
42
|
# to user we are matching the string of stdout and raising the error here so that user gets exact information.
|
41
|
-
if @backend.class.to_s == "Train::Transports::SSH::Connection"
|
42
|
-
|
43
|
+
if @backend.class.to_s == "Train::Transports::SSH::Connection"
|
44
|
+
if stdout =~ /Please login as the user/
|
45
|
+
raise Train::UserError, "SSH failed: #{stdout}"
|
46
|
+
end
|
47
|
+
|
48
|
+
if stderr =~ /WARNING: Your password has expired/
|
49
|
+
raise Train::UserError, "SSH failed: #{stderr}"
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
|
-
|
46
|
-
|
53
|
+
stdout.strip! unless stdout.nil?
|
54
|
+
stdout
|
47
55
|
end
|
48
56
|
|
49
57
|
def unix_uname_s
|
@@ -357,7 +357,7 @@ module Train::Platforms::Detect::Specifications
|
|
357
357
|
declare_instance("mac_os_x", "macOS X", "darwin") do
|
358
358
|
cmd = unix_file_contents("/System/Library/CoreServices/SystemVersion.plist")
|
359
359
|
@platform[:uuid_command] = "system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }'"
|
360
|
-
cmd =~ /Mac OS X/i
|
360
|
+
cmd =~ /Mac OS X|macOS/i
|
361
361
|
end
|
362
362
|
|
363
363
|
declare_instance("darwin", "Darwin", "darwin") do
|
@@ -369,6 +369,7 @@ module Train::Platforms::Detect::Specifications
|
|
369
369
|
declare_bsd("freebsd", "Freebsd", "bsd", /freebsd/i)
|
370
370
|
declare_bsd("openbsd", "Openbsd", "bsd", /openbsd/i)
|
371
371
|
declare_bsd("netbsd", "Netbsd", "bsd", /netbsd/i)
|
372
|
+
declare_bsd("dragonflybsd", "Dragonflybsd", "bsd", /dragonfly/i)
|
372
373
|
end
|
373
374
|
|
374
375
|
def self.load_other
|
@@ -16,6 +16,9 @@ class Train::Transports::SSH
|
|
16
16
|
# Use all options left that are not `nil` for `Net::SSH.start` later
|
17
17
|
@ssh_options = options.reject { |_key, value| value.nil? }
|
18
18
|
|
19
|
+
# Allow older algorithms
|
20
|
+
@ssh_options[:append_all_supported_algorithms] = true
|
21
|
+
|
19
22
|
@prompt = /^\S+[>#]\r\n.*$/
|
20
23
|
end
|
21
24
|
|
data/lib/train/transports/ssh.rb
CHANGED
@@ -65,6 +65,9 @@ module Train::Transports
|
|
65
65
|
option :non_interactive, default: false
|
66
66
|
option :verify_host_key, default: false
|
67
67
|
|
68
|
+
# Allow connecting with older algorithms
|
69
|
+
option :append_all_supported_algorithms, default: true
|
70
|
+
|
68
71
|
option :compression_level do |opts|
|
69
72
|
# on nil or false: set compression level to 0
|
70
73
|
opts[:compression] ? 6 : 0
|
@@ -76,7 +79,7 @@ module Train::Transports
|
|
76
79
|
validate_options(opts)
|
77
80
|
conn_opts = connection_options(opts)
|
78
81
|
|
79
|
-
if defined?(@connection) &&
|
82
|
+
if defined?(@connection) && reusable_connection?(conn_opts)
|
80
83
|
reuse_connection(&block)
|
81
84
|
else
|
82
85
|
create_new_connection(conn_opts, &block)
|
@@ -85,6 +88,13 @@ module Train::Transports
|
|
85
88
|
|
86
89
|
private
|
87
90
|
|
91
|
+
def reusable_connection?(conn_opts)
|
92
|
+
return false unless @connection_options
|
93
|
+
|
94
|
+
# Do requested options match their current settings
|
95
|
+
@connection_options.all? { |k, v| conn_opts[k] == v }
|
96
|
+
end
|
97
|
+
|
88
98
|
def validate_options(options)
|
89
99
|
super(options)
|
90
100
|
|
@@ -167,6 +177,7 @@ module Train::Transports
|
|
167
177
|
bastion_user: opts[:bastion_user],
|
168
178
|
bastion_port: opts[:bastion_port],
|
169
179
|
non_interactive: opts[:non_interactive],
|
180
|
+
append_all_supported_algorithms: opts[:append_all_supported_algorithms],
|
170
181
|
transport_options: opts,
|
171
182
|
}
|
172
183
|
# disable host key verification. The hash key and value to use
|
@@ -54,7 +54,7 @@ class Train::Transports::SSH
|
|
54
54
|
@bastion_user = @options.delete(:bastion_user)
|
55
55
|
@bastion_port = @options.delete(:bastion_port)
|
56
56
|
|
57
|
-
@cmd_wrapper
|
57
|
+
@cmd_wrapper = CommandWrapper.load(self, @transport_options)
|
58
58
|
end
|
59
59
|
|
60
60
|
# (see Base::Connection#close)
|
data/lib/train/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef InSpec Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ffi
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "!="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.13.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "!="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.13.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: json
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +87,7 @@ dependencies:
|
|
73
87
|
version: '1.2'
|
74
88
|
- - "<"
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
90
|
+
version: '4.0'
|
77
91
|
type: :runtime
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -83,7 +97,7 @@ dependencies:
|
|
83
97
|
version: '1.2'
|
84
98
|
- - "<"
|
85
99
|
- !ruby/object:Gem::Version
|
86
|
-
version: '
|
100
|
+
version: '4.0'
|
87
101
|
- !ruby/object:Gem::Dependency
|
88
102
|
name: net-ssh
|
89
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +107,7 @@ dependencies:
|
|
93
107
|
version: '2.9'
|
94
108
|
- - "<"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '7.0'
|
97
111
|
type: :runtime
|
98
112
|
prerelease: false
|
99
113
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -103,7 +117,7 @@ dependencies:
|
|
103
117
|
version: '2.9'
|
104
118
|
- - "<"
|
105
119
|
- !ruby/object:Gem::Version
|
106
|
-
version: '
|
120
|
+
version: '7.0'
|
107
121
|
description: A minimal Train with a backends for ssh and winrm.
|
108
122
|
email:
|
109
123
|
- inspec@chef.io
|