Always remove credentials file after mount attempts

This commit is contained in:
Chris Roberts 2017-12-14 12:31:43 -08:00
parent eae5230b5d
commit e85ef1655b
2 changed files with 24 additions and 14 deletions

View File

@ -46,7 +46,7 @@ SCRIPT
# Attempt to mount the folder. We retry here a few times because
# it can fail early on.
begin
retryable(on: Vagrant::Errors::LinuxMountFailed, tries: 10, sleep: 2) do
no_such_device = false
stderr = ""
@ -63,6 +63,11 @@ SCRIPT
output: stderr
end
end
ensure
# Always remove credentials file after mounting attempts
# have been completed
machine.communicate.sudo("rm /etc/smb_creds_#{name}")
end
emit_upstart_notification(machine, expanded_guest_path)
end

View File

@ -63,6 +63,11 @@ describe "VagrantPlugins::GuestLinux::Cap::MountSMBSharedFolder" do
cap.mount_smb_shared_folder(machine, mount_name, mount_guest_path, folder_options)
end
it "removes the credentials file before completion" do
expect(comm).to receive(:sudo).with(/rm.+smb_creds_.+/)
cap.mount_smb_shared_folder(machine, mount_name, mount_guest_path, folder_options)
end
it "sends upstart notification after mount" do
expect(comm).to receive(:sudo).with(/emit/)
cap.mount_smb_shared_folder(machine, mount_name, mount_guest_path, folder_options)