Commit c11c923c authored by Douwe Maan's avatar Douwe Maan

Prevent keys with a very specific comment from accidentally being deleted.

parent fcb6bb46
v2.6.3
- Prevent keys with a very specific comment from accidentally being deleted.
v2.6.2 v2.6.2
- Include ecdsa keys in `gitlab_keys list-keys`. - Include ecdsa keys in `gitlab_keys list-keys`.
- Refactor logic around GL_ID - Refactor logic around GL_ID
......
...@@ -71,8 +71,12 @@ class GitlabKeys ...@@ -71,8 +71,12 @@ class GitlabKeys
$stdin $stdin
end end
def key_command(key_id)
"#{ROOT_PATH}/bin/gitlab-shell #{key_id}"
end
def key_line(key_id, public_key) 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 end
def rm_key def rm_key
...@@ -81,7 +85,7 @@ class GitlabKeys ...@@ -81,7 +85,7 @@ class GitlabKeys
Tempfile.open('authorized_keys') do |temp| Tempfile.open('authorized_keys') do |temp|
open(auth_file, 'r+') do |current| open(auth_file, 'r+') do |current|
current.each do |line| 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
end end
temp.close temp.close
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment