awsborn 0.3.5 → 0.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.
- data/VERSION +1 -1
- data/lib/awsborn/keychain.rb +61 -0
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Awsborn
|
2
|
+
class Keychain
|
3
|
+
def initialize (path = nil)
|
4
|
+
@keychain = path
|
5
|
+
end
|
6
|
+
|
7
|
+
def unlock
|
8
|
+
unless @unlocked
|
9
|
+
system 'security', 'unlock-keychain', '-p', master_password, @keychain
|
10
|
+
@unlocked = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def lock
|
15
|
+
system 'security', 'lock-keychain', @keychain
|
16
|
+
@unlocked = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def note (name)
|
20
|
+
unlock
|
21
|
+
hex_dump = find_generic_password(name)
|
22
|
+
text = decode_hex(hex_dump)
|
23
|
+
text = string_content(text) if multi_encoded?(text)
|
24
|
+
text
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_generic_password (name)
|
28
|
+
dump = `security -q find-generic-password -s "#{name}" -g "#{@keychain}" 2>&1 1>/dev/null`
|
29
|
+
hex_dump = dump[/password: 0x(\S+)/, 1]
|
30
|
+
raise "Note '#{name}' not found in #{@keychain}" unless hex_dump
|
31
|
+
hex_dump
|
32
|
+
end
|
33
|
+
|
34
|
+
def decode_hex (hex_dump)
|
35
|
+
text = ""
|
36
|
+
0.step(hex_dump.size - 2, 2) { |i| text << hex_dump[i,2].hex.chr }
|
37
|
+
text
|
38
|
+
end
|
39
|
+
|
40
|
+
def multi_encoded? (note)
|
41
|
+
note.include?(%q(<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">))
|
42
|
+
end
|
43
|
+
|
44
|
+
def string_content (note)
|
45
|
+
text = note[%r{<string>(.*)</string>}m,1]
|
46
|
+
text.gsub!('<','<')
|
47
|
+
text.gsub!('>','>')
|
48
|
+
text.gsub!('&','&')
|
49
|
+
text
|
50
|
+
end
|
51
|
+
|
52
|
+
def master_password
|
53
|
+
unless @password
|
54
|
+
dump = `security -q find-generic-password -s "#{File.basename(@keychain)}" -g 2>&1`
|
55
|
+
@password = dump[/password: "(.*)"/, 1]
|
56
|
+
end
|
57
|
+
@password
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 6
|
9
|
+
version: 0.3.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Vrensk
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04
|
17
|
+
date: 2010-05-04 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/awsborn/extensions/object.rb
|
108
108
|
- lib/awsborn/extensions/proc.rb
|
109
109
|
- lib/awsborn/git_branch.rb
|
110
|
+
- lib/awsborn/keychain.rb
|
110
111
|
- lib/awsborn/known_hosts_updater.rb
|
111
112
|
- lib/awsborn/rake.rb
|
112
113
|
- lib/awsborn/server.rb
|