diff options
| author | Douwe Maan <douwe@gitlab.com> | 2017-08-02 15:20:26 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2017-08-02 15:20:26 +0000 |
| commit | 980eb544646cccf4dde60825452c59b13b14aa6d (patch) | |
| tree | 0896f33aa907f726b4adac7cb99e94b8ea6e77b0 /lib/gitlab_projects.rb | |
| parent | b3ff4c3d61b63bab1d6acf19099295799ce9b6a2 (diff) | |
| parent | cc62be58f8ff3eefa4879b0db4356c43e1d870ca (diff) | |
| download | gitlab-shell-980eb544646cccf4dde60825452c59b13b14aa6d.tar.gz | |
Merge branch '100-require-tempfile' into 'master'v5.6.1
Fix SSH key and known_hosts support
Closes #100
See merge request !156
Diffstat (limited to 'lib/gitlab_projects.rb')
| -rw-r--r-- | lib/gitlab_projects.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index 267c679..49a1d25 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -1,4 +1,5 @@ require 'fileutils' +require 'tempfile' require 'timeout' require 'open3' @@ -432,26 +433,29 @@ class GitlabProjects options = {} if ENV.key?('GITLAB_SHELL_SSH_KEY') - key_file = Tempfile.new('gitlab-shell-key-file', mode: 0o400) + key_file = Tempfile.new('gitlab-shell-key-file') + key_file.chmod(0o400) key_file.write(ENV['GITLAB_SHELL_SSH_KEY']) key_file.close options['IdentityFile'] = key_file.path - options['IdentitiesOnly'] = true + options['IdentitiesOnly'] = 'yes' end if ENV.key?('GITLAB_SHELL_KNOWN_HOSTS') - known_hosts_file = Tempfile.new('gitlab-shell-known-hosts', mode: 0o400) + known_hosts_file = Tempfile.new('gitlab-shell-known-hosts') + known_hosts_file.chmod(0o400) known_hosts_file.write(ENV['GITLAB_SHELL_KNOWN_HOSTS']) known_hosts_file.close - options['StrictHostKeyChecking'] = true + options['StrictHostKeyChecking'] = 'yes' options['UserKnownHostsFile'] = known_hosts_file.path end return yield({}) if options.empty? - script = Tempfile.new('gitlab-shell-ssh-wrapper', mode: 0o755) + script = Tempfile.new('gitlab-shell-ssh-wrapper') + script.chmod(0o755) script.write(custom_ssh_script(options)) script.close |
