Merge pull request #9769 from chrisroberts/e-key-perms

Log error and proceed when private key permissions fail
This commit is contained in:
Chris Roberts 2018-05-03 12:34:50 -07:00 committed by GitHub
commit 40ae8aa38d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -196,8 +196,13 @@ module VagrantPlugins
# Adjust private key file permissions
if Vagrant::Util::Platform.windows?
priv_path = @machine.data_dir.join("private_key").to_s
File.set_permissions(priv_path, Etc.getlogin => File::FULL)
begin
priv_path = @machine.data_dir.join("private_key").to_s
File.set_permissions(priv_path, Etc.getlogin => File::FULL)
rescue => e
@logger.warn("Error encountered during private key permissions set - " \
"#{e.class}: #{e.message}")
end
else
@machine.data_dir.join("private_key").chmod(0600)
end

View File

@ -231,6 +231,10 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
expect(File).to receive(:set_permissions).with("PRIVATE_KEY_PATH", any_args)
end
it "should proceed when error is encountered" do
expect(File).to receive(:set_permissions).and_raise(StandardError)
end
context "with multiple permissions on file" do
it "should delete all non-owner permissions" do