summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Bajao <ebajao@gitlab.com>2019-08-29 16:28:22 +0800
committerPatrick Bajao <ebajao@gitlab.com>2019-08-29 16:33:04 +0800
commita1ec2ad0b2638f084dffbe804b681c96dc6dadb8 (patch)
treeeff3f8eee80adf8abdf7b656512f85ffee5527dd /lib
parentb047359de5b365022d63b8da10a3a87f3ad92397 (diff)
downloadgitlab-ce-a1ec2ad0b2638f084dffbe804b681c96dc6dadb8.tar.gz
Auto create authorized_keys file if doesn't exist60071-remove-gitlab-keys-usage
Utilize the auto repair functionality of system checks.
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)}",