Mount smb folders using mount options from cap
This commit is contained in:
parent
4738a105cc
commit
7e698b757d
@ -15,38 +15,21 @@ module VagrantPlugins
|
|||||||
|
|
||||||
mount_device = "//#{options[:smb_host]}/#{name}"
|
mount_device = "//#{options[:smb_host]}/#{name}"
|
||||||
|
|
||||||
mount_options = options.fetch(:mount_options, [])
|
mount_options, _, _ = options[:plugin].capability(
|
||||||
detected_ids = detect_owner_group_ids(machine, guestpath, mount_options, options)
|
:mount_options, name, expanded_guest_path, options)
|
||||||
mount_uid = detected_ids[:uid]
|
mount_type = options[:plugin].capability(:mount_type)
|
||||||
mount_gid = detected_ids[:gid]
|
|
||||||
|
|
||||||
# If a domain is provided in the username, separate it
|
# If a domain is provided in the username, separate it
|
||||||
username, domain = (options[:smb_username] || '').split('@', 2)
|
username, domain = (options[:smb_username] || '').split('@', 2)
|
||||||
smb_password = options[:smb_password]
|
smb_password = options[:smb_password]
|
||||||
# Ensure password is scrubbed
|
# Ensure password is scrubbed
|
||||||
Vagrant::Util::CredentialScrubber.sensitive(smb_password)
|
Vagrant::Util::CredentialScrubber.sensitive(smb_password)
|
||||||
|
|
||||||
mnt_opts = []
|
|
||||||
if machine.env.host.capability?(:smb_mount_options)
|
|
||||||
mnt_opts += machine.env.host.capability(:smb_mount_options)
|
|
||||||
else
|
|
||||||
mnt_opts << "sec=ntlmssp"
|
|
||||||
end
|
|
||||||
mnt_opts << "credentials=/etc/smb_creds_#{name}"
|
|
||||||
mnt_opts << "uid=#{mount_uid}"
|
|
||||||
mnt_opts << "gid=#{mount_gid}"
|
|
||||||
if !ENV['VAGRANT_DISABLE_SMBMFSYMLINKS']
|
|
||||||
mnt_opts << "mfsymlinks"
|
|
||||||
end
|
|
||||||
|
|
||||||
mnt_opts = merge_mount_options(mnt_opts, options[:mount_options] || [])
|
|
||||||
|
|
||||||
mount_options = "-o #{mnt_opts.join(",")}"
|
|
||||||
if mount_options.include?("mfsymlinks")
|
if mount_options.include?("mfsymlinks")
|
||||||
display_mfsymlinks_warning(machine.env)
|
display_mfsymlinks_warning(machine.env)
|
||||||
end
|
end
|
||||||
|
|
||||||
mount_command = "mount -t cifs #{mount_options} #{mount_device} #{expanded_guest_path}"
|
mount_command = "mount -t #{mount_type} -o #{mount_options} #{mount_device} #{expanded_guest_path}"
|
||||||
|
|
||||||
# Create the guest path if it doesn't exist
|
# Create the guest path if it doesn't exist
|
||||||
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
|
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
|
||||||
@ -82,7 +65,9 @@ SCRIPT
|
|||||||
ensure
|
ensure
|
||||||
# Always remove credentials file after mounting attempts
|
# Always remove credentials file after mounting attempts
|
||||||
# have been completed
|
# have been completed
|
||||||
machine.communicate.sudo("rm /etc/smb_creds_#{name}")
|
if !machine.config.vm.allow_fstab_modification
|
||||||
|
machine.communicate.sudo("rm /etc/smb_creds_#{name}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
emit_upstart_notification(machine, expanded_guest_path)
|
emit_upstart_notification(machine, expanded_guest_path)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user