winssh communicator: retain the authorized_keys file acl permissions
This commit is contained in:
parent
aeac480683
commit
4ab0dc19b1
|
@ -50,6 +50,7 @@ module VagrantPlugins
|
|||
end
|
||||
comm.upload(keys_file.path, remote_upload_path)
|
||||
keys_file.delete
|
||||
comm.execute("Set-Acl \"#{remote_upload_path}\" (Get-Acl \"#{remote_authkeys_path}\")", shell: "powershell")
|
||||
comm.execute("move /y \"#{remote_upload_path}\" \"#{remote_authkeys_path}\"", shell: "cmd")
|
||||
end
|
||||
|
||||
|
@ -75,6 +76,7 @@ module VagrantPlugins
|
|||
File.write(keys_file.path, current_content.join("\r\n") + "\r\n")
|
||||
comm.upload(keys_file.path, remote_upload_path)
|
||||
keys_file.delete
|
||||
comm.execute("Set-Acl \"#{remote_upload_path}\" (Get-Acl \"#{remote_authkeys_path}\")", shell: "powershell")
|
||||
comm.execute("move /y \"#{remote_upload_path}\" \"#{remote_authkeys_path}\"", shell: "cmd")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,6 +41,7 @@ describe "VagrantPlugins::GuestWindows::Cap::InsertPublicKey" do
|
|||
it "inserts the public key" do
|
||||
expect(comm).to receive(:download)
|
||||
expect(comm).to receive(:upload)
|
||||
expect(comm).to receive(:execute).with(/Set-Acl .*/, shell: "powershell")
|
||||
expect(comm).to receive(:execute).with(/move .*/, shell: "cmd")
|
||||
cap.insert_public_key(machine, "ssh-rsa ...")
|
||||
expect(File.read(@tempfile.path)).to include("ssh-rsa ...")
|
||||
|
@ -56,6 +57,7 @@ describe "VagrantPlugins::GuestWindows::Cap::InsertPublicKey" do
|
|||
it "inserts the public key" do
|
||||
expect(comm).to_not receive(:download)
|
||||
expect(comm).to receive(:upload)
|
||||
expect(comm).to receive(:execute).with(/Set-Acl .*/, shell: "powershell")
|
||||
expect(comm).to receive(:execute).with(/move .*/, shell: "cmd")
|
||||
cap.insert_public_key(machine, "ssh-rsa ...")
|
||||
expect(File.read(@tempfile.path)).to include("ssh-rsa ...")
|
||||
|
|
|
@ -47,6 +47,7 @@ describe "VagrantPlugins::GuestWindows::Cap::RemovePublicKey" do
|
|||
it "removes the public key" do
|
||||
expect(comm).to receive(:download)
|
||||
expect(comm).to receive(:upload)
|
||||
expect(comm).to receive(:execute).with(/Set-Acl .*/, shell: "powershell")
|
||||
expect(comm).to receive(:execute).with(/move .*/, shell: "cmd")
|
||||
cap.remove_public_key(machine, public_key_insecure)
|
||||
expect(File.read(@tempfile.path)).to include(public_key_other)
|
||||
|
@ -58,6 +59,7 @@ describe "VagrantPlugins::GuestWindows::Cap::RemovePublicKey" do
|
|||
it "does nothing" do
|
||||
expect(comm).to_not receive(:download)
|
||||
expect(comm).to_not receive(:upload)
|
||||
expect(comm).to_not receive(:execute).with(/Set-Acl .*/, shell: "powershell")
|
||||
expect(comm).to_not receive(:execute).with(/move .*/, shell: "cmd")
|
||||
cap.remove_public_key(machine, public_key_insecure)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue