Skip to content

Commit

Permalink
add sudo to readlink and test -e commands
Browse files Browse the repository at this point in the history
In b3eae35 and a4abb8a we added some attempt to resolve the
path of symbolic links and also a check to make sure a file path
exists before checking it. The commands we used for that don't run
privileged by default, which causes failures if you try to mount
under a directory owned by root.

Fixes #65
  • Loading branch information
dustymabe committed Dec 22, 2016
1 parent bdfdfa4 commit ba12edf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.sshfs_forward_is_folder_mounted(machine, opts)

# If the path doesn't exist at all in the machine then we
# can safely say it is not mounted
exists = machine.communicate.test("test -e #{guest_path}")
exists = machine.communicate.test("test -e #{guest_path}", sudo: true)
return false unless exists

# find the absolute path so that we can properly check if it is mounted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Cap
class SSHFSGetAbsolutePath
def self.sshfs_get_absolute_path(machine, path)
abs_path = ""
machine.communicate.execute("readlink -f #{path}") do |type, data|
machine.communicate.execute("readlink -f #{path}", sudo: true) do |type, data|
if type == :stdout
abs_path = data
end
Expand Down

0 comments on commit ba12edf

Please sign in to comment.