summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/views/errors/invalid_ssh_key.html.haml3
-rw-r--r--lib/gitlab/backend/gitolite.rb9
3 files changed, 14 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 7c1941ec859..9aab250dbd4 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,6 +14,10 @@ class ApplicationController < ActionController::Base
render "errors/gitolite", layout: "error"
end
+ rescue_from Gitlab::Gitolite::InvalidKey do |exception|
+ render "errors/invalid_ssh_key", layout: "error"
+ end
+
rescue_from Encoding::CompatibilityError do |exception|
render "errors/encoding", layout: "error", status: 404
end
diff --git a/app/views/errors/invalid_ssh_key.html.haml b/app/views/errors/invalid_ssh_key.html.haml
new file mode 100644
index 00000000000..fb7922b0ea3
--- /dev/null
+++ b/app/views/errors/invalid_ssh_key.html.haml
@@ -0,0 +1,3 @@
+%h1 Git Error
+%hr
+%p Seems like SSH Key you provided is not a valid SSH key.
diff --git a/lib/gitlab/backend/gitolite.rb b/lib/gitlab/backend/gitolite.rb
index 18b30500913..b69f4663c35 100644
--- a/lib/gitlab/backend/gitolite.rb
+++ b/lib/gitlab/backend/gitolite.rb
@@ -6,6 +6,7 @@ require 'fileutils'
module Gitlab
class Gitolite
class AccessDenied < StandardError; end
+ class InvalidKey < StandardError; end
def set_key key_id, key_content, projects
configure do |c|
@@ -190,8 +191,12 @@ module Gitlab
end
end
rescue Exception => ex
- Gitlab::Logger.error(ex.message)
- raise Gitolite::AccessDenied.new("gitolite timeout")
+ if ex.message =~ /is not a valid SSH key string/
+ raise Gitolite::InvalidKey.new("ssh key is not valid")
+ else
+ Gitlab::Logger.error(ex.message)
+ raise Gitolite::AccessDenied.new("gitolite timeout")
+ end
end
end
end