diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-10 17:49:13 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-14 11:30:46 +0200 |
commit | c11c923c036bf8247d92b9d3ca8812c1b1240339 (patch) | |
tree | eef2d8a5672b3c0f73cd00164e31149b77dc18bb /lib | |
parent | fcb6bb46e88b1c050ca68045461e8663c3b4a77a (diff) | |
download | gitlab-shell-c11c923c036bf8247d92b9d3ca8812c1b1240339.tar.gz |
Prevent keys with a very specific comment from accidentally being deleted.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab_keys.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb index 1ed0ab3..10f84bd 100644 --- a/lib/gitlab_keys.rb +++ b/lib/gitlab_keys.rb @@ -71,8 +71,12 @@ class GitlabKeys $stdin end + def key_command(key_id) + "#{ROOT_PATH}/bin/gitlab-shell #{key_id}" + end + def key_line(key_id, public_key) - auth_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell #{key_id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{public_key}" + auth_line = "command=\"#{key_command(key_id)}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{public_key}" end def rm_key @@ -81,7 +85,7 @@ class GitlabKeys Tempfile.open('authorized_keys') do |temp| open(auth_file, 'r+') do |current| current.each do |line| - temp.puts(line) unless line.include?("/bin/gitlab-shell #{@key_id}\"") + temp.puts(line) unless line.start_with?("command=\"#{key_command(@key_id)}\"") end end temp.close |