From 633042fd189f0e0ac62086a1e58ea0e3f89b8ff2 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Sat, 2 Nov 2013 18:52:51 +0100 Subject: Remove sed invocation from GitlabKeys --- lib/gitlab_keys.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb index 2ea5117..1185b0d 100644 --- a/lib/gitlab_keys.rb +++ b/lib/gitlab_keys.rb @@ -36,8 +36,13 @@ 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 -- cgit v1.2.1