gritano 0.6.0 → 0.7.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.
- data/README.rdoc +6 -8
- data/TODO +2 -0
- data/VERSION +1 -1
- data/features/data/local_commands/plugin_info_ssh.txt +1 -0
- data/features/data/local_commands/plugin_list.txt +5 -0
- data/features/data/local_help.txt +5 -3
- data/features/data/remote_commands/admin_help_igorbonadio.txt +5 -3
- data/features/data/remote_commands/admin_help_jessicaeto.txt +5 -3
- data/features/data/remote_commands/admin_plugin_info_ssh_igorbonadio.txt +1 -0
- data/features/data/remote_commands/admin_plugin_info_ssh_jessicaeto.txt +1 -0
- data/features/data/remote_commands/admin_plugin_list_igorbonadio.txt +5 -0
- data/features/data/remote_commands/admin_plugin_list_jessicaeto.txt +1 -0
- data/features/data/remote_commands/admin_version_igorbonadio.txt +1 -13
- data/features/data/ssh_help.txt +10 -0
- data/features/local.feature +2 -1
- data/features/remote.feature +4 -2
- data/features/step_definitions/install_step.rb +1 -1
- data/gritano.gemspec +13 -3
- data/lib/gritano.rb +2 -1
- data/lib/gritano/console/executor.rb +5 -23
- data/lib/gritano/console/gritano.rb +54 -0
- data/lib/gritano/console/remote.rb +1 -1
- data/lib/gritano/plugin.rb +79 -0
- data/lib/gritano/plugin/ssh.rb +63 -0
- data/spec/console_base_spec.rb +1 -1
- data/spec/model_config_spec.rb +1 -1
- data/spec/plugin_spec.rb +48 -0
- data/spec/plugin_ssh_spec.rb +15 -0
- metadata +14 -4
- data/lib/gritano/console/ssh_install.txt +0 -7
data/README.rdoc
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
= Gritano v0.
|
|
1
|
+
= Gritano v0.7.0
|
|
2
2
|
|
|
3
3
|
Gritano is the simplest way to configure a git server over ssh. You can create repositories and manage user access using this practical tool.
|
|
4
4
|
|
|
5
5
|
== Requirements
|
|
6
6
|
|
|
7
|
-
* ruby 1.9 (http://www.ruby-lang.org)
|
|
7
|
+
* ruby 1.9 or 2.0 (http://www.ruby-lang.org)
|
|
8
8
|
* git (http://git-scm.com)
|
|
9
9
|
|
|
10
10
|
== Install
|
|
@@ -85,17 +85,15 @@ Starting from Gritano 0.3.0, administrators can execute commands via ssh:
|
|
|
85
85
|
|
|
86
86
|
$ ssh git@host.com admin:repo:list
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
== Plugins
|
|
89
89
|
|
|
90
|
-
Gritano 0.
|
|
91
|
-
|
|
92
|
-
To enable this feature, you need to install Gritano-SSH and execute:
|
|
90
|
+
Starting from Gritano 0.7.0, Gritano can be extended by plugins:
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
* SSH - It's a patched OpenSSH v6.1p1 used by Gritano that enables SSH lookup for public keys in a database.
|
|
95
93
|
|
|
96
94
|
== For more Information
|
|
97
95
|
|
|
98
|
-
http://igorbonadio.com.br/gritano
|
|
96
|
+
http://igorbonadio.com.br/gritano
|
|
99
97
|
|
|
100
98
|
== Contributing to Gritano
|
|
101
99
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.7.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
It installs a patched OpenSSH version used by Gritano that enables SSH lookup for public keys in a database
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
Examples:
|
|
4
4
|
gritano help
|
|
5
5
|
gritano version
|
|
6
|
+
gritano plugin:list
|
|
7
|
+
gritano plugin:info plugin_name
|
|
8
|
+
gritano plugin:add plugin_name
|
|
9
|
+
gritano plugin:rm plugin_name
|
|
10
|
+
gritano plugin:exec plugin_name command
|
|
6
11
|
gritano setup:prepare
|
|
7
12
|
gritano setup:install
|
|
8
13
|
gritano user:list
|
|
@@ -22,9 +27,6 @@
|
|
|
22
27
|
gritano repo:write:add reponame.git username
|
|
23
28
|
gritano repo:read:rm reponame.git username
|
|
24
29
|
gritano repo:write:rm reponame.git username
|
|
25
|
-
gritano addon:list
|
|
26
|
-
gritano addon:ssh:install
|
|
27
|
-
gritano addon:ssh:uninstall
|
|
28
30
|
|
|
29
31
|
--
|
|
30
32
|
v{{VERSION}}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
Examples:
|
|
4
4
|
ssh git@host.com admin:help
|
|
5
5
|
ssh git@host.com admin:version
|
|
6
|
+
ssh git@host.com admin:plugin:list
|
|
7
|
+
ssh git@host.com admin:plugin:info plugin_name
|
|
8
|
+
ssh git@host.com admin:plugin:add plugin_name
|
|
9
|
+
ssh git@host.com admin:plugin:rm plugin_name
|
|
10
|
+
ssh git@host.com admin:plugin:exec plugin_name command
|
|
6
11
|
ssh git@host.com admin:setup:prepare
|
|
7
12
|
ssh git@host.com admin:setup:install
|
|
8
13
|
ssh git@host.com admin:user:list
|
|
@@ -22,9 +27,6 @@
|
|
|
22
27
|
ssh git@host.com admin:repo:write:add reponame.git username
|
|
23
28
|
ssh git@host.com admin:repo:read:rm reponame.git username
|
|
24
29
|
ssh git@host.com admin:repo:write:rm reponame.git username
|
|
25
|
-
ssh git@host.com admin:addon:list
|
|
26
|
-
ssh git@host.com admin:addon:ssh:install
|
|
27
|
-
ssh git@host.com admin:addon:ssh:uninstall
|
|
28
30
|
|
|
29
31
|
--
|
|
30
32
|
v{{VERSION}}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
Examples:
|
|
4
4
|
ssh git@host.com admin:help
|
|
5
5
|
ssh git@host.com admin:version
|
|
6
|
+
ssh git@host.com admin:plugin:list
|
|
7
|
+
ssh git@host.com admin:plugin:info plugin_name
|
|
8
|
+
ssh git@host.com admin:plugin:add plugin_name
|
|
9
|
+
ssh git@host.com admin:plugin:rm plugin_name
|
|
10
|
+
ssh git@host.com admin:plugin:exec plugin_name command
|
|
6
11
|
ssh git@host.com admin:setup:prepare
|
|
7
12
|
ssh git@host.com admin:setup:install
|
|
8
13
|
ssh git@host.com admin:user:list
|
|
@@ -22,9 +27,6 @@
|
|
|
22
27
|
ssh git@host.com admin:repo:write:add reponame.git username
|
|
23
28
|
ssh git@host.com admin:repo:read:rm reponame.git username
|
|
24
29
|
ssh git@host.com admin:repo:write:rm reponame.git username
|
|
25
|
-
ssh git@host.com admin:addon:list
|
|
26
|
-
ssh git@host.com admin:addon:ssh:install
|
|
27
|
-
ssh git@host.com admin:addon:ssh:uninstall
|
|
28
30
|
|
|
29
31
|
--
|
|
30
32
|
v{{VERSION}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
It installs a patched OpenSSH version used by Gritano that enables SSH lookup for public keys in a database
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
error: access denied
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
error: access denied
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Examples:
|
|
4
|
-
ssh git@host.com version
|
|
5
|
-
ssh git@host.com help
|
|
6
|
-
ssh git@host.com repo:list
|
|
7
|
-
ssh git@host.com key:list
|
|
8
|
-
ssh git@host.com key:add keyname < key.pub
|
|
9
|
-
ssh git@host.com key:rm keyname
|
|
10
|
-
ssh git@host.com admin:help
|
|
11
|
-
|
|
12
|
-
--
|
|
13
|
-
v{{VERSION}}
|
|
1
|
+
v{{VERSION}}
|
data/features/local.feature
CHANGED
data/features/remote.feature
CHANGED
|
@@ -100,7 +100,8 @@ Feature: Remote access
|
|
|
100
100
|
| admin:repo:write:rm tmp/gritano.git arybonadio |
|
|
101
101
|
| admin:repo:write:rm tmp/p-lang.git igorbonadio |
|
|
102
102
|
| admin:repo:user:list tmp/ruby.git |
|
|
103
|
-
| admin:
|
|
103
|
+
| admin:plugin:list |
|
|
104
|
+
| admin:plugin:info ssh |
|
|
104
105
|
|
|
105
106
|
Scenario Outline: Admin user execute command
|
|
106
107
|
Given I start the remote console with "igorbonadio"
|
|
@@ -155,4 +156,5 @@ Feature: Remote access
|
|
|
155
156
|
| admin:repo:write:rm tmp/gritano.git arybonadio |
|
|
156
157
|
| admin:repo:write:rm tmp/p-lang.git igorbonadio |
|
|
157
158
|
| admin:repo:user:list tmp/ruby.git |
|
|
158
|
-
| admin:
|
|
159
|
+
| admin:plugin:list |
|
|
160
|
+
| admin:plugin:info ssh |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Given /^I start the gritano console but gritano is not installed$/ do
|
|
2
2
|
stdin = double()
|
|
3
3
|
stdin.stub(:read).and_return("Your SSHKEY here...")
|
|
4
|
-
FileUtils.rm_rf(
|
|
4
|
+
FileUtils.rm_rf(File.join("tmp", ".gritano"))
|
|
5
5
|
@home_dir = 'tmp'
|
|
6
6
|
@repo_dir = 'tmp'
|
|
7
7
|
@console = Gritano::CLI
|
data/gritano.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "gritano"
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.7.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Igor Bonadio"]
|
|
12
|
-
s.date = "2013-
|
|
12
|
+
s.date = "2013-03-05"
|
|
13
13
|
s.description = "Gritano is the simplest way to configure your git server over ssh. You can create repositories and manage user access."
|
|
14
14
|
s.email = "igorbonadio@gmail.com"
|
|
15
15
|
s.executables = ["gritano", "gritano-pub-key", "gritano-remote"]
|
|
@@ -41,6 +41,8 @@ Gem::Specification.new do |s|
|
|
|
41
41
|
"features/data/config_true.yml",
|
|
42
42
|
"features/data/local_commands/addon_list.txt",
|
|
43
43
|
"features/data/local_commands/addon_ssh_install.txt",
|
|
44
|
+
"features/data/local_commands/plugin_info_ssh.txt",
|
|
45
|
+
"features/data/local_commands/plugin_list.txt",
|
|
44
46
|
"features/data/local_commands/repo_add_tmp_jeka_git.txt",
|
|
45
47
|
"features/data/local_commands/repo_add_tmp_p_lang_git.txt",
|
|
46
48
|
"features/data/local_commands/repo_add_tmp_p_lang_git_igorbonadio.txt",
|
|
@@ -85,6 +87,10 @@ Gem::Specification.new do |s|
|
|
|
85
87
|
"features/data/remote_commands/admin_addon_list_jessicaeto.txt",
|
|
86
88
|
"features/data/remote_commands/admin_help_igorbonadio.txt",
|
|
87
89
|
"features/data/remote_commands/admin_help_jessicaeto.txt",
|
|
90
|
+
"features/data/remote_commands/admin_plugin_info_ssh_igorbonadio.txt",
|
|
91
|
+
"features/data/remote_commands/admin_plugin_info_ssh_jessicaeto.txt",
|
|
92
|
+
"features/data/remote_commands/admin_plugin_list_igorbonadio.txt",
|
|
93
|
+
"features/data/remote_commands/admin_plugin_list_jessicaeto.txt",
|
|
88
94
|
"features/data/remote_commands/admin_repo_add_tmp_jeka_git_igorbonadio.txt",
|
|
89
95
|
"features/data/remote_commands/admin_repo_add_tmp_jeka_git_jessicaeto.txt",
|
|
90
96
|
"features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio.txt",
|
|
@@ -178,6 +184,7 @@ Gem::Specification.new do |s|
|
|
|
178
184
|
"features/data/remote_commands/version_igorbonadio.txt",
|
|
179
185
|
"features/data/remote_commands/version_jessicaeto.txt",
|
|
180
186
|
"features/data/remote_help.txt",
|
|
187
|
+
"features/data/ssh_help.txt",
|
|
181
188
|
"features/install.feature",
|
|
182
189
|
"features/local.feature",
|
|
183
190
|
"features/pub_key.feature",
|
|
@@ -198,12 +205,13 @@ Gem::Specification.new do |s|
|
|
|
198
205
|
"lib/gritano/console/gritano.rb",
|
|
199
206
|
"lib/gritano/console/installer.rb",
|
|
200
207
|
"lib/gritano/console/remote.rb",
|
|
201
|
-
"lib/gritano/console/ssh_install.txt",
|
|
202
208
|
"lib/gritano/models.rb",
|
|
203
209
|
"lib/gritano/models/key.rb",
|
|
204
210
|
"lib/gritano/models/permission.rb",
|
|
205
211
|
"lib/gritano/models/repository.rb",
|
|
206
212
|
"lib/gritano/models/user.rb",
|
|
213
|
+
"lib/gritano/plugin.rb",
|
|
214
|
+
"lib/gritano/plugin/ssh.rb",
|
|
207
215
|
"spec/cli_spec.rb",
|
|
208
216
|
"spec/console_base_spec.rb",
|
|
209
217
|
"spec/console_executor_spec.rb",
|
|
@@ -217,6 +225,8 @@ Gem::Specification.new do |s|
|
|
|
217
225
|
"spec/model_permission_spec.rb",
|
|
218
226
|
"spec/model_repository_spec.rb",
|
|
219
227
|
"spec/model_user_spec.rb",
|
|
228
|
+
"spec/plugin_spec.rb",
|
|
229
|
+
"spec/plugin_ssh_spec.rb",
|
|
220
230
|
"spec/spec_helper.rb"
|
|
221
231
|
]
|
|
222
232
|
s.homepage = "http://igorbonadio.com.br/gritano"
|
data/lib/gritano.rb
CHANGED
|
@@ -2,4 +2,5 @@ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
|
|
|
2
2
|
|
|
3
3
|
require File.join(ROOT_PATH, '/gritano/models')
|
|
4
4
|
require File.join(ROOT_PATH, '/gritano/console')
|
|
5
|
-
require File.join(ROOT_PATH, '/gritano/cli')
|
|
5
|
+
require File.join(ROOT_PATH, '/gritano/cli')
|
|
6
|
+
require File.join(ROOT_PATH, '/gritano/plugin')
|
|
@@ -90,6 +90,11 @@ module Gritano
|
|
|
90
90
|
|
|
91
91
|
add_command "user:key:add", "username keyname < key.pub" do |argv|
|
|
92
92
|
login, key_name, key_file = argv
|
|
93
|
+
|
|
94
|
+
if File.exist?(File.join(@home_dir, '.gritano', 'config.yml'))
|
|
95
|
+
Key.config = YAML::load(File.open(File.join(@home_dir, '.gritano', 'config.yml')))
|
|
96
|
+
end
|
|
97
|
+
|
|
93
98
|
user = User.find_by_login(login)
|
|
94
99
|
if user
|
|
95
100
|
begin
|
|
@@ -247,29 +252,6 @@ module Gritano
|
|
|
247
252
|
return [false, "An error occurred. Permissions was not modified."]
|
|
248
253
|
end
|
|
249
254
|
|
|
250
|
-
add_command "addon:list" do |argv|
|
|
251
|
-
msg = Terminal::Table.new do |t|
|
|
252
|
-
t << ['add-ons']
|
|
253
|
-
t << :separator
|
|
254
|
-
t.add_row ['ssh']
|
|
255
|
-
end
|
|
256
|
-
return [true, msg]
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
add_command "addon:ssh:install" do |argv|
|
|
260
|
-
File.open(File.join(@home_dir, '.gritano', 'config.yml'), "w").write({'ssh' => true}.to_yaml)
|
|
261
|
-
File.open(File.join(@ssh_path, 'authorized_keys'), "w").write('')
|
|
262
|
-
gritano_pub_key_path = `which gritano-pub-key`[0..-2]
|
|
263
|
-
`ln -s #{gritano_pub_key_path} #{File.join(@home_dir, '.gritano', 'gritano-pub-key')}`
|
|
264
|
-
[true, File.open(File.join(File.dirname(__FILE__), 'ssh_install.txt')).readlines.join.gsub('{{GRITANO_PUB_KEY}}', File.join(@home_dir, '.gritano', 'gritano-pub-key'))]
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
add_command "addon:ssh:uninstall" do |argv|
|
|
268
|
-
File.open(File.join(@home_dir, '.gritano', 'config.yml'), "w").write({'ssh' => false}.to_yaml)
|
|
269
|
-
File.open(File.join(@ssh_path, 'authorized_keys'), 'w').write(Key.authorized_keys)
|
|
270
|
-
FileUtils.rm(File.join(@home_dir, '.gritano', 'gritano-pub-key')) if File.exist?(File.join(@home_dir, '.gritano', 'gritano-pub-key'))
|
|
271
|
-
[true, 'Now Gritano is configured to use the authorized_keys file to authenticate users.']
|
|
272
|
-
end
|
|
273
255
|
end
|
|
274
256
|
end
|
|
275
257
|
end
|
|
@@ -19,6 +19,60 @@ module Gritano
|
|
|
19
19
|
version = "v#{File.open(File.join(File.dirname(__FILE__), '..', '..', '..', 'VERSION')).readlines.join}"
|
|
20
20
|
[true, version]
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
add_command "plugin:list" do |argv|
|
|
24
|
+
begin
|
|
25
|
+
msg = Terminal::Table.new do |t|
|
|
26
|
+
t << ['plugin', 'installed']
|
|
27
|
+
t << :separator
|
|
28
|
+
Plugin.list.each do |plugin, params|
|
|
29
|
+
t.add_row [plugin, params[:installed].call]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
return [true, msg]
|
|
33
|
+
rescue Exception => e
|
|
34
|
+
puts e
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
add_command "plugin:info", "plugin_name" do |argv|
|
|
39
|
+
name, = argv
|
|
40
|
+
begin
|
|
41
|
+
return [true, Plugin.list[name][:klass].info]
|
|
42
|
+
rescue
|
|
43
|
+
return [false, "There isn't a plugin called #{name}"]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
add_command "plugin:add", "plugin_name" do |argv|
|
|
48
|
+
name, = argv
|
|
49
|
+
begin
|
|
50
|
+
Plugin.list[name][:klass].new.add
|
|
51
|
+
return [true, "Plugin #{name} was added"]
|
|
52
|
+
rescue
|
|
53
|
+
return [false, "There isn't a plugin called #{name}"]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
add_command "plugin:rm", "plugin_name" do |argv|
|
|
58
|
+
name, = argv
|
|
59
|
+
begin
|
|
60
|
+
Plugin.list[name][:klass].new.remove
|
|
61
|
+
return [true, "Plugin #{name} was removed"]
|
|
62
|
+
rescue
|
|
63
|
+
return [false, "There isn't a plugin called #{name}"]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
add_command "plugin:exec", "plugin_name command" do |argv|
|
|
68
|
+
name = argv[0]
|
|
69
|
+
params = argv[1..-1]
|
|
70
|
+
begin
|
|
71
|
+
return [true, Plugin.list[name][:klass].new.exec(params)]
|
|
72
|
+
rescue Exception => e
|
|
73
|
+
return [false, "There isn't a plugin called #{name}"]
|
|
74
|
+
end
|
|
75
|
+
end
|
|
22
76
|
|
|
23
77
|
def method_missing(meth, *args, &block)
|
|
24
78
|
params = [meth.to_s.gsub("_", ":")] + args[0]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module Gritano
|
|
2
|
+
class Plugin
|
|
3
|
+
|
|
4
|
+
def initialize(stdin = STDIN, home_dir = Etc.getpwuid.dir, repo_path = Etc.getpwuid.dir)
|
|
5
|
+
@stdin = stdin
|
|
6
|
+
@home_dir = home_dir
|
|
7
|
+
@repo_path = repo_path
|
|
8
|
+
@ssh_path = File.join(@home_dir, '.ssh')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def add
|
|
12
|
+
on_add
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def remove
|
|
16
|
+
on_remove
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def on_add
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def on_remove
|
|
24
|
+
raise NotImplementedError
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def exec(cmd)
|
|
28
|
+
method = cmd[0].split(':').join('_')
|
|
29
|
+
params = cmd[1..-1]
|
|
30
|
+
send(method, params)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.name
|
|
34
|
+
self.to_s.downcase.split('::')[-1]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.info
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.check_install
|
|
42
|
+
false
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.list
|
|
46
|
+
@subclass
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.inherited(subclass)
|
|
50
|
+
if @subclass
|
|
51
|
+
@subclass << subclass
|
|
52
|
+
else
|
|
53
|
+
@subclass = {subclass.name => {klass: subclass, installed: lambda { subclass.check_install }}}
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.add_command(command, parameters = "", &block)
|
|
58
|
+
define_method(command.gsub(':', '_'), &block)
|
|
59
|
+
commands[command] = parameters
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.commands
|
|
63
|
+
@commands || @commands = Hash.new
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.help
|
|
67
|
+
msg = " gritano plugin:exec #{self.name} [command]\n\n"
|
|
68
|
+
msg += " Examples:\n"
|
|
69
|
+
commands.each do |command, parameters|
|
|
70
|
+
msg += " gritano plugin:exec #{self.name} #{command} #{parameters}\n"
|
|
71
|
+
end
|
|
72
|
+
msg += "\n --\n v#{File.open(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).readlines.join}"
|
|
73
|
+
msg
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
require File.join(ROOT_PATH, 'gritano/plugin/ssh')
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Gritano
|
|
2
|
+
class Ssh < Plugin
|
|
3
|
+
|
|
4
|
+
def self.info
|
|
5
|
+
"It installs a patched OpenSSH version used by Gritano that enables SSH lookup for public keys in a database"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def on_add
|
|
9
|
+
File.open(File.join(@home_dir, '.gritano', 'config.yml'), "w").write({'ssh' => true}.to_yaml)
|
|
10
|
+
File.open(File.join(@ssh_path, 'authorized_keys'), "w").write('')
|
|
11
|
+
gritano_pub_key_path = `which gritano-pub-key`[0..-2]
|
|
12
|
+
`ln -s #{gritano_pub_key_path} #{File.join(@home_dir, '.gritano', 'gritano-pub-key')}`
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def on_remove
|
|
16
|
+
File.open(File.join(@home_dir, '.gritano', 'config.yml'), "w").write({'ssh' => false}.to_yaml)
|
|
17
|
+
File.open(File.join(@ssh_path, 'authorized_keys'), 'w').write(Key.authorized_keys)
|
|
18
|
+
FileUtils.rm(File.join(@home_dir, '.gritano', 'gritano-pub-key')) if File.exist?(File.join(@home_dir, '.gritano', 'gritano-pub-key'))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.check_install
|
|
22
|
+
home = Etc.getpwuid.dir
|
|
23
|
+
if File.exist?(File.join(home, '.gritano', 'config.yml'))
|
|
24
|
+
config = YAML::load(File.open(File.join(home, '.gritano', 'config.yml')))
|
|
25
|
+
return config['ssh']
|
|
26
|
+
else
|
|
27
|
+
return false
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
add_command "help" do |params|
|
|
32
|
+
Ssh.help
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
add_command "install", "gritano_path" do |params|
|
|
36
|
+
gritano_dir, = params
|
|
37
|
+
FileUtils.rm_rf(File.join('/tmp', 'gritano-openssh')) if Dir.exist?(File.join('/tmp', 'gritano-openssh'))
|
|
38
|
+
puts "[git] Cloning"
|
|
39
|
+
`git clone git://github.com/igorbonadio/gritano-openssh.git /tmp/gritano-openssh`
|
|
40
|
+
puts "[build] Configuring"
|
|
41
|
+
`cd /tmp/gritano-openssh/src && ./configure`
|
|
42
|
+
puts "[build] Compiling"
|
|
43
|
+
`cd /tmp/gritano-openssh/src && make`
|
|
44
|
+
puts "[build] Installing"
|
|
45
|
+
`cd /tmp/gritano-openssh/src && make install`
|
|
46
|
+
gritano_pub_key = File.join(gritano_dir, 'gritano-pub-key')
|
|
47
|
+
File.open(File.join("/usr", "local", "etc", "sshd_config"), "a") do |f|
|
|
48
|
+
f.write("\n\nAuthorizedKeysScript #{gritano_pub_key}\n\n")
|
|
49
|
+
end
|
|
50
|
+
return "Installed"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
add_command "start" do |params|
|
|
54
|
+
`/usr/local/sbin/sshd`
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
add_command "stop" do |params|
|
|
58
|
+
pid = `ps aux | grep -e /usr/local/sbin/sshd | grep -v grep | tr -s \" \" | cut -d \" \" -f2`
|
|
59
|
+
`kill -9 #{pid}`
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
data/spec/console_base_spec.rb
CHANGED
data/spec/model_config_spec.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
|
3
3
|
module Gritano
|
|
4
|
-
describe Config do
|
|
4
|
+
describe "Config" do
|
|
5
5
|
it "should have a ssh configuration" do
|
|
6
6
|
config = YAML::load(File.open(File.join('.gritano', 'config.yml')))
|
|
7
7
|
config['ssh'].should be_false
|
data/spec/plugin_spec.rb
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
module Gritano
|
|
4
|
+
describe Plugin do
|
|
5
|
+
it "should have an on_add method" do
|
|
6
|
+
Plugin.new.should respond_to :on_add
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should have an on_remove method" do
|
|
10
|
+
Plugin.new.should respond_to :on_remove
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should have an exec method" do
|
|
14
|
+
Plugin.new.should respond_to :exec
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should have an info method" do
|
|
18
|
+
Plugin.should respond_to :info
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should raise an NotImplementedError if on_add is not overrided" do
|
|
22
|
+
lambda { Plugin.new.on_add }.should raise_error NotImplementedError
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should raise an NotImplementedError if on_remove is not overrided" do
|
|
26
|
+
lambda { Plugin.new.on_remove }.should raise_error NotImplementedError
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should raise an NotImplementedError if info is not overrided" do
|
|
30
|
+
lambda { Plugin.info }.should raise_error NotImplementedError
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should exec commands" do
|
|
34
|
+
plugin = Plugin.new
|
|
35
|
+
plugin.should_receive(:config_port).with(["2222"])
|
|
36
|
+
plugin.exec("config:port 2222".split(" "))
|
|
37
|
+
|
|
38
|
+
plugin.should_receive(:start).with([])
|
|
39
|
+
plugin.exec("start".split(" "))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should have a ssh pluging" do
|
|
43
|
+
Plugin.list['ssh'][:klass].should be == Ssh
|
|
44
|
+
Plugin.list['ssh'][:installed].call.should be == false
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
module Gritano
|
|
4
|
+
describe Ssh do
|
|
5
|
+
it "should show information" do
|
|
6
|
+
Ssh.info.should be == "It installs a patched OpenSSH version used by Gritano that enables SSH lookup for public keys in a database"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should show the help" do
|
|
10
|
+
Ssh.help.should be == File.open("features/data/ssh_help.txt").readlines.join.
|
|
11
|
+
gsub('{{VERSION}}', File.open("VERSION").readlines.join)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gritano
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
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-
|
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activerecord
|
|
@@ -222,6 +222,8 @@ files:
|
|
|
222
222
|
- features/data/config_true.yml
|
|
223
223
|
- features/data/local_commands/addon_list.txt
|
|
224
224
|
- features/data/local_commands/addon_ssh_install.txt
|
|
225
|
+
- features/data/local_commands/plugin_info_ssh.txt
|
|
226
|
+
- features/data/local_commands/plugin_list.txt
|
|
225
227
|
- features/data/local_commands/repo_add_tmp_jeka_git.txt
|
|
226
228
|
- features/data/local_commands/repo_add_tmp_p_lang_git.txt
|
|
227
229
|
- features/data/local_commands/repo_add_tmp_p_lang_git_igorbonadio.txt
|
|
@@ -266,6 +268,10 @@ files:
|
|
|
266
268
|
- features/data/remote_commands/admin_addon_list_jessicaeto.txt
|
|
267
269
|
- features/data/remote_commands/admin_help_igorbonadio.txt
|
|
268
270
|
- features/data/remote_commands/admin_help_jessicaeto.txt
|
|
271
|
+
- features/data/remote_commands/admin_plugin_info_ssh_igorbonadio.txt
|
|
272
|
+
- features/data/remote_commands/admin_plugin_info_ssh_jessicaeto.txt
|
|
273
|
+
- features/data/remote_commands/admin_plugin_list_igorbonadio.txt
|
|
274
|
+
- features/data/remote_commands/admin_plugin_list_jessicaeto.txt
|
|
269
275
|
- features/data/remote_commands/admin_repo_add_tmp_jeka_git_igorbonadio.txt
|
|
270
276
|
- features/data/remote_commands/admin_repo_add_tmp_jeka_git_jessicaeto.txt
|
|
271
277
|
- features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio.txt
|
|
@@ -359,6 +365,7 @@ files:
|
|
|
359
365
|
- features/data/remote_commands/version_igorbonadio.txt
|
|
360
366
|
- features/data/remote_commands/version_jessicaeto.txt
|
|
361
367
|
- features/data/remote_help.txt
|
|
368
|
+
- features/data/ssh_help.txt
|
|
362
369
|
- features/install.feature
|
|
363
370
|
- features/local.feature
|
|
364
371
|
- features/pub_key.feature
|
|
@@ -379,12 +386,13 @@ files:
|
|
|
379
386
|
- lib/gritano/console/gritano.rb
|
|
380
387
|
- lib/gritano/console/installer.rb
|
|
381
388
|
- lib/gritano/console/remote.rb
|
|
382
|
-
- lib/gritano/console/ssh_install.txt
|
|
383
389
|
- lib/gritano/models.rb
|
|
384
390
|
- lib/gritano/models/key.rb
|
|
385
391
|
- lib/gritano/models/permission.rb
|
|
386
392
|
- lib/gritano/models/repository.rb
|
|
387
393
|
- lib/gritano/models/user.rb
|
|
394
|
+
- lib/gritano/plugin.rb
|
|
395
|
+
- lib/gritano/plugin/ssh.rb
|
|
388
396
|
- spec/cli_spec.rb
|
|
389
397
|
- spec/console_base_spec.rb
|
|
390
398
|
- spec/console_executor_spec.rb
|
|
@@ -398,6 +406,8 @@ files:
|
|
|
398
406
|
- spec/model_permission_spec.rb
|
|
399
407
|
- spec/model_repository_spec.rb
|
|
400
408
|
- spec/model_user_spec.rb
|
|
409
|
+
- spec/plugin_spec.rb
|
|
410
|
+
- spec/plugin_ssh_spec.rb
|
|
401
411
|
- spec/spec_helper.rb
|
|
402
412
|
- TODO
|
|
403
413
|
homepage: http://igorbonadio.com.br/gritano
|
|
@@ -415,7 +425,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
415
425
|
version: '0'
|
|
416
426
|
segments:
|
|
417
427
|
- 0
|
|
418
|
-
hash:
|
|
428
|
+
hash: -2501048903144546813
|
|
419
429
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
420
430
|
none: false
|
|
421
431
|
requirements:
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Now Gritano is configured to use a custom ssh that can authenticate users that are registered in Gritano's database.
|
|
2
|
-
|
|
3
|
-
Don't forget to add the following line to your sshd_config:
|
|
4
|
-
|
|
5
|
-
AuthorizedKeysScript {{GRITANO_PUB_KEY}}
|
|
6
|
-
|
|
7
|
-
For more information: https://github.com/igorbonadio/gritano-openssh.
|