summaryrefslogtreecommitdiff
path: root/app/models/key.rb
diff options
context:
space:
mode:
authorSašo Stanovnik <sstanovnik@gmail.com>2015-03-24 10:55:31 +0100
committerSašo Stanovnik <sstanovnik@gmail.com>2015-03-24 10:55:31 +0100
commit38384bd9521a42683d9ba33ac482993496c6f986 (patch)
tree337fbb5a108ce428c281a55c5b80b46dfc13a853 /app/models/key.rb
parent05d4658b3233b3f37876772c10fbf5e648682154 (diff)
downloadgitlab-ce-38384bd9521a42683d9ba33ac482993496c6f986.tar.gz
The new fingerprint format wis incompatible with the previous regex.
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index 1c41f8b8d7a..480a16f9335 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -83,14 +83,14 @@ class Key < ActiveRecord::Base
cmd_status = 0
cmd_output = ''
+ explicit_fingerprint_algorithm = false
Tempfile.open('gitlab_key_file') do |file|
file.puts key
file.rewind
-
+
# OpenSSH 6.8 introduces a new default output format for fingerprints.
# Check the version and decide which command to use.
version_output, version_status = popen(%W(ssh -V))
- explicit_fingerprint_algorithm = false
if version_status.zero?
out, _ = version_output.scan /.*?(\d)\.(\d).*?,/
major, minor = out[0], out[1]
@@ -107,8 +107,15 @@ class Key < ActiveRecord::Base
end
if cmd_status.zero?
- cmd_output.gsub /(\h{2}:)+\h{2}/ do |match|
- self.fingerprint = match
+ if explicit_fingerprint_algorithm
+ cmd_output.gsub /(MD5:)(\h{2}:)+\h{2}/ do |match|
+ match.slice! /^MD5:/
+ self.fingerprint = match
+ end
+ else
+ cmd_output.gsub /(\h{2}:)+\h{2}/ do |match|
+ self.fingerprint = match
+ end
end
end
end