summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-10 17:49:13 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-14 11:30:46 +0200
commitc11c923c036bf8247d92b9d3ca8812c1b1240339 (patch)
treeeef2d8a5672b3c0f73cd00164e31149b77dc18bb
parentfcb6bb46e88b1c050ca68045461e8663c3b4a77a (diff)
downloadgitlab-shell-c11c923c036bf8247d92b9d3ca8812c1b1240339.tar.gz
Prevent keys with a very specific comment from accidentally being deleted.
-rw-r--r--CHANGELOG3
-rw-r--r--VERSION2
-rw-r--r--lib/gitlab_keys.rb8
3 files changed, 10 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 4d653cd..3205e8b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v2.6.3
+ - Prevent keys with a very specific comment from accidentally being deleted.
+
v2.6.2
- Include ecdsa keys in `gitlab_keys list-keys`.
- Refactor logic around GL_ID
diff --git a/VERSION b/VERSION
index 097a15a..ec1cf33 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.6.2
+2.6.3
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