synced_folders/smb: use cred files [GH-4230]
This commit is contained in:
parent
1a541dc043
commit
601f7d41e5
|
@ -127,6 +127,8 @@ BUG FIXES:
|
|||
- push/heroku: use current branch [GH-6554]
|
||||
- synced\_folders/rsync: on Windows, replace all paths with Cygwin
|
||||
paths since all rsync implementations require this [GH-6160]
|
||||
- synced\_folders/smb: use credentials files to allow for more characters
|
||||
in password [GH-4230]
|
||||
|
||||
PLUGIN AUTHOR CHANGES:
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
module VagrantPlugins
|
||||
module GuestDebian
|
||||
module Cap
|
||||
class SMB
|
||||
def self.smb_install(machine)
|
||||
# Deb/Ubuntu require mount.cifs which doesn't come by default.
|
||||
machine.communicate.tap do |comm|
|
||||
if !comm.test("test -f /sbin/mount.cifs")
|
||||
machine.ui.detail(I18n.t("vagrant.guest_deb_installing_smb"))
|
||||
comm.sudo("apt-get -y update")
|
||||
comm.sudo("apt-get -y install cifs-utils")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -30,6 +30,11 @@ module VagrantPlugins
|
|||
require_relative "cap/rsync"
|
||||
Cap::RSync
|
||||
end
|
||||
|
||||
guest_capability("debian", "smb_install") do
|
||||
require_relative "cap/smb"
|
||||
Cap::SMB
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,17 +24,14 @@ module VagrantPlugins
|
|||
mount_gid = "`getent group #{options[:group]} | cut -d: -f3`"
|
||||
mount_gid_old = "`id -g #{options[:group]}`"
|
||||
end
|
||||
|
||||
smb_password = Shellwords.shellescape(options[:smb_password])
|
||||
|
||||
|
||||
# If a domain is provided in the username, separate it
|
||||
username, domain = (options[:smb_username] || '').split('@', 2)
|
||||
smb_password = options[:smb_password]
|
||||
|
||||
options[:mount_options] ||= []
|
||||
options[:mount_options] << "sec=ntlm"
|
||||
options[:mount_options] << "username=#{username}"
|
||||
options[:mount_options] << "password=#{smb_password}"
|
||||
options[:mount_options] << "domain=#{domain}" if domain
|
||||
options[:mount_options] << "credentials=/etc/smb_creds_#{name}"
|
||||
|
||||
# First mount command uses getent to get the group
|
||||
mount_options = "-o uid=#{mount_uid},gid=#{mount_gid}"
|
||||
|
@ -49,6 +46,16 @@ module VagrantPlugins
|
|||
# Create the guest path if it doesn't exist
|
||||
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
|
||||
|
||||
# Write the credentials file
|
||||
machine.communicate.sudo(<<-SCRIPT)
|
||||
cat <<EOF >/etc/smb_creds_#{name}
|
||||
username=#{username}
|
||||
password=#{smb_password}
|
||||
#{domain ? "domain=#{domain}" : ""}
|
||||
EOF
|
||||
chmod 0600 /etc/smb_creds_#{name}
|
||||
SCRIPT
|
||||
|
||||
# Attempt to mount the folder. We retry here a few times because
|
||||
# it can fail early on.
|
||||
attempts = 0
|
||||
|
|
|
@ -92,6 +92,11 @@ module VagrantPlugins
|
|||
guest: machine.guest.name.to_s
|
||||
end
|
||||
|
||||
# Setup if we have it
|
||||
if machine.guest.capability?(:smb_install)
|
||||
machine.guest.capability(:smb_install)
|
||||
end
|
||||
|
||||
# Detect the host IP for this guest if one wasn't specified
|
||||
# for every folder.
|
||||
host_ip = nil
|
||||
|
|
|
@ -160,6 +160,8 @@ en:
|
|||
description of what they do.
|
||||
|
||||
%{list}
|
||||
guest_deb_installing_smb: |-
|
||||
Installing SMB "mount.cifs"...
|
||||
global_status_footer: |-
|
||||
The above shows information about all known Vagrant environments
|
||||
on this machine. This data is cached and may not be completely
|
||||
|
|
Loading…
Reference in New Issue