summaryrefslogtreecommitdiff
path: root/lib/gitlab_keys.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2013-11-02 18:52:51 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2013-11-02 18:52:51 +0100
commit633042fd189f0e0ac62086a1e58ea0e3f89b8ff2 (patch)
tree4244c05b447054951050f61582b827b232a2bc27 /lib/gitlab_keys.rb
parent261cb1fe7c946e034a5f43a03e9da86476eca8f2 (diff)
downloadgitlab-shell-633042fd189f0e0ac62086a1e58ea0e3f89b8ff2.tar.gz
Remove sed invocation from GitlabKeys
Diffstat (limited to 'lib/gitlab_keys.rb')
-rw-r--r--lib/gitlab_keys.rb9
1 files changed, 7 insertions, 2 deletions
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