diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-05 13:51:18 +0000 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-05 13:51:18 +0000 |
| commit | e6eaa8e0364c922166ef63a65f7e8e7eacf1b12c (patch) | |
| tree | 04eb0e33193a8d02c32eba5f081e6b0fe3f27279 /lib | |
| parent | af88f84247d5e9462f6ab562a96c620d0c7a57d4 (diff) | |
| parent | ab008254dc74d928d5e361955cb2fa9ab3005f79 (diff) | |
| download | gitlab-shell-e6eaa8e0364c922166ef63a65f7e8e7eacf1b12c.tar.gz | |
Merge branch 'banish_shell_from_gitlab_keys' of /home/git/repositories/gitlab/gitlab-shell
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab_keys.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb index 2ea5117..bc00867 100644 --- a/lib/gitlab_keys.rb +++ b/lib/gitlab_keys.rb @@ -36,12 +36,17 @@ class GitlabKeys def rm_key $logger.info "Removing key #{@key_id}" Tempfile.open('authorized_keys') do |temp| - cmd = "sed '/shell #{@key_id}\"/d' #{auth_file} > #{temp.path} && mv #{temp.path} #{auth_file}" - system(cmd) + open(auth_file, 'r+') do |current| + current.each do |line| + temp.puts(line) unless line.include?("/bin/gitlab-shell #{@key_id}\"") + end + end + temp.close + FileUtils.cp(temp.path, auth_file) end end def clear - system("echo '# Managed by gitlab-shell' > #{auth_file}") + open(auth_file, 'w') { |file| file.puts '# Managed by gitlab-shell' } end end |
