Merge pull request #911 from squarelover/master
Don't raise an error if keyfile permissions are modified successfully
This commit is contained in:
commit
161885859a
|
@ -113,6 +113,7 @@ module Vagrant
|
||||||
@logger.info("Attempting to correct key permissions to 0600")
|
@logger.info("Attempting to correct key permissions to 0600")
|
||||||
File.chmod(0600, key_path)
|
File.chmod(0600, key_path)
|
||||||
|
|
||||||
|
stat = File.stat(key_path)
|
||||||
if Util::FileMode.from_octal(stat.mode) != "600"
|
if Util::FileMode.from_octal(stat.mode) != "600"
|
||||||
raise Errors::SSHKeyBadPermissions, :key_path => key_path
|
raise Errors::SSHKeyBadPermissions, :key_path => key_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
require File.expand_path("../../base", __FILE__)
|
||||||
|
|
||||||
|
describe Vagrant::SSH do
|
||||||
|
context "check_key_permissions" do
|
||||||
|
let(:key_path) { File.expand_path("../id_rsa", __FILE__) }
|
||||||
|
let(:ssh_instance) { Vagrant::SSH.new(double) }
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
File.open(key_path, 'w') do |file|
|
||||||
|
file.write("hello!")
|
||||||
|
end
|
||||||
|
File.chmod(644, key_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
after(:each) do
|
||||||
|
FileUtils.rm(key_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not raise an exception if we set a keyfile permission correctly" do
|
||||||
|
ssh_instance.check_key_permissions(key_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue