Class: SystemCheck::App::GitUserDefaultSSHConfigCheck

Inherits:
BaseCheck
  • Object
show all
Defined in:
lib/system_check/app/git_user_default_ssh_config_check.rb

Constant Summary collapse

WHITELIST =

These files are allowed in the .ssh directory. The ‘config` file is not whitelisted as it may change the SSH client’s behaviour dramatically.

%w[
  authorized_keys
  authorized_keys.lock
  authorized_keys2
  known_hosts
].freeze

Instance Attribute Summary

Attributes inherited from BaseCheck

#skip_reason

Instance Method Summary collapse

Methods inherited from BaseCheck

#can_repair?, #can_skip?, check_fail, check_pass, display_name, #multi_check, #multi_check?, #repair!, set_check_fail, set_check_pass, set_name, set_skip_reason, skip_reason

Methods included from Helpers

#finished_checking, #fix_and_rerun, #for_more_information, #omnibus_gitlab?, #sanitized_message, #see_installation_guide_section, #should_sanitize?, #start_checking, #sudo_gitlab, #try_fixing_it

Methods included from Gitlab::TaskHelpers

#ask_to_continue, #checkout_or_clone_version, #checkout_version, #clone_repo, #get_version, #gid_for, #gitlab_user, #gitlab_user?, #invoke_and_time_task, #os_name, #prompt, #prompt_for_password, #repository_storage_paths_args, #run_and_match, #run_command, #run_command!, #uid_for, #user_home, #warn_user_is_not_gitlab

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/system_check/app/git_user_default_ssh_config_check.rb', line 22

def check?
  forbidden_files.empty?
end

#show_errorObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/system_check/app/git_user_default_ssh_config_check.rb', line 26

def show_error
  backup_dir = "~/gitlab-check-backup-#{Time.now.to_i}"

  instructions = forbidden_files.map do |filename|
    "sudo mv #{Shellwords.escape(filename)} #{backup_dir}"
  end

  try_fixing_it("mkdir #{backup_dir}", *instructions)
  for_more_information('doc/user/ssh.md#overriding-ssh-settings-on-the-gitlab-server')
  fix_and_rerun
end

#skip?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/system_check/app/git_user_default_ssh_config_check.rb', line 18

def skip?
  !home_dir || !File.directory?(home_dir)
end