Commit c638971d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'add-key-lock' into 'master'

Use lock file when add new entries to authorized_keys

Fixes #21
parents 025f97aa 8402c1bc
v1.9.5
- Put authorized_keys.lock in the same directory as authorized_keys
- Use lock file when add new entries to authorized_keys
v1.9.4
- Use lock file when modify authorized_keys
......
......@@ -29,9 +29,11 @@ class GitlabKeys
protected
def add_key
$logger.info "Adding key #{@key_id} => #{@key.inspect}"
auth_line = key_line(@key_id, @key)
open(auth_file, 'a') { |file| file.puts(auth_line) }
lock do
$logger.info "Adding key #{@key_id} => #{@key.inspect}"
auth_line = key_line(@key_id, @key)
open(auth_file, 'a') { |file| file.puts(auth_line) }
end
true
end
......
......@@ -28,6 +28,7 @@ describe GitlabKeys do
context "without file writing" do
before { gitlab_keys.stub(:open) }
before { create_authorized_keys_fixture }
it "should log an add-key event" do
$logger.should_receive(:info).with('Adding key key-741 => "ssh-rsa AAAAB3NzaDAxx2E"')
......
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