confman 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +34 -18
- data/confman.gemspec +1 -1
- data/lib/confman/access.rb +13 -4
- data/lib/confman/cli.rb +12 -1
- data/lib/confman/version.rb +1 -1
- metadata +19 -4
data/LICENSE.txt
CHANGED
@@ -1,22 +1,38 @@
|
|
1
|
-
|
1
|
+
All other components of this product are
|
2
|
+
Copyright (c) 2013 Synctree, Inc. All rights reserved.
|
2
3
|
|
3
|
-
|
4
|
+
Certain inventions disclosed in this file may be claimed within
|
5
|
+
patents owned or patent applications filed by Synctree, Inc. or third
|
6
|
+
parties.
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
Subject to the terms of this notice, Synctree grants you a
|
9
|
+
nonexclusive, nontransferable license, without the right to
|
10
|
+
sublicense, to (a) install and execute one copy of these files on any
|
11
|
+
number of workstations owned or controlled by you and (b) distribute
|
12
|
+
verbatim copies of these files to third parties. As a condition to the
|
13
|
+
foregoing grant, you must provide this notice along with each copy you
|
14
|
+
distribute and you must not remove, alter, or obscure this notice. All
|
15
|
+
other use, reproduction, modification, distribution, or other
|
16
|
+
exploitation of these files is strictly prohibited, except as may be set
|
17
|
+
forth in a separate written license agreement between you and New
|
18
|
+
Relic. The terms of any such license agreement will control over this
|
19
|
+
notice. The license stated above will be automatically terminated and
|
20
|
+
revoked if you exceed its scope or violate any of the terms of this
|
21
|
+
notice.
|
12
22
|
|
13
|
-
|
14
|
-
|
23
|
+
This License does not grant permission to use the trade names,
|
24
|
+
trademarks, service marks, or product names of Synctree, except as
|
25
|
+
required for reasonable and customary use in describing the origin of
|
26
|
+
this file and reproducing the content of this notice. You may not
|
27
|
+
mark or brand this file with any trade name, trademarks, service
|
28
|
+
marks, or product names other than the original brand (if any)
|
29
|
+
provided by Synctree.
|
15
30
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
31
|
+
Unless otherwise expressly agreed by Synctree in a separate written
|
32
|
+
license agreement, these files are provided AS IS, WITHOUT WARRANTY OF
|
33
|
+
ANY KIND, including without any implied warranties of MERCHANTABILITY,
|
34
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a
|
35
|
+
condition to your use of these files, you are solely responsible for
|
36
|
+
such use. Synctree will have no liability to you for direct,
|
37
|
+
indirect, consequential, incidental, special, or punitive damages or
|
38
|
+
for lost profits or data.
|
data/confman.gemspec
CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.description = 'Confman ruby client'
|
12
12
|
spec.summary = ''
|
13
13
|
spec.homepage = ""
|
14
|
-
spec.license = "MIT"
|
15
14
|
|
16
15
|
spec.files = `git ls-files`.split($/)
|
17
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -19,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
20
|
spec.add_dependency "rest-client", "~> 1"
|
21
|
+
spec.add_dependency "daemons", "~> 1"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rspec", "~> 2.6"
|
data/lib/confman/access.rb
CHANGED
@@ -9,14 +9,18 @@ class Confman::Access
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def extract_keys(file = authorized_keys_location)
|
12
|
-
r = { :
|
12
|
+
r = { :manual_keys => [], :users => {} }
|
13
13
|
return r unless File.exists?(file)
|
14
14
|
File.readlines(file).each do |key|
|
15
15
|
key.chomp!
|
16
16
|
if key =~ /^#\sAM\s([^=]+)=(.*)$/
|
17
17
|
r[$1.to_sym] = $2
|
18
|
+
elsif key =~ /^environment=\"AM_USER=([^\"]+)\"\s(.*)$/
|
19
|
+
r[:users][$1] ||= []
|
20
|
+
r[:users][$1].push($2)
|
21
|
+
|
18
22
|
elsif key =~ /^ssh-/
|
19
|
-
r[:
|
23
|
+
r[:manual_keys].push(key.chomp)
|
20
24
|
end
|
21
25
|
end
|
22
26
|
r
|
@@ -54,8 +58,13 @@ class Confman::Access
|
|
54
58
|
current_keys = extract_keys
|
55
59
|
new_keys = request_new_keys
|
56
60
|
|
57
|
-
|
58
|
-
|
61
|
+
keys_changed = current_keys[:users].keys.sort != new_keys[:users].keys.sort
|
62
|
+
current_keys[:users].each do |user, ssh_keys|
|
63
|
+
keys_changed = true if ssh_keys.sort != new_keys[:users][user].sort
|
64
|
+
end unless keys_changed
|
65
|
+
|
66
|
+
if keys_changed
|
67
|
+
new_keys[:manual_keys] = current_keys[:manual_keys]
|
59
68
|
|
60
69
|
new_authorized_keys_file = "#{authorized_keys_location}.#{Time.now.to_i}"
|
61
70
|
save_keys(new_keys, new_authorized_keys_file)
|
data/lib/confman/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'confman'
|
2
2
|
require 'optparse'
|
3
|
+
require 'daemons'
|
3
4
|
|
4
5
|
class Confman::CLI
|
5
6
|
@@options = {}
|
@@ -25,6 +26,7 @@ class Confman::CLI
|
|
25
26
|
opt.separator " export -n <name> -f <outputfile>: Imports conf_set named 'name' into a file."
|
26
27
|
opt.separator " init -e <endpoint> -k <key>: Sets up config. Run this before querying the ConfMan server.(run as root)"
|
27
28
|
opt.separator " reset_keys: Resets authorized keys for the current user."
|
29
|
+
opt.separator " keyd: Periodically Resets authorized keys for the current user"
|
28
30
|
opt.separator ""
|
29
31
|
opt.separator "Options"
|
30
32
|
|
@@ -47,7 +49,7 @@ class Confman::CLI
|
|
47
49
|
|
48
50
|
@@opt_parser.parse!(args)
|
49
51
|
|
50
|
-
if respond_to?(command)
|
52
|
+
if command && respond_to?(command)
|
51
53
|
send(command)
|
52
54
|
else
|
53
55
|
puts @@opt_parser
|
@@ -87,6 +89,15 @@ class Confman::CLI
|
|
87
89
|
Confman.access.reset_keys
|
88
90
|
end
|
89
91
|
|
92
|
+
def self.keyd
|
93
|
+
Daemons.run_proc('keyd') do
|
94
|
+
loop do
|
95
|
+
reset_keys
|
96
|
+
sleep(60)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
90
101
|
def self.exportall
|
91
102
|
out = @@options[:outputfile] ? File.open(@@options[:outputfile], "w") : STDOUT
|
92
103
|
out.write(Confman.api.conf_sets)
|
data/lib/confman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: daemons
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: bundler
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,8 +116,7 @@ files:
|
|
100
116
|
- spec/confman_spec.rb
|
101
117
|
- spec/data_store_spec.rb
|
102
118
|
homepage: ''
|
103
|
-
licenses:
|
104
|
-
- MIT
|
119
|
+
licenses: []
|
105
120
|
post_install_message:
|
106
121
|
rdoc_options: []
|
107
122
|
require_paths:
|