sshkit-sudo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85165b7a964cdf190a07333fdeccfa0bae2245cc
4
- data.tar.gz: 4fd29dd814d0723b82820a9fb316bb07a4341700
3
+ metadata.gz: 4aef500f984bbbcac5a81ea14dcae23d3cd909ef
4
+ data.tar.gz: 1b7daedbca438fb00feb770091071f6c347301ff
5
5
  SHA512:
6
- metadata.gz: 235c4f129e985cdaf9c8e51c0e13ab14aaf1be7d3be5f6eb178a80861f268bbd7d8285f5e4c557ec615ae4ec91413a86fd09263beb92b82f2ecdea58ebbb1157
7
- data.tar.gz: ab21701f75d6e67cde2bbc5c8fad306db4c2a99acf8153f835e9d3e7f7fc2db9a89d82616eec313e44451a28ee97c2c3fbfd5a5e7f2f1db3c9d77420efd9ab8e
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
- pass = $stdin.noecho(&:gets)
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
 
@@ -1,5 +1,5 @@
1
1
  module SSHKit
2
2
  module Sudo
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkit-sudo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Imai