diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-05-30 11:44:38 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-05-30 11:44:38 +0200 |
commit | 2c5d04deb2e9252b346e5701da81f62f28f800db (patch) | |
tree | a6e5b2bb5afc29987ada73dcaf215559a82b1ea1 | |
parent | c26647b9d919085c669f49c71d0646ac23b9c9d9 (diff) | |
download | gitlab-shell-2c5d04deb2e9252b346e5701da81f62f28f800db.tar.gz |
Put authorized_keys.lock in the .ssh directory
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | lib/gitlab_keys.rb | 2 | ||||
-rw-r--r-- | spec/gitlab_keys_spec.rb | 13 |
3 files changed, 16 insertions, 2 deletions
@@ -1,3 +1,6 @@ +v1.9.5 + - Put authorized_keys.lock in the same directory as authorized_keys + v1.9.4 - Use lock file when modify authorized_keys diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb index 675f5e1..faa0716 100644 --- a/lib/gitlab_keys.rb +++ b/lib/gitlab_keys.rb @@ -92,6 +92,6 @@ class GitlabKeys end def lock_file - @lock_file ||= File.join(ROOT_PATH, "authorized_keys.lock") + @lock_file ||= auth_file + '.lock' end end diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb index 2ef7241..773b0b6 100644 --- a/spec/gitlab_keys_spec.rb +++ b/spec/gitlab_keys_spec.rb @@ -96,7 +96,10 @@ describe GitlabKeys do end context "without file writing" do - before { Tempfile.stub(:open) } + before do + Tempfile.stub(:open) + gitlab_keys.stub(:lock).and_yield + end it "should log an rm-key event" do $logger.should_receive(:info).with('Removing key key-741') @@ -146,6 +149,10 @@ describe GitlabKeys do end describe :lock do + before do + GitlabKeys.any_instance.stub(lock_file: tmp_lock_file_path) + end + it "should raise exception if operation lasts more then timeout" do key = GitlabKeys.new expect do @@ -201,4 +208,8 @@ describe GitlabKeys do def tmp_authorized_keys_path File.join(ROOT_PATH, 'tmp', 'authorized_keys') end + + def tmp_lock_file_path + tmp_authorized_keys_path + '.lock' + end end |