spare_keys 1.1.1 → 1.2.0
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/spare_keys.rb +27 -0
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee6d263bb19251d17f0bc7798c5654db62373f56
|
4
|
+
data.tar.gz: e744c90dad10884f4ff680ed7c2e090ff1b21fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1a1dbc6e74400ca1340175133be63d53f495abef63256b44118c287568df5a69993780186fdd1536c665bdf3ffdac30211fde17e1dede81aa89102b052a8b0
|
7
|
+
data.tar.gz: ccfe4b946b6e5409e1a9f91d5967fc5d65f2c69107e590dea2707d9c0883553abf72cd725644ac71c277216b664e6d963053d736184f304f24dd8f6a9a85d928
|
data/lib/spare_keys.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
|
2
3
|
# Temporarily reconfigures the active keychain
|
3
4
|
class SpareKeys
|
4
5
|
|
@@ -13,6 +14,8 @@ class SpareKeys
|
|
13
14
|
def self.use_keychain(keychain_path, clear_list = false, type = nil, domain = nil)
|
14
15
|
domain_flag = "-d #{domain}" if domain
|
15
16
|
|
17
|
+
keychain_path = expand_keychain_path(keychain_path)
|
18
|
+
|
16
19
|
original_list = `security list-keychains #{domain_flag} | xargs`
|
17
20
|
original_keychain = `security #{type}-keychain #{domain_flag} | xargs` if type
|
18
21
|
|
@@ -26,6 +29,16 @@ class SpareKeys
|
|
26
29
|
yield if block_given?
|
27
30
|
ensure
|
28
31
|
original_keychain = `security #{type}-keychain #{domain_flag} -s #{original_keychain}` if type
|
32
|
+
|
33
|
+
unless clear_list
|
34
|
+
# Grab the keychain list as it looks right now in case
|
35
|
+
# another process has changed it
|
36
|
+
current_list = `security list-keychains #{domain_flag}`
|
37
|
+
current_list_as_array = current_list.scan(/"[^"]*"/).map { |item| item.gsub(/^"|"$/, "")}
|
38
|
+
# Remove the supplied keychain
|
39
|
+
original_list = (current_list_as_array.reject { |item| item == keychain_path }).join(" ")
|
40
|
+
end
|
41
|
+
|
29
42
|
`security list-keychains #{domain_flag} -s #{original_list}`
|
30
43
|
end
|
31
44
|
end
|
@@ -49,6 +62,7 @@ class SpareKeys
|
|
49
62
|
temp_keychain = Dir::Tmpname.make_tmpname(['spare-keys-', extension], nil)
|
50
63
|
|
51
64
|
`security create-keychain -p "#{password}" #{temp_keychain}`
|
65
|
+
`security set-keychain-settings #{temp_keychain}`
|
52
66
|
`security unlock-keychain -p "#{password}" #{temp_keychain}`
|
53
67
|
|
54
68
|
if block_given?
|
@@ -80,4 +94,17 @@ private
|
|
80
94
|
|
81
95
|
end
|
82
96
|
|
97
|
+
def self.expand_keychain_path(path)
|
98
|
+
|
99
|
+
if (File.basename(path) == path)
|
100
|
+
default_keychain_path = File.expand_path("~/Library/Keychains")
|
101
|
+
|
102
|
+
path = File.join(default_keychain_path, path)
|
103
|
+
else
|
104
|
+
path = File.expand_path(path)
|
105
|
+
end
|
106
|
+
|
107
|
+
return path
|
108
|
+
end
|
109
|
+
|
83
110
|
end
|
metadata
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spare_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Szalay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.9.6
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.12'
|
48
|
-
- -
|
48
|
+
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: 1.12.5
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- - ~>
|
55
|
+
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '1.12'
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.12.5
|
61
61
|
description: Isolates keychain access for use with keychain-dependent utilities
|
@@ -75,18 +75,19 @@ require_paths:
|
|
75
75
|
- lib
|
76
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
88
|
+
rubygems_version: 2.6.7
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Temporarily keychain switcher
|
92
92
|
test_files: []
|
93
|
+
has_rdoc:
|