sshkit-sudo 0.0.1 → 0.0.2
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/sshkit/sudo.rb +8 -0
- data/lib/sshkit/sudo/backends_ext/netssh.rb +13 -2
- data/lib/sshkit/sudo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aef500f984bbbcac5a81ea14dcae23d3cd909ef
|
4
|
+
data.tar.gz: 1b7daedbca438fb00feb770091071f6c347301ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f360bcfc138880579c22b0bfb6fcd1f82bff408c9ff878aabd2c9647ff2eca17535a17c92b0aa7243a94c50bb5bd4d9236a6ffa73866fe6ec503bebcbaee2116
|
7
|
+
data.tar.gz: ba4027bd19e83afe772c00e0d0a8d55a285978c2184ffe90ea9c2a109a6b7ea1152f58f818822f08dcb9566e719e2507b630ebd46731de8302f9edf8340a57db
|
data/lib/sshkit/sudo.rb
CHANGED
@@ -2,3 +2,11 @@ require "sshkit/sudo/version"
|
|
2
2
|
require "sshkit/sudo/backends_ext/printer"
|
3
3
|
require "sshkit/sudo/backends_ext/netssh"
|
4
4
|
require "sshkit/sudo/backends_ext/local"
|
5
|
+
|
6
|
+
module SSHKit
|
7
|
+
module Sudo
|
8
|
+
def self.password_cache
|
9
|
+
@password_cache ||= {}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -25,9 +25,16 @@ module SSHKit
|
|
25
25
|
cmd.stdout = data
|
26
26
|
cmd.full_stdout += data
|
27
27
|
output << cmd
|
28
|
-
|
28
|
+
if data =~ /Sorry.*\stry\sagain/
|
29
|
+
SSHKit::Sudo.password_cache[password_cache_key(cmd.host)] = nil
|
30
|
+
end
|
29
31
|
if data =~ /password.*:/
|
30
|
-
|
32
|
+
key = password_cache_key(cmd.host)
|
33
|
+
pass = SSHKit::Sudo.password_cache[key]
|
34
|
+
unless pass
|
35
|
+
pass = $stdin.noecho(&:gets)
|
36
|
+
SSHKit::Sudo.password_cache[key] = pass
|
37
|
+
end
|
31
38
|
ch.send_data(pass)
|
32
39
|
end
|
33
40
|
end
|
@@ -69,6 +76,10 @@ module SSHKit
|
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
79
|
+
|
80
|
+
def password_cache_key(host)
|
81
|
+
"#{host.user}@#{host.hostname}"
|
82
|
+
end
|
72
83
|
end
|
73
84
|
end
|
74
85
|
|
data/lib/sshkit/sudo/version.rb
CHANGED