summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/authorized_keys.rb9
-rw-r--r--lib/system_check/app/authorized_keys_permission_check.rb4
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/authorized_keys.rb b/lib/gitlab/authorized_keys.rb
index ca9b65b7c44..820a78b653c 100644
--- a/lib/gitlab/authorized_keys.rb
+++ b/lib/gitlab/authorized_keys.rb
@@ -22,6 +22,15 @@ module Gitlab
false
end
+ # Creates the authorized_keys file if it doesn't exist
+ #
+ # @return [Boolean]
+ def create
+ open_authorized_keys_file(File::CREAT) { true }
+ rescue Errno::EACCES
+ false
+ end
+
# Add id and its key to the authorized_keys file
#
# @param [String] id identifier of key prefixed by `key-`
diff --git a/lib/system_check/app/authorized_keys_permission_check.rb b/lib/system_check/app/authorized_keys_permission_check.rb
index 1c581f88abc..1246a6875a3 100644
--- a/lib/system_check/app/authorized_keys_permission_check.rb
+++ b/lib/system_check/app/authorized_keys_permission_check.rb
@@ -14,6 +14,10 @@ module SystemCheck
authorized_keys.accessible?
end
+ def repair!
+ authorized_keys.create
+ end
+
def show_error
try_fixing_it([
"sudo chmod 700 #{File.dirname(authorized_keys.file)}",