Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/backend/shell.rb')
-rw-r--r--lib/gitlab/backend/shell.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb
index 7121c8e40d2..b93800e235f 100644
--- a/lib/gitlab/backend/shell.rb
+++ b/lib/gitlab/backend/shell.rb
@@ -2,6 +2,12 @@ module Gitlab
class Shell
class AccessDenied < StandardError; end
+ class KeyAdder < Struct.new(:io)
+ def add_key(id, key)
+ io.puts("#{id}\t#{key.strip}")
+ end
+ end
+
# Init new repository
#
# name - project path with namespace
@@ -130,6 +136,16 @@ module Gitlab
system "#{gitlab_shell_path}/bin/gitlab-keys", "add-key", key_id, key_content
end
+ # Batch-add keys to authorized_keys
+ #
+ # Ex.
+ # batch_add_keys { |adder| adder.add_key("key-42", "sha-rsa ...") }
+ def batch_add_keys(&block)
+ IO.popen(%W(#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys), 'w') do |io|
+ block.call(KeyAdder.new(io))
+ end
+ end
+
# Remove ssh key from gitlab shell
#
# Ex.