Use host capability to update key file permissions if available
This commit is contained in:
parent
5325000fa6
commit
5ba91de4d8
|
@ -194,17 +194,9 @@ module VagrantPlugins
|
||||||
f.write(priv)
|
f.write(priv)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adjust private key file permissions
|
# Adjust private key file permissions if host provides capability
|
||||||
if Vagrant::Util::Platform.windows?
|
if @machine.env.host.has_capability?(:set_ssh_key_permissions)
|
||||||
begin
|
@machine.env.host.capability(:set_ssh_key_permissions, @machine.data_dir.join("private_key"))
|
||||||
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
|
end
|
||||||
|
|
||||||
# Remove the old key if it exists
|
# Remove the old key if it exists
|
||||||
|
|
Loading…
Reference in New Issue