key_control 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a43d357aa17e6404d6b196fb576fdf25946bdab
4
- data.tar.gz: 126e9d849870e97199913868ab3ec380e6a142ec
3
+ metadata.gz: 4a784b53837348d3fcba7ffc9f84e65c6a9d040b
4
+ data.tar.gz: 229ba84f2e41c534c7097295c94d7bf6b97e2ddf
5
5
  SHA512:
6
- metadata.gz: 6bd5cc1776e64ecdee7abc6425d180a1983e2d6428860e5fc7a52f10d6082ea1b64ceeb156aaa857eae8ee48689d01194cbfa40f53292ac2ff8b6c43e3401c07
7
- data.tar.gz: 5e3828a75ac5addee2ae31f590290ac1a36c96d38fcabca66cbbafcccde52150fcc1c2af603649d3c8493f0f8a10c2ea948af77a368d2eaa63804adcd2f183f4
6
+ metadata.gz: eb8c382abdfaf975048c30b55067a7d0ab08ff920545eb900ef180b4ffd9b8044284d7d1d4349a1802d4fd7639ed2a759864832c106f457cff640ec3ec72b7ee
7
+ data.tar.gz: 88eac2321abe8781fda47e4e04d05f83875d241a2bc11294288ce0dffb77199705402c871cfa4b0a5a125d634c44ab3adddd2cd42005d6156f41de2a4aaf9235
@@ -47,13 +47,16 @@ module KeyControl
47
47
 
48
48
  # Private: Get a handle representing the system calls available through
49
49
  # libkeyutils.so.
50
- # TODO: For now, we assume that the shared object file is in the default
51
- # location for CentOS installations. It would be nice to make this more
52
- # flexible.
53
50
  #
54
51
  # Returns a Fiddle::Handle.
55
52
  def keyutils
56
- @keyutils ||= Fiddle::Handle.new("/lib64/libkeyutils.so.1")
53
+ @keyutils ||= KeyControl::LIBRARIES.map do |library|
54
+ begin
55
+ Fiddle::Handle.new(library)
56
+ rescue Fiddle::DLError
57
+ nil
58
+ end
59
+ end.compact.first
57
60
  end
58
61
  end
59
62
  end
@@ -1,3 +1,3 @@
1
1
  module KeyControl
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/key_control.rb CHANGED
@@ -4,10 +4,25 @@ require "key_control/key_ring"
4
4
 
5
5
  module KeyControl
6
6
 
7
+ # Constants for special keyring identifiers. For more information, see:
8
+ # http://manpages.ubuntu.com/manpages/oneiric/man1/keyctl.1.html
7
9
  THREAD = -1
8
10
  PROCESS = -2
9
11
  SESSION = -3
10
12
  USER = -4
11
13
  DEFAULT = -5
12
14
  GROUP = -6
15
+
16
+ # A list of potential library paths. Currently points to the default path for
17
+ # CentOS installations.
18
+ # TODO: Track down and add the default library paths for more distros.
19
+ LIBRARIES = %w(
20
+ /lib64/libkeyutils.so.1 )
21
+
22
+ # Public: Does KeyControl detect any known keyutils libraries?
23
+ #
24
+ # Returns a boolean.
25
+ def self.available?
26
+ LIBRARIES.any? { |library| File.exists?(library) }
27
+ end
13
28
  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.1
4
+ version: 0.0.2
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-03-27 00:00:00.000000000 Z
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.0.6
80
+ rubygems_version: 2.2.2
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: A simple wrapper for the `keyctl` utility.