Commit 475f607a22dcf8ec16c1b51edb638fa624768061
1 parent
02e39563
Exists in
master
and in
4 other branches
Use gitlab-shell authorized_keys truncation. Fix issue with authorized_keys stor…
…ed in different location
Showing
3 changed files
with
12 additions
and
4 deletions
Show diff stats
lib/gitlab/backend/shell.rb
| @@ -139,6 +139,15 @@ module Gitlab | @@ -139,6 +139,15 @@ module Gitlab | ||
| 139 | system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", key_id, key_content | 139 | system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", key_id, key_content |
| 140 | end | 140 | end |
| 141 | 141 | ||
| 142 | + # Remove all ssh keys from gitlab shell | ||
| 143 | + # | ||
| 144 | + # Ex. | ||
| 145 | + # remmove_all_keys | ||
| 146 | + # | ||
| 147 | + def remove_all_keys | ||
| 148 | + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "clear" | ||
| 149 | + end | ||
| 150 | + | ||
| 142 | # Add empty directory for storing repositories | 151 | # Add empty directory for storing repositories |
| 143 | # | 152 | # |
| 144 | # Ex. | 153 | # Ex. |
lib/tasks/gitlab/check.rake
| @@ -657,7 +657,7 @@ namespace :gitlab do | @@ -657,7 +657,7 @@ namespace :gitlab do | ||
| 657 | end | 657 | end |
| 658 | 658 | ||
| 659 | def check_gitlab_shell | 659 | def check_gitlab_shell |
| 660 | - required_version = Gitlab::VersionInfo.new(1, 6, 0) | 660 | + required_version = Gitlab::VersionInfo.new(1, 7, 0) |
| 661 | current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) | 661 | current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) |
| 662 | 662 | ||
| 663 | print "GitLab Shell version >= #{required_version} ? ... " | 663 | print "GitLab Shell version >= #{required_version} ? ... " |
lib/tasks/gitlab/shell.rake
| @@ -25,15 +25,14 @@ namespace :gitlab do | @@ -25,15 +25,14 @@ namespace :gitlab do | ||
| 25 | def setup | 25 | def setup |
| 26 | warn_user_is_not_gitlab | 26 | warn_user_is_not_gitlab |
| 27 | 27 | ||
| 28 | - gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys') | ||
| 29 | unless ENV['force'] == 'yes' | 28 | unless ENV['force'] == 'yes' |
| 30 | puts "This will rebuild an authorized_keys file." | 29 | puts "This will rebuild an authorized_keys file." |
| 31 | - puts "You will lose any data stored in #{gitlab_shell_authorized_keys}." | 30 | + puts "You will lose any data stored in authorized_keys file." |
| 32 | ask_to_continue | 31 | ask_to_continue |
| 33 | puts "" | 32 | puts "" |
| 34 | end | 33 | end |
| 35 | 34 | ||
| 36 | - system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}") | 35 | + Gitlab::Shell.new.remove_all_keys |
| 37 | 36 | ||
| 38 | Key.find_each(batch_size: 1000) do |key| | 37 | Key.find_each(batch_size: 1000) do |key| |
| 39 | if Gitlab::Shell.new.add_key(key.shell_id, key.key) | 38 | if Gitlab::Shell.new.add_key(key.shell_id, key.key) |