key_control 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/key_control/key_ring.rb +0 -7
- data/lib/key_control/system.rb +0 -12
- data/lib/key_control/version.rb +1 -1
- data/test/key_control/key_ring_test.rb +41 -39
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmI3Yjk3YjQwODc1ZDcxZjVmYzBhZDgzYmY0MmE3NDAwZWZkNjBiNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDcxNmJmYWFiMjE0MThjZTFkY2ViZTk1Y2Q5YjA0N2NhYjEyNDVkMA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzNlMjRhOGNlOTdjODRkYjE1ZTQ4NjhmZTM2Y2RjYTc2ZGQzNDMzYThhMzcx
|
10
|
+
Y2RkNmI2Y2ZkMzhjNGNlYTllNWE2NGNkNTYwYmE0ZmY3NGEwMGUyZjI1OWEz
|
11
|
+
ZWQyOWVlYTAxYTJjMjIwM2VjNWE5NGMwMjBiYjlkNThmNGZkYmM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjA2ZWYyMTgyM2Q1NDMwMGZiNWNhYzgwNjQxYTJhZWQ4ODQxOWU4MWE0NjFm
|
14
|
+
ZjAxNTM4NmM4ZWE1OTAyNWMxYjBhNTg4N2E1MThkNTU4MjdlNTg1MWRjZjIx
|
15
|
+
MWJiM2RlZjRhOTBjYTAyNTg2Y2IwMDAyMzNhYzNlMzRkMmNkMTA=
|
data/lib/key_control/key_ring.rb
CHANGED
data/lib/key_control/system.rb
CHANGED
@@ -94,17 +94,5 @@ module KeyControl
|
|
94
94
|
Fiddle::TYPE_SIZE_T ],
|
95
95
|
Fiddle::TYPE_LONG )
|
96
96
|
end
|
97
|
-
|
98
|
-
# Private: Get a proc representing the keyctl_describe system call.
|
99
|
-
#
|
100
|
-
# Returns a Fiddle::Function.
|
101
|
-
def describe
|
102
|
-
@describe ||= Fiddle::Function.new(
|
103
|
-
keyutils["keyctl_describe"],
|
104
|
-
[ Fiddle::TYPE_INT,
|
105
|
-
Fiddle::ALIGN_CHAR,
|
106
|
-
Fiddle::TYPE_SIZE_T ],
|
107
|
-
Fiddle::TYPE_INT )
|
108
|
-
end
|
109
97
|
end
|
110
98
|
end
|
data/lib/key_control/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe KeyControl::KeyRing do
|
4
|
+
let(:secret) { "the secret time forgot" }
|
4
5
|
|
5
6
|
describe "thread keyring" do
|
6
7
|
let(:ring) do
|
@@ -8,18 +9,20 @@ describe KeyControl::KeyRing do
|
|
8
9
|
end
|
9
10
|
|
10
11
|
it "allows read/write for values in the same thread" do
|
11
|
-
|
12
|
-
ring[
|
12
|
+
key = "single-thread-test"
|
13
|
+
ring[key].must_equal nil
|
14
|
+
|
15
|
+
ring[key] = secret
|
16
|
+
ring[key].must_equal secret
|
13
17
|
end
|
14
18
|
|
15
19
|
it "uses a new keyring for new threads" do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
thr.join
|
20
|
+
key = "multi-thread-test"
|
21
|
+
ring[key].must_equal nil
|
22
|
+
|
23
|
+
Thread.new { ring[key] = secret }.join
|
21
24
|
|
22
|
-
ring[
|
25
|
+
ring[key].must_equal nil
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
@@ -29,31 +32,30 @@ describe KeyControl::KeyRing do
|
|
29
32
|
end
|
30
33
|
|
31
34
|
it "allows read/write of values in the same process" do
|
32
|
-
|
33
|
-
ring[
|
35
|
+
key = "single-process-test"
|
36
|
+
ring[key].must_equal nil
|
37
|
+
|
38
|
+
ring[key] = secret
|
39
|
+
ring[key].must_equal secret
|
34
40
|
end
|
35
41
|
|
36
42
|
it "allows read/write of values across threads in the same process" do
|
37
|
-
|
43
|
+
key = "process-thread-test"
|
44
|
+
ring[key].must_equal nil
|
38
45
|
|
39
|
-
|
40
|
-
ring["process-thread-test"] = "baz"
|
41
|
-
end
|
42
|
-
thr.join
|
46
|
+
Thread.new { ring[key] = secret }.join
|
43
47
|
|
44
|
-
ring[
|
48
|
+
ring[key].must_equal secret
|
45
49
|
end
|
46
50
|
|
47
51
|
it "uses a new keyring for new processes" do
|
48
|
-
|
49
|
-
|
50
|
-
pid = fork do
|
51
|
-
ring["child-process-test"] = "too many secrets"
|
52
|
-
exit
|
53
|
-
end
|
52
|
+
key = "multi-process-test"
|
53
|
+
ring[key].must_equal nil
|
54
54
|
|
55
|
+
pid = fork { ring[key] = secret and exit }
|
55
56
|
Process.waitpid(pid)
|
56
|
-
|
57
|
+
|
58
|
+
ring[key].must_equal nil
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -62,31 +64,31 @@ describe KeyControl::KeyRing do
|
|
62
64
|
KeyControl::KeyRing.new(KeyControl::SESSION)
|
63
65
|
end
|
64
66
|
|
65
|
-
it "allows read/write of values in the same process" do
|
66
|
-
|
67
|
-
ring[
|
67
|
+
it "allows read/write of values in the same thread/process" do
|
68
|
+
key = "session-test"
|
69
|
+
ring[key].must_equal nil
|
70
|
+
|
71
|
+
ring[key] = secret
|
72
|
+
ring[key].must_equal secret
|
68
73
|
end
|
69
74
|
|
70
75
|
it "allows read/write of values across threads in the same process" do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
thr.join
|
76
|
+
key = "session-thread-test"
|
77
|
+
ring[key].must_equal nil
|
78
|
+
|
79
|
+
Thread.new { ring[key] = secret }.join
|
76
80
|
|
77
|
-
ring[
|
81
|
+
ring[key].must_equal secret
|
78
82
|
end
|
79
83
|
|
80
84
|
it "allows read/write of values across processes in the same session" do
|
81
|
-
|
82
|
-
|
83
|
-
pid = fork do
|
84
|
-
ring["session-process-test"] = "too many secrets"
|
85
|
-
exit
|
86
|
-
end
|
85
|
+
key = "session-process-test"
|
86
|
+
ring[key].must_equal nil
|
87
87
|
|
88
|
+
pid = fork { ring[key] = secret and exit }
|
88
89
|
Process.waitpid(pid)
|
89
|
-
|
90
|
+
|
91
|
+
ring[key].must_equal secret
|
90
92
|
end
|
91
93
|
end
|
92
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: key_control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,19 +28,18 @@ dependencies:
|
|
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'
|
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'
|
41
|
-
description:
|
42
|
-
|
43
|
-
system's keyctl utility.
|
41
|
+
description: ! " Provides a Hash-like syntax for storing and retrieving data from
|
42
|
+
the\n system's keyctl utility.\n"
|
44
43
|
email:
|
45
44
|
- andrew@tablexi.com
|
46
45
|
executables: []
|
@@ -71,17 +70,17 @@ require_paths:
|
|
71
70
|
- lib
|
72
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
72
|
requirements:
|
74
|
-
- - '>='
|
73
|
+
- - ! '>='
|
75
74
|
- !ruby/object:Gem::Version
|
76
75
|
version: '0'
|
77
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
77
|
requirements:
|
79
|
-
- - '>='
|
78
|
+
- - ! '>='
|
80
79
|
- !ruby/object:Gem::Version
|
81
80
|
version: '0'
|
82
81
|
requirements: []
|
83
82
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.2.2
|
85
84
|
signing_key:
|
86
85
|
specification_version: 4
|
87
86
|
summary: A simple wrapper for the `keyctl` utility.
|