summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-07-18 13:55:01 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-07-18 13:55:01 +0300
commit475f607a22dcf8ec16c1b51edb638fa624768061 (patch)
tree78cacd6518838dd3faa4df1de47d8765cb939650
parent02e39563c8e931c94a650f36d8732beecc068019 (diff)
downloadgitlab-ce-475f607a22dcf8ec16c1b51edb638fa624768061.tar.gz
Use gitlab-shell authorized_keys truncation. Fix issue with authorized_keys stored in different location
-rw-r--r--lib/gitlab/backend/shell.rb9
-rw-r--r--lib/tasks/gitlab/check.rake2
-rw-r--r--lib/tasks/gitlab/shell.rake5
3 files changed, 12 insertions, 4 deletions
diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb
index 6c9532face8..d0b89f85ade 100644
--- a/lib/gitlab/backend/shell.rb
+++ b/lib/gitlab/backend/shell.rb
@@ -139,6 +139,15 @@ module Gitlab
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", key_id, key_content
end
+ # Remove all ssh keys from gitlab shell
+ #
+ # Ex.
+ # remmove_all_keys
+ #
+ def remove_all_keys
+ system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "clear"
+ end
+
# Add empty directory for storing repositories
#
# Ex.
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 779670512c2..be679dcd97e 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -657,7 +657,7 @@ namespace :gitlab do
end
def check_gitlab_shell
- required_version = Gitlab::VersionInfo.new(1, 6, 0)
+ required_version = Gitlab::VersionInfo.new(1, 7, 0)
current_version = Gitlab::VersionInfo.parse(gitlab_shell_version)
print "GitLab Shell version >= #{required_version} ? ... "
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
index 11d4eacaa69..0d7a390bc92 100644
--- a/lib/tasks/gitlab/shell.rake
+++ b/lib/tasks/gitlab/shell.rake
@@ -25,15 +25,14 @@ namespace :gitlab do
def setup
warn_user_is_not_gitlab
- gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys')
unless ENV['force'] == 'yes'
puts "This will rebuild an authorized_keys file."
- puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
+ puts "You will lose any data stored in authorized_keys file."
ask_to_continue
puts ""
end
- system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")
+ Gitlab::Shell.new.remove_all_keys
Key.find_each(batch_size: 1000) do |key|
if Gitlab::Shell.new.add_key(key.shell_id, key.key)