pax_global_header00006660000000000000000000000064136001424650014513gustar00rootroot0000000000000052 comment=78559fbcd926efcdfb081d909d6316084a803613 vagrant-bindfs-1.1.5/000077500000000000000000000000001360014246500144245ustar00rootroot00000000000000vagrant-bindfs-1.1.5/.gitignore000066400000000000000000000001351360014246500164130ustar00rootroot00000000000000# Vagrant .vagrant/* # Bundler /.bundle /vendor/bundle Gemfile.lock # Rubygems *.gem pkg/ vagrant-bindfs-1.1.5/.rspec000066400000000000000000000000361360014246500155400ustar00rootroot00000000000000--color --require spec_helper vagrant-bindfs-1.1.5/.rubocop.yml000066400000000000000000000003451360014246500167000ustar00rootroot00000000000000--- require: - rubocop-performance AllCops: DisplayCopNames: true Layout/LineLength: Max: 150 Metrics/BlockLength: Exclude: - 'spec/**/*_spec.rb' Style/Documentation: Enabled: No Naming/FileName: Enabled: No vagrant-bindfs-1.1.5/Gemfile000066400000000000000000000020451360014246500157200ustar00rootroot00000000000000# frozen_string_literal: true source 'https://rubygems.org' # Du to some changes in bundler, specifying dependencies with the `gemspec` # keyword will trigger an error as `vagrant-bindfs` would then be declared # twice, once here and once in the :plugins group. # # To work around this issue, development dependencies should be added to # the :development group below instead of in `.gemspec` file. # # gemspec group :development do # We depend on Vagrant for development, but we don't add it as a # gem dependency because we expect to be installed within the # Vagrant environment itself using `vagrant plugin`. gem 'vagrant', git: 'https://github.com/hashicorp/vagrant.git' # Development dependencies gem 'rake' gem 'rspec', '~> 3.5.0' gem 'rubocop', require: false gem 'rubocop-performance', require: false end group :plugins do # `vagrant-bindfs` (and other plugins that it may depends on) must be # included in this :plugins group to get loaded at the correct position # while developing. gem 'vagrant-bindfs', path: '.' end vagrant-bindfs-1.1.5/MIT-LICENSE000066400000000000000000000020611360014246500160570ustar00rootroot00000000000000Copyright (c) 2010 Gaël-Ian Havard MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. vagrant-bindfs-1.1.5/README.md000066400000000000000000000222071360014246500157060ustar00rootroot00000000000000# vagrant-bindfs A Vagrant plugin to automate [bindfs](http://bindfs.org/) mounts in the VM. This allow you to change owner, group and permissions on files and, for example, work around NFS share permissions issues. ## Some Background: Why `vagrant-bindfs` The default vagrant provider is [virtualbox](https://www.virtualbox.org/). It's free and works well but has some [performance problems](http://snippets.aktagon.com/snippets/609-Slow-IO-performance-with-Vagrant-and-VirtualBox-). People often recommend switching to [vagrant's VMWare-fusion provider](http://www.vagrantup.com/vmware). This reportedly has better performance, but shares with symlinks [won't work](http://communities.vmware.com/thread/428199?start=0&tstart=0). You also have to buy both the plugin and VMware Fusion. The final recommendation, at least on Linux/OSX hosts, is to [use NFS](http://docs.vagrantup.com/v2/synced-folders/nfs.html). However, an NFS mount has the same numeric permissions in the guest as in the host. If you're on OSX, for instance, a folder owned by the default OSX user will appear to be [owned by `501:20`](https://groups.google.com/forum/?fromgroups#!topic/vagrant-up/qXXJ-AQuKQM) in the guest. This is where `vagrant-bindfs` comes in! Simply: - mount your share over NFS into a temporary location in the guest - re-mount the share to the actual destination with `vagrant-bindfs`, setting the correct permissions _Note that `map_uid` and `map_gid` NFS options can be used to set the identity used to read/write files on the host side._ ## Installation vagrant-bindfs is distributed as a Ruby gem. You can install it as any other Vagrant plugin with: ```bash vagrant plugin install vagrant-bindfs ``` ## Usage In your `Vagrantfile`, use `config.bindfs.bind_folder` to configure folders that will be bound on VM startup. The format is: ```ruby config.bindfs.bind_folder "/path/to/source", "/path/to/destination", options ``` By default, all folders are bound after folders syncing between host and guest machines. You can pass a special `:after` option to the bind_folder method to choose when a folder should be bound. Supported values are : * `:synced_folders` (default) * `:provision`, to bind a folder after provisioning occured. ### Example ```ruby Vagrant.configure("2") do |config| [...] # Your VM configuration ## Basic usage config.bindfs.bind_folder "source/dir", "mount/point" ## Advanced options config.bindfs.bind_folder "source/dir", "mount/point", perms: "u=rw:g=r:o=r", # http://bindfs.org/docs/bindfs.1.html#sect12 create_as_user: true ## Complete example for a NFS shared folder # Static IP is required to use NFS shared folder, # this is only required for Virtualbox provider config.vm.network "private_network", ip: "192.168.50.4" # Declare shared folder with Vagrant syntax config.vm.synced_folder "host/source/dir", "/vagrant-nfs", type: :nfs # Use vagrant-bindfs to re-mount folder config.bindfs.bind_folder "/vagrant-nfs", "guest/mount/point" # Bind a folder after provisioning config.bindfs.bind_folder "/vagrant-after-provision", "another/guest/mount/point", after: :provision end ``` Remember that Vagrant use `/vagrant` on guest side to automatically share your project directory (the one with the Vagrantfile), in particular for provisioning and configuration purposes. Binding a folder to `/vagrant` or one of its subfolders may expose unexpected behaviors. ### bindfs support The `bind_folder` config accept any option you can pass to bindfs. vagrant-bindfs is compatible with bindfs from version 1.9 to 1.14.2. Check [lib/vagrant-bindfs/bindfs/option_definitions.json](https://github.com/gael-ian/vagrant-bindfs/blob/master/lib/vagrant-bindfs/bindfs/option_definitions.json) for a complete list of supported options and default values and read the [bindfs man page](http://bindfs.org/docs/bindfs.1.html) for full documentation. Both long arguments and shorthand are supported. If you set both, shorthand will prevail. Long arguments can be written indifferently with underscore ('force_user') or dash ('force-user') and as strings ('force-user') or symbols (:force_user or :'force-user'). Option arguments values can be anything that can be casted to a string _via_ `to_s`. The plugin will try to detect flag arguments values as true or false from common notations. vagrant-bindfs detects installed version of bindfs, translates option names when needed and ignores an option if it is not supported. As we may have missed something, it will warn you when a binding command fail. On Debian (and Ubuntu), SUSE, Fedora, CentOS, Gentoo and OS X guest systems, vagrant-bindfs will try to install bindfs automatically if it is not installed. On other system, you'll get warned. OS X guests may need some specific options. See [bindfs README](https://github.com/mpartel/bindfs#os-x-note) for details. ## Configuration This plugin supports the following configuration options: ### `debug` Setting `config.bindfs.debug` to true will increase the verbosity level of this plugin in Vagrant output. ### `default_options` You can overwrite default bindfs options _via_ `config.bindfs.default_options=`. ```ruby Vagrant.configure("2") do |config| # These values are the default options config.bindfs.default_options = { force_user: 'vagrant', force_group: 'vagrant', perms: 'u=rwX:g=rD:o=rD' } end ``` ### `skip_validations` By default, `vagrant-bindfs` will check if the user and the group set for a bound folder exists on the virtual machine. If either one, the other or both of them are missing, it will warn you and not execute any bindfs command for this folder. To skip these validations, you can add `:user` and/or `:group` to the `config.bindfs.skip_validations` array. ```ruby Vagrant.configure("2") do |config| config.bindfs.skip_validations << :user end ``` ### `bindfs_version` and `install_bindfs_from_source` By default, if `bindfs` needs to be installed on the virtual machine, `vagrant-bindfs` will install the most recent release available in repositories (_via_ `homebrew` for OS X guests). If no version of `bindfs` is found, it will try to install the most recent supported version of `bindfs` from source. (See [lib/vagrant-bindfs/bindfs.rb](https://github.com/gael-ian/vagrant-bindfs/blob/master/lib/vagrant-bindfs/bindfs.rb#L4) for the exact version number). You can force the plugin to install the version of `bindfs` of your choice with the `bindfs_version` configuration option. It will then look for the specified version in repositories and install it if available. If not, it will install it from sources. You can also force installation from sources with the `install_bindfs_from_source` configuration option. This will skip any repositories look up. ```ruby Vagrant.configure("2") do |config| # This will force the plugin to install bindfs-1.12.2 from sources config.bindfs.bindfs_version = "1.12.2" config.bindfs.install_bindfs_from_source = true end ``` **This feature only works with exact version match and does not try to resolve dependencies.** In particular, Fuse will always be installed from the latest version available in repositories (_via_ Homebrew Cask for OS X guests). ### `force_empty_mountpoints` By default, `vagrant-bindfs` won't try to empty an existing mount point before mount. Hence, if you try to bind a folder to a non-empty directory without explicitly allowing Fuse to do so (with the `nonempty` Fuse option), mount will fail. You can ask `vagrant-bindfs` to make sure the mount points are empty with the `config.bindfs.force_empty_mountpoints` option. Mount poitns will then be destroyed (with `rm -rf`) prior to mount, unless you allow Fuse to not mind (with the `nonempty` Fuse option). ```ruby Vagrant.configure("2") do |config| config.bindfs.force_empty_mountpoint = true # This exemple assume two directories exist in your VM: # - `a/non/empty/mount/point/and/its/content` # - `another/non/empty/mount/point/and/its/content` # `a/non/empty/mount/point` will be destroyed before mount and # all its content will be lost. config.bindfs.bind_folder "/vagrant", "a/non/empty/mount/point" # `a/non/empty/mount/point` will not be destroyed before mount # but its content will not be accessible while in use by bindfs. config.bindfs.bind_folder "/vagrant", "a/non/empty/mount/point", o: :nonempty end ``` ## Contributing If you find this plugin useful, we could use a few enhancements! In particular, capabilities files for installing vagrant-bindfs on other systems would be useful. We could also use some more specs… ### How to Test Changes If you've made changes to this plugin, you can easily test it locally in Vagrant. Edit `Vagrantfile` and uncomment one or more of the selected test boxes. Then, from the root of the repo, do: bundle install bundle exec vagrant up This will spin up one or more VM and try to bindfs-mount some shares in it. Feel free to modify the included `Vagrantfile` or test helpers (in `test/test_helpers.rb`) to add additional boxes and test cases. If you add a new test machine, please ensure that it will stay available and regularly updated for future tests. We recommend to use [officialy supported boxes](https://goo.gl/LbkPVF). vagrant-bindfs-1.1.5/Rakefile000066400000000000000000000010061360014246500160660ustar00rootroot00000000000000# frozen_string_literal: true require 'rubygems' require 'bundler/setup' require 'rspec/core/rake_task' require 'rubocop/rake_task' # Immediately sync all stdout $stdout.sync = true $stderr.sync = true # Change to the directory of this file Dir.chdir(__dir__) # Installs the tasks for gem creation Bundler::GemHelper.install_tasks # Install the `spec` task so that we can run tests RSpec::Core::RakeTask.new # Add Rubocop tasks RuboCop::RakeTask.new # Default task is to run the unit tests task default: 'spec' vagrant-bindfs-1.1.5/Vagrantfile000066400000000000000000000027601360014246500166160ustar00rootroot00000000000000# frozen_string_literal: true # -*- mode: ruby -*- # vi: set ft=ruby : # Uncomment machines you want to test test_machines = { # debian: { box: "bento/debian-10" }, # ubuntu: { box: "bento/ubuntu-18.04" }, # fedora: { box: "bento/fedora-latest" }, # redhat: { box: "bento/centos-8" }, # gentoo: { box: "generic/gentoo" }, # The `vagrant` user group does not exist in this box. # suse: { box: "bento/opensuse-leap-15", args: { group: 'users' } }, # **This box require the Oracle VM VirtualBox Extension Pack for Virtualbox.** # The `vagrant` user group does not exist in this box. # osx: { box: "jhcook/osx-elcapitan-10.11", args: { group: 'staff' } }, # When you add a new test machine, please ensure that it will stay # available and regularly updated for future tests. We recommend to # use officialy supported boxes, as stated in the Vagrant # documentation. See https://goo.gl/LbkPVF } require File.expand_path('spec/vagrantfile_helper', __dir__) Vagrant.configure('2') do |config| # Common configuration config.vm.provider 'virtualbox' do |vb| vb.memory = 4096 vb.cpus = 2 end # For a more detailled output when you test, set this to true. config.bindfs.debug = false config.bindfs.force_empty_mountpoints = true test_machines.each do |distro, options| config.vm.define "vagrant-bindfs-test-#{distro}" do |machine| machine.vm.box = options[:box] tests_setup(machine, (options[:args] || {})) end end end vagrant-bindfs-1.1.5/lib/000077500000000000000000000000001360014246500151725ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs.rb000066400000000000000000000005711360014246500204270ustar00rootroot00000000000000# frozen_string_literal: true begin require 'vagrant' rescue LoadError raise 'The Vagrant bindfs plugin must be run within Vagrant' end module VagrantBindfs autoload :Vagrant, 'vagrant-bindfs/vagrant' autoload :Bindfs, 'vagrant-bindfs/bindfs' end I18n.load_path << File.expand_path('../locales/en.yml', __dir__) I18n.reload! require 'vagrant-bindfs/vagrant/plugin' vagrant-bindfs-1.1.5/lib/vagrant-bindfs/000077500000000000000000000000001360014246500200775ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs.rb000066400000000000000000000021161360014246500216710ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Bindfs SOURCE_VERSION = '1.14.2' SOURCE_URLS = [ 'https://bindfs.org/downloads/%s.tar.gz', 'https://bindfs.dy.fi/downloads/%s.tar.gz' ].freeze autoload :Command, 'vagrant-bindfs/bindfs/command' autoload :Folder, 'vagrant-bindfs/bindfs/folder' autoload :OptionSet, 'vagrant-bindfs/bindfs/option_set' autoload :Validators, 'vagrant-bindfs/bindfs/validators' class << self FULL_VERSION_NUMBER_SINCE = '1.13.0' def source_tar_basename(version) ['bindfs', normalize_version_in_tar_name(version)].join('-') end def source_tar_urls(version) SOURCE_URLS.map { |url| format(url, basename: source_tar_basename(version)) } end def normalize_version_in_tar_name(version) v = version.to_s.strip parts = (v.split('.').map(&:to_i) + [0, 0, 0]).take(3).compact parts.pop if parts.last.zero? && Gem::Version.new(v) < Gem::Version.new(FULL_VERSION_NUMBER_SINCE) parts.join('.') end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/000077500000000000000000000000001360014246500213445ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/command.rb000066400000000000000000000030151360014246500233060ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Bindfs class Command attr_reader :folder def initialize(folder) @folder = folder end def to_s(bindfs_command = 'bindfs') [bindfs_command, arguments_for(folder.options).join(' '), folder.source, folder.destination].compact.join(' ') end protected def arguments_for(options) options.each_with_object([]) do |(name, value), args| args << format_argument(name, value) unless value.nil? args end.compact end def format_argument(name, value) send("format_#{argument_type(name)}", name, value) end def format_flag(name, value) return unless value compatible_name = argument_compatible_name(name) (argument_shorthand_only?(name) ? "-#{compatible_name}" : "--#{compatible_name}") end def format_option(name, value) compatible_name = argument_compatible_name(name) (argument_shorthand_only?(name) ? "-#{compatible_name} #{value}" : "--#{compatible_name}=#{value}") end def argument_type(name) argument_definition(name)['type'] end def argument_shorthand_only?(name) argument_definition(name)['long'].empty? end def argument_definition(name) Bindfs::OptionSet.bindfs_options[name] end def argument_compatible_name(name) Bindfs::OptionSet.compatible_name_for_version(name, @folder.options.version) end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/folder.rb000066400000000000000000000014501360014246500231440ustar00rootroot00000000000000# frozen_string_literal: true require 'digest/sha1' module VagrantBindfs module Bindfs class Folder attr_reader :source attr_reader :destination attr_reader :options attr_reader :hook def initialize(hook, source, destination, options = {}) @hook = hook @source = source @destination = destination @options = Bindfs::OptionSet.new(nil, options) end def id @id ||= Digest::SHA1.new.digest(destination) end def reverse_merge!(options) @options = Bindfs::OptionSet.new(nil, options).merge(@options) end def merge!(options) @options = @options.merge(options) end def to_version!(version) @options = @options.to_version(version) end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/option_definitions.json000066400000000000000000000143441360014246500261500ustar00rootroot00000000000000// TODO: Update after each bindfs release { // "File" ownership "force-user": { "long": ["force-user", "user", "owner"], "short": ["u"], "type": "option", "since": "0.0.1" }, "force-group": { "long": ["force-group", "group"], "short": ["g"], "type": "option", "since": "0.0.1" }, "perms": { "long": ["perms"], "short": ["p"], "type": "option", "since": "0.0.1" }, "mirror": { "long": ["mirror"], "short": ["m"], "type": "option", "since": "0.0.1" }, "mirror-only": { "long": ["mirror-only"], "short": ["M"], "type": "option", "since": "0.0.1" }, "map": { "long": ["map"], "short": [], "type": "option", "since": "1.10" }, "uid-offset": { "long": ["uid-offset"], "short": [], "type": "option", "since": "1.13.2" }, "gid-offset": { "long": ["gid-offset"], "short": [], "type": "option", "since": "1.13.2" }, // File creation policy "create-as-user": { "long": ["create-as-user"], "short": [], "type": "flag", "since": "0.0.1" }, "create-as-mounter": { "long": ["create-as-mounter"], "short": [], "type": "flag", "since": "0.0.1" }, "create-for-user": { "long": ["create-for-user"], "short": [], "type": "option", "since": "0.0.1" }, "create-for-group": { "long": ["create-for-group"], "short": [], "type": "option", "since": "0.0.1" }, "create-with-perms": { "long": ["create-with-perms"], "short": [], "type": "option", "since": "0.0.1" }, // Chown policy "chown-normal": { "long": ["chown-normal"], "short": [], "type": "flag", "since": "0.0.1" }, "chown-ignore": { "long": ["chown-ignore"], "short": [], "type": "flag", "since": "0.0.1" }, "chown-deny": { "long": ["chown-deny"], "short": [], "type": "flag", "since": "0.0.1" }, // Chgrp policy "chgrp-normal": { "long": ["chgrp-normal"], "short": [], "type": "flag", "since": "0.0.1" }, "chgrp-ignore": { "long": ["chgrp-ignore"], "short": [], "type": "flag", "since": "0.0.1" }, "chgrp-deny": { "long": ["chgrp-deny"], "short": [], "type": "flag", "since": "0.0.1" }, // Chmod policy "chmod-normal": { "long": ["chmod-normal"], "short": [], "type": "flag", "since": "0.0.1" }, "chmod-ignore": { "long": ["chmod-ignore"], "short": [], "type": "flag", "since": "0.0.1" }, "chmod-deny": { "long": ["chmod-deny"], "short": [], "type": "flag", "since": "0.0.1" }, "chmod-filter": { "long": ["chmod-filter"], "short": [], "type": "option", "since": "1.12.2" }, "chmod-allow-x": { "long": ["chmod-allow-x"], "short": [], "type": "flag", "since": "0.0.1" }, // Extended attribute policy "xattr-none": { "long": ["xattr-none"], "short": [], "type": "flag", "since": "0.0.1" }, "xattr-ro": { "long": ["xattr-ro"], "short": [], "type": "flag", "since": "0.0.1" }, "xattr-rw": { "long": ["xattr-rw"], "short": [], "type": "flag", "since": "0.0.1" }, // Other file operations "delete-deny": { "long": ["delete-deny"], "short": [], "type": "flag", "since": "1.13.9" }, "rename-deny": { "long": ["rename-deny"], "short": [], "type": "flag", "since": "1.13.9" }, // Rate limits "read-rate": { "long": ["read-rate"], "short": [], "type": "option", "since": "1.12.6" }, "write-rate": { "long": ["write-rate"], "short": [], "type": "option", "since": "1.12.6" }, // Link handling "hide-hard-links": { "long": ["hide-hard-links"], "short": [], "type": "flag", "since": "1.10" }, "resolve-symlinks": { "long": ["resolve-symlinks"], "short": [], "type": "flag", "since": "1.13.0" }, "resolve-symlink-policy": { "long": ["resolve-symlink-policy"], "short": [], "type": "option", "since": "1.13.0" }, // Multithreading "multithreaded": { "long": ["multithreaded"], "short": [], "type": "flag", "since": "1.11" }, "enable-lock-forwarding": { "long": ["enable-lock-forwarding"], "short": [], "type": "flag", "since": "1.13.2" }, "disable-lock-forwarding": { "long": ["disable-lock-forwarding"], "short": [], "type": "flag", "since": "1.13.2" }, // Miscellaneous "no-allow-other": { "long": ["no-allow-other"], "short": ["n"], "type": "flag", "since": "0.0.1" }, "realistic-permissions": { "long": ["realistic-permissions"], "short": [], "type": "flag", "since": "1.10" }, "ctime-from-mtime": { "long": ["ctime-from-mtime"], "short": [], "type": "flag", "since": "0.0.1" }, "enabe-ioctl": { "long": ["enable-ioctl"], "short": [], "type": "flag", "since": "1.13.2" }, "block-devices-as-files": { "long": ["block-devices-as-files"], "short": [], "type": "flag", "since": "1.13.7" }, "forward-odirect": { "long": ["forward-odirect"], "short": [], "type": "option", "since": "1.14.0" }, // FUSE options "o": { "long": [], "short": ["o"], "type": "option", "since": "0.0.1" }, "r": { "long": [], "short": ["r"], "type": "flag", "since": "0.0.1" }, "d": { "long": [], "short": ["d"], "type": "flag", "since": "0.0.1" }, "f": { "long": [], "short": ["f"], "type": "flag", "since": "0.0.1" } } vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/option_set.rb000066400000000000000000000100261360014246500240530ustar00rootroot00000000000000# frozen_string_literal: true require 'forwardable' module VagrantBindfs module Bindfs class OptionSet attr_reader :version attr_reader :options attr_reader :invalid_options attr_reader :unsupported_options include ::Enumerable extend ::Forwardable def_delegators :@options, :each, :[], :keys, :key? def initialize(version = nil, options = {}) @version = version @options = normalize_option_names(options) @invalid_options = {} @unsupported_options = {} extract_invalid_options! extract_unsupported_options! cast_option_values! end def merge!(other) other = other.to_version(version) if other.respond_to?(:to_version) @options.merge!(normalize_option_names(other)) extract_invalid_options! extract_unsupported_options! cast_option_values! end def merge(other) dup.tap { |result| result.merge!(other) } end def to_version(new_version) self.class.new(new_version, @options.merge(invalid_options).merge(unsupported_options)) end protected def normalize_option_names(options) options.each_with_object({}) do |(key, value), normalized| normalized_key = key.to_s.tr('_', '-') canonical_name = canonical_option_name(normalized_key) raise VagrantBindfs::Vagrant::ConfigError.new(:conflicting_options, name: canonical_name) \ if normalized.key?(canonical_name) normalized[canonical_name] = value normalized end end def canonical_option_name(option_name) self.class.bindfs_options.each do |name, definition| return name if definition['short'].include?(option_name) return name if definition['long'].include?(option_name) end option_name end def extract_invalid_options! extract_options_by_names!(options.keys - self.class.bindfs_options.keys, @invalid_options) end def extract_unsupported_options! extract_options_by_names!(options.keys - self.class.supported_options(version).keys, @unsupported_options) end def extract_options_by_names!(names, to) return {} if names.empty? names.each { |name| to[name] = @options.delete(name) } end def cast_option_values! @options = options.each_with_object({}) do |(key, value), normalized| normalized[key] = case self.class.bindfs_options[key]['type'] when 'option' then cast_value_as_option(value) when 'flag' then cast_value_as_flag(value) end normalized end end def cast_value_as_option(value) return nil if value.respond_to?(:nil?) && value.nil? (value.respond_to?(:to_s) ? value.to_s : value) end def cast_value_as_flag(value) return true if [true, 'true', 'True', 'yes', 'Yes', 'y', 'Y', 'on', 'On', 1].include?(value) return false if [false, 'false', 'False', 'no', 'No', 'n', 'N', 'off', 'Off', 0].include?(value) !!value # rubocop:disable Style/DoubleNegation end class << self def bindfs_options @bindfs_options ||= JSON.parse(File.read(File.expand_path('option_definitions.json', __dir__))) end def supported_options(version) bindfs_options.each_with_object({}) do |(name, definition), supported| supported[name] = definition if version.nil? || !version_lower_than(version, definition['since']) supported end end def compatible_name_for_version(option_name, version) return 'user' if option_name == 'force-user' && version_lower_than(version, '1.12') return 'group' if option_name == 'force-group' && version_lower_than(version, '1.12') option_name end protected def version_lower_than(version, target) Gem::Version.new(version) < Gem::Version.new(target) end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/validators.rb000066400000000000000000000003621360014246500240420ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Bindfs module Validators autoload :Config, 'vagrant-bindfs/bindfs/validators/config' autoload :Runtime, 'vagrant-bindfs/bindfs/validators/runtime' end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/validators/000077500000000000000000000000001360014246500235145ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/validators/config.rb000066400000000000000000000026341360014246500253130ustar00rootroot00000000000000# frozen_string_literal: true require 'forwardable' module VagrantBindfs module Bindfs module Validators class Config attr_reader :folder attr_reader :errors extend ::Forwardable def_delegators :@folder, :source, :destination, :options def initialize(folder) @folder = folder @errors = [] end def valid? @errors = [] validate_source! validate_destination! validate_options! @errors.empty? end protected def validate_source! @errors << I18n.t('vagrant-bindfs.validations.source_path_required') if source.empty? @errors << I18n.t('vagrant-bindfs.validations.path_must_be_absolute', path: source) if relative_path?(source) end def validate_destination! @errors << I18n.t('vagrant-bindfs.validations.destination_path_required') if destination.empty? @errors << I18n.t('vagrant-bindfs.validations.path_must_be_absolute', path: destination) if relative_path?(destination) end def validate_options! folder.options.invalid_options.keys.each do |option_name| @errors << I18n.t(option_name.tr('-', '_'), scope: 'vagrant-bindfs.deprecations') end end def relative_path?(path) Pathname.new(path).relative? end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/bindfs/validators/runtime.rb000066400000000000000000000031651360014246500255310ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Bindfs module Validators class Runtime < Config attr_reader :machine def initialize(folder, machine) super(folder) @machine = machine end protected def validate_source! super @errors << I18n.t('vagrant-bindfs.validations.source_path_does_not_exist', path: source) unless directory_exists?(source) end def validate_destination! super @errors << I18n.t('vagrant-bindfs.validations.destination_already_mounted', dest: destination) if mount_exists?(destination) end def validate_options! super validate_user validate_group end def directory_exists?(path) machine.guest.capability(:bindfs_exists_directory, path) end def mount_exists?(path) machine.guest.capability(:bindfs_exists_mount, path) end def validate_user return if machine.config.bindfs.skip_validations.include?(:user) return if machine.guest.capability(:bindfs_exists_user, options['force-user']) @errors << I18n.t('vagrant-bindfs.validations.user_does_not_exist', user: options['force-user']) end def validate_group return if machine.config.bindfs.skip_validations.include?(:group) return if machine.guest.capability(:bindfs_exists_group, options['force-group']) @errors << I18n.t('vagrant-bindfs.validations.group_does_not_exist', group: options['force-group']) end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant.rb000066400000000000000000000006461360014246500220740ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant autoload :Plugin, 'vagrant-bindfs/vagrant/plugin' autoload :Config, 'vagrant-bindfs/vagrant/config' autoload :Capabilities, 'vagrant-bindfs/vagrant/capabilities' autoload :Actions, 'vagrant-bindfs/vagrant/actions' autoload :Error, 'vagrant-bindfs/vagrant/errors' autoload :ConfigError, 'vagrant-bindfs/vagrant/errors' end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/000077500000000000000000000000001360014246500215415ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions.rb000066400000000000000000000004671360014246500235350ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Actions autoload :Installer, 'vagrant-bindfs/vagrant/actions/installer' autoload :Mounter, 'vagrant-bindfs/vagrant/actions/mounter' autoload :Concerns, 'vagrant-bindfs/vagrant/actions/concerns' end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions/000077500000000000000000000000001360014246500232015ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions/concerns.rb000066400000000000000000000004341360014246500253410ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Actions module Concerns autoload :Log, 'vagrant-bindfs/vagrant/actions/concerns/log' autoload :Machine, 'vagrant-bindfs/vagrant/actions/concerns/machine' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions/concerns/000077500000000000000000000000001360014246500250135ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions/concerns/log.rb000066400000000000000000000011631360014246500261220ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Actions module Concerns module Log def logger env[:ui] end def debug(message) logger.detail(message) if config.debug end def detail(message) logger.detail(message) end def info(message) logger.info message end def warn(message) logger.warn message end def error(message) logger.error message end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions/concerns/machine.rb000066400000000000000000000012321360014246500267420ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Actions module Concerns module Machine def machine env[:machine] end def config machine.config.bindfs end def bound_folders(hook = nil) @bound_folders ||= begin config.bound_folders.each_with_object({}) do |(id, folder), bound| bound[id] = folder if hook.nil? || folder.hook == hook bound end end end def guest machine.guest end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions/installer.rb000066400000000000000000000073221360014246500255270ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Actions class Installer attr_reader :app attr_reader :env include Concerns::Machine include Concerns::Log def initialize(app, env) @app = app @env = env end def call(env) @app.call(env) apply!(env) end protected def apply!(_env) return if bound_folders.empty? ensure_guest_is_ready_to_bind! end def ensure_guest_is_ready_to_bind! info(I18n.t('vagrant-bindfs.actions.installer.start')) ensure_package_manager_is_installed! ensure_fuse_is_installed! ensure_fuse_is_loaded! ensure_bindfs_is_installed! info(I18n.t('vagrant-bindfs.actions.installer.end')) end def ensure_package_manager_is_installed! unless guest.capability(:bindfs_package_manager_installed) warn(I18n.t('vagrant-bindfs.actions.package_manager.not_installed')) guest.capability(:bindfs_package_manager_install) end detail(I18n.t('vagrant-bindfs.actions.package_manager.installed', name: guest.capability(:bindfs_package_manager_name))) end def ensure_fuse_is_installed! unless guest.capability(:bindfs_fuse_installed) warn(I18n.t('vagrant-bindfs.actions.fuse.not_installed')) guest.capability(:bindfs_fuse_install) end detail(I18n.t('vagrant-bindfs.actions.fuse.installed')) end def ensure_fuse_is_loaded! unless guest.capability(:bindfs_fuse_loaded) warn(I18n.t('vagrant-bindfs.actions.fuse.not_loaded')) guest.capability(:bindfs_fuse_load) end detail(I18n.t('vagrant-bindfs.actions.fuse.loaded')) end def ensure_bindfs_is_installed! unless guest.capability(:bindfs_bindfs_installed) warn(I18n.t('vagrant-bindfs.actions.bindfs.not_installed')) install_bindfs! end detail(I18n.t('vagrant-bindfs.actions.bindfs.detected', version: guest.capability(:bindfs_bindfs_version))) end def install_bindfs! return install_bindfs_from_source! if install_from_source? return install_bindfs_from_repositories! if install_from_repositories? warn(I18n.t('vagrant-bindfs.actions.bindfs.not_found_in_repository', version: config.bindfs_version)) install_bindfs_from_source! end def install_bindfs_from_repositories! return guest.capability(:bindfs_bindfs_install) if install_latest_from_repositories? guest.capability(:bindfs_bindfs_install_version, config.bindfs_version) end def install_bindfs_from_source! version = (config.bindfs_version == :latest ? VagrantBindfs::Bindfs::SOURCE_VERSION : config.bindfs_version.to_s) guest.capability(:bindfs_bindfs_install_compilation_requirements) guest.capability(:bindfs_bindfs_install_from_source, version) end def install_from_source? config.install_bindfs_from_source end def install_from_repositories? install_latest_from_repositories? || install_version_from_repositories? end def install_latest_from_repositories? config.bindfs_version == :latest && guest.capability(:bindfs_bindfs_search) end def install_version_from_repositories? config.bindfs_version != :latest && guest.capability(:bindfs_bindfs_search_version, config.bindfs_version) end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/actions/mounter.rb000066400000000000000000000054751360014246500252320ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Actions class Mounter attr_reader :app attr_reader :env attr_reader :hook include Concerns::Machine include Concerns::Log def initialize(app, env, hook) @app = app @env = env @hook = hook end def call(env) app.call(env) return if bound_folders(hook).empty? bind_folders! end protected def bind_folders! info I18n.t('vagrant-bindfs.actions.mounter.start', hook: hook) bound_folders(hook).each_value do |folder| bind_folder!(folder) end end def bind_folder!(folder) folder.reverse_merge!(config.default_options) folder.to_version!(bindfs_version) return unless valid_folder?(folder) machine.communicate.tap do |comm| empty_mountpoint!(comm, folder) if empty_mountpoint?(folder) ensure_mountpoint_exists!(comm, folder) execute_bind_command!(comm, folder) end end def valid_folder?(folder) validator = VagrantBindfs::Bindfs::Validators::Runtime.new(folder, machine) return true if validator.valid? error I18n.t( 'vagrant-bindfs.validations.errors_found', dest: folder.destination, source: folder.source, errors: validator.errors.join(' ') ) false end def empty_mountpoint?(folder) return false unless config.force_empty_mountpoints return false if folder.options.key?('o') && !folder.options['o'].match(/nonempty/).nil? true end def empty_mountpoint!(comm, folder) detail I18n.t( 'vagrant-bindfs.actions.mounter.force_empty_mountpoints', dest: folder.destination ) comm.sudo("rm -rf #{folder.destination}") end def ensure_mountpoint_exists!(comm, folder) comm.sudo("mkdir -p #{folder.destination}") end def execute_bind_command!(comm, folder) detail I18n.t( 'vagrant-bindfs.actions.mounter.entry', dest: folder.destination, source: folder.source ) command = VagrantBindfs::Bindfs::Command.new(folder) comm.sudo(command.to_s(bindfs_full_path), error_class: VagrantBindfs::Vagrant::Error, error_key: 'bindfs.mount_failed') debug(command.to_s(bindfs_full_path)) end def bindfs_version @bindfs_version ||= guest.capability(:bindfs_bindfs_version) end def bindfs_full_path @bindfs_full_path ||= guest.capability(:bindfs_bindfs_full_path) end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities.json000066400000000000000000000060201360014246500250630ustar00rootroot00000000000000{ // System checks "bindfs_exists_user": { "darwin": "Darwin::SystemChecks", "linux": "Linux::SystemChecks" }, "bindfs_exists_group": { "darwin": "Darwin::SystemChecks", "linux": "Linux::SystemChecks" }, "bindfs_exists_directory": { "darwin": "All::SystemChecks", "linux": "All::SystemChecks" }, "bindfs_exists_mount": { "darwin": "All::SystemChecks", "linux": "All::SystemChecks" }, // Package manager "bindfs_package_manager_name": { "darwin": "Darwin::PackageManager", "debian": "Debian::PackageManager", "gentoo": "Gentoo::PackageManager", "redhat": "RedHat::PackageManager", "suse": "Suse::PackageManager" }, "bindfs_package_manager_installed": { "darwin": "All::PackageManager", "linux": "All::PackageManager" }, "bindfs_package_manager_install": { "darwin": "Darwin::PackageManager", "linux": "Linux::PackageManager" }, "bindfs_package_manager_update": { "darwin": "Darwin::PackageManager", "debian": "Debian::PackageManager", "gentoo": "Gentoo::PackageManager", "redhat": "RedHat::PackageManager", "suse": "Suse::PackageManager" }, // Fuse "bindfs_fuse_installed": { "darwin": "Darwin::Fuse", "linux": "Linux::Fuse" }, "bindfs_fuse_install": { "darwin": "Darwin::Fuse", "debian": "Debian::Fuse", "gentoo": "Gentoo::Fuse", "redhat": "RedHat::Fuse", "suse": "Suse::Fuse" }, "bindfs_fuse_loaded": { "darwin": "Darwin::Fuse", "linux": "Linux::Fuse", "ubuntu": "Ubuntu::Fuse" }, "bindfs_fuse_load": { "darwin": "Darwin::Fuse", "linux": "Linux::Fuse", "ubuntu": "Ubuntu::Fuse" }, // Bindfs "bindfs_bindfs_full_path": { "darwin": "All::Bindfs", "linux": "All::Bindfs" }, "bindfs_bindfs_installed": { "darwin": "All::Bindfs", "linux": "All::Bindfs" }, "bindfs_bindfs_version": { "darwin": "All::Bindfs", "linux": "All::Bindfs" }, "bindfs_bindfs_search": { "darwin": "Darwin::Bindfs", "debian": "Debian::Bindfs", "gentoo": "Gentoo::Bindfs", "redhat": "RedHat::Bindfs", "suse": "Suse::Bindfs" }, "bindfs_bindfs_install": { "darwin": "Darwin::Bindfs", "debian": "Debian::Bindfs", "gentoo": "Gentoo::Bindfs", "redhat": "RedHat::Bindfs", "suse": "Suse::Bindfs" }, "bindfs_bindfs_search_version": { "darwin": "Darwin::Bindfs", "debian": "Debian::Bindfs", "gentoo": "Gentoo::Bindfs", "redhat": "RedHat::Bindfs", "suse": "Suse::Bindfs" }, "bindfs_bindfs_install_version": { "darwin": "Darwin::Bindfs", "debian": "Debian::Bindfs", "gentoo": "Gentoo::Bindfs", "redhat": "RedHat::Bindfs", "suse": "Suse::Bindfs" }, "bindfs_bindfs_install_compilation_requirements": { "darwin": "Darwin::Bindfs", "debian": "Debian::Bindfs", "gentoo": "Gentoo::Bindfs", "redhat": "RedHat::Bindfs", "suse": "Suse::Bindfs" }, "bindfs_bindfs_install_from_source": { "darwin": "All::Bindfs", "linux": "All::Bindfs" } } vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities.rb000066400000000000000000000023101360014246500245130ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities autoload :All, 'vagrant-bindfs/vagrant/capabilities/all' autoload :Darwin, 'vagrant-bindfs/vagrant/capabilities/darwin' autoload :Linux, 'vagrant-bindfs/vagrant/capabilities/linux' autoload :Debian, 'vagrant-bindfs/vagrant/capabilities/debian' autoload :Ubuntu, 'vagrant-bindfs/vagrant/capabilities/ubuntu' autoload :Gentoo, 'vagrant-bindfs/vagrant/capabilities/gentoo' autoload :RedHat, 'vagrant-bindfs/vagrant/capabilities/redhat' autoload :Suse, 'vagrant-bindfs/vagrant/capabilities/suse' class << self def included(base) capabilities = JSON.parse(File.read(File.expand_path('capabilities.json', __dir__))) capabilities.each do |cap_name, oses| oses.each do |os_name, module_name| mod = module_by_name(module_name) base.guest_capability(os_name.to_s, cap_name.to_s) { mod } end end end def module_by_name(camel_cased_word) camel_cased_word.split('::').inject(self) { |constant, name| constant.const_get(name) } end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/000077500000000000000000000000001360014246500241725ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/all.rb000066400000000000000000000006111360014246500252650ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module All autoload :SystemChecks, 'vagrant-bindfs/vagrant/capabilities/all/system_checks' autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/all/package_manager' autoload :Bindfs, 'vagrant-bindfs/vagrant/capabilities/all/bindfs' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/all/000077500000000000000000000000001360014246500247425ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/all/bindfs.rb000066400000000000000000000047151360014246500265430ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module All module Bindfs class << self def bindfs_bindfs_full_path(machine) machine.communicate.execute('bash -c "type -P bindfs || true"') do |_, output| path = output.strip return path unless path.empty? end 'bindfs' end def bindfs_bindfs_installed(machine) bindfs_full_path = machine.guest.capability(:bindfs_bindfs_full_path) machine.communicate.test("#{bindfs_full_path} --help") end def bindfs_bindfs_version(machine) bindfs_full_path = machine.guest.capability(:bindfs_bindfs_full_path) [%(sudo #{bindfs_full_path} --version | cut -d" " -f2), %(sudo -i #{bindfs_full_path} --version | cut -d" " -f2)].each do |command| machine.communicate.execute(command) do |_, output| version = output.strip return Gem::Version.new(version) if !version.empty? && Gem::Version.correct?(version) end end Gem::Version.new('0.0') end def bindfs_bindfs_install_from_source(machine, version) tar_urls = VagrantBindfs::Bindfs.source_tar_urls(version) tar_dirname = VagrantBindfs::Bindfs.source_tar_basename(version) begin machine.communicate.execute format(INSTALL_SCRIPT, urls: tar_urls.join('" "'), dirname: tar_dirname) ensure machine.communicate.execute('([ -f ./bindfs.tar.gz ] && rm ./bindfs.tar.gz) || true') machine.communicate.execute("([ -d ./#{tar_dirname} ] && rm -rf ./#{tar_dirname}) || true") end end INSTALL_SCRIPT = <<-SHELL for u in "%s"; do if wget -q --spider $u; then url=$u; break; fi; done; [ -n "$url" ] && \ wget $url -O bindfs.tar.gz && \ tar -zxvf bindfs.tar.gz && \ [ -d ./%s ] && \ cd %s && \ ./configure && \ make && \ sudo make install SHELL end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/all/package_manager.rb000066400000000000000000000007111360014246500303530ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module All module PackageManager class << self def bindfs_package_manager_installed(machine) package_manager_name = machine.guest.capability(:bindfs_package_manager_name) machine.communicate.test("#{package_manager_name} --help") end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/all/system_checks.rb000066400000000000000000000010311360014246500301260ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module All module SystemChecks class << self def bindfs_exists_directory(machine, directory) machine.communicate.test("test -d #{directory.shellescape}") end def bindfs_exists_mount(machine, directory) machine.communicate.test("mount | grep '^bindfs' | grep #{directory.shellescape}") end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/darwin.rb000066400000000000000000000007371360014246500260120ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Darwin autoload :SystemChecks, 'vagrant-bindfs/vagrant/capabilities/darwin/system_checks' autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/darwin/package_manager' autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/darwin/fuse' autoload :Bindfs, 'vagrant-bindfs/vagrant/capabilities/darwin/bindfs' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/darwin/000077500000000000000000000000001360014246500254565ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/darwin/bindfs.rb000066400000000000000000000022601360014246500272500ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Darwin module Bindfs class << self # Homebrew only use its own github repositories def bindfs_bindfs_search(_machine) true end def bindfs_bindfs_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.execute('brew install homebrew/fuse/bindfs') end # Homebrew does not provide any method to install # an older version of a formula def bindfs_bindfs_search_version(_machine, _version) false end def bindfs_bindfs_install_version(machine) # Pass end # Homebrew requires the development tools to be installed def bindfs_bindfs_install_compilation_requirements(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.execute('brew install autoconf automake libtool pkg-config wget') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/darwin/fuse.rb000066400000000000000000000016431360014246500267510ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Darwin module Fuse class << self def bindfs_fuse_installed(machine) machine.communicate.test('test -d /Library/Frameworks/OSXFUSE.framework/') end def bindfs_fuse_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.execute('brew tap caskroom/cask && brew cask install osxfuse') end # OSXFuse is automatically loaded. # Just check if it is installed def bindfs_fuse_loaded(machine) machine.guest.capability(:bindfs_fuse_installed) end def bindfs_fuse_load(machine) machine.guest.capability(:bindfs_fuse_installed) end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/darwin/package_manager.rb000066400000000000000000000012221360014246500310650ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Darwin module PackageManager class << self def bindfs_package_manager_name(_machine) 'brew' end def bindfs_package_manager_install(machine) machine.communicate.execute('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"') end def bindfs_package_manager_update(machine) machine.communicate.execute('brew update') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/darwin/system_checks.rb000066400000000000000000000012711360014246500306500ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Darwin module SystemChecks class << self def bindfs_exists_user(machine, user) ( user.nil? || \ machine.communicate.test("test -n \"$(dscacheutil -q user -a name #{user.shellescape})\"") ) end def bindfs_exists_group(machine, group) ( group.nil? || \ machine.communicate.test("test -n \"$(dscacheutil -q group -a name #{group.shellescape})\"") ) end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/debian.rb000066400000000000000000000006041360014246500257410ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Debian autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/debian/package_manager' autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/debian/fuse' autoload :Bindfs, 'vagrant-bindfs/vagrant/capabilities/debian/bindfs' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/debian/000077500000000000000000000000001360014246500254145ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/debian/bindfs.rb000066400000000000000000000036461360014246500272170ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Debian module Bindfs class << self def bindfs_bindfs_search(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.test('[[ $(sudo apt-cache search bindfs | egrep "^bindfs - " | wc -l) != 0 ]]') end def bindfs_bindfs_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('apt-get install -y bindfs') end def bindfs_bindfs_search_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.tap do |comm| # Ensure aptitude is installed as Ubuntu removed it comm.sudo('apt-get install aptitude') comm.sudo("aptitude versions bindfs | sed -n '/p/,${p}' | sed 's/\s\+/ /g' | cut -d' ' -f2") do |_, output| package_version = output.strip return "bindfs-#{package_version}" if !package_version.empty? && !package_version.match(/^#{version}/).nil? end end false end def bindfs_bindfs_install_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) package_version = machine.guest.capability(:bindfs_bindfs_search_version, version) machine.communicate.sudo("apt-get install -y bindfs=#{package_version.shellescape}") end def bindfs_bindfs_install_compilation_requirements(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('apt-get install -y build-essential pkg-config wget tar libfuse-dev') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/debian/fuse.rb000066400000000000000000000006311360014246500267030ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Debian module Fuse class << self def bindfs_fuse_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('apt-get install -y fuse') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/debian/package_manager.rb000066400000000000000000000006741360014246500310350ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Debian module PackageManager class << self def bindfs_package_manager_name(_machine) 'apt-get' end def bindfs_package_manager_update(machine) machine.communicate.sudo('apt-get update') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/gentoo.rb000066400000000000000000000006041360014246500260120ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Gentoo autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/gentoo/package_manager' autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/gentoo/fuse' autoload :Bindfs, 'vagrant-bindfs/vagrant/capabilities/gentoo/bindfs' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/gentoo/000077500000000000000000000000001360014246500254655ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/gentoo/bindfs.rb000066400000000000000000000051261360014246500272630ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Gentoo module Bindfs class << self def bindfs_bindfs_search(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.tap do |comm| # Ensure equery is installed comm.sudo('emerge app-portage/gentoolkit') return comm.test("equery -q list -po #{bindfs_package_name}") end end def bindfs_bindfs_install(machine) machine.guest.capability(:bindfs_package_manager_update) allow_bindfs_installation(machine) machine.communicate.sudo("emerge #{bindfs_package_name}") end def bindfs_bindfs_search_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.tap do |comm| # Ensure equery is installed comm.sudo('emerge app-portage/gentoolkit') comm.sudo("equery -q list -po -F '$fullversion' #{bindfs_package_name} || true") do |_, output| output.strip.gsub(/\s+/, ' ').split(' ').each do |package_version| return package_version unless package_version.match(/^#{version}/).nil? end end end false end def bindfs_bindfs_install_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) package_version = machine.guest.capability(:bindfs_bindfs_search_version, version) allow_bindfs_installation(machine) machine.communicate.sudo("emerge =#{bindfs_package_name}-#{package_version.shellescape}") end def bindfs_bindfs_install_compilation_requirements(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('emerge wget tar') end private def bindfs_package_name 'sys-fs/bindfs' end def allow_bindfs_installation(machine) machine.communicate.sudo <<-SHELL arch=$(equery -q list -po -F '$keywords' #{bindfs_package_name}) keywords=$(echo $arch | tr ' ' "\n" | sort | uniq | tr "\n" ' ') echo "#{bindfs_package_name} $keywords" > /etc/portage/package.accept_keywords/bindfs SHELL end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/gentoo/fuse.rb000066400000000000000000000006241360014246500267560ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Gentoo module Fuse class << self def bindfs_fuse_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('emerge sys-fs/fuse') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/gentoo/package_manager.rb000066400000000000000000000006731360014246500311050ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Gentoo module PackageManager class << self def bindfs_package_manager_name(_machine) 'emerge' end def bindfs_package_manager_update(machine) machine.communicate.sudo('emaint -a sync') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/linux.rb000066400000000000000000000006151360014246500256600ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Linux autoload :SystemChecks, 'vagrant-bindfs/vagrant/capabilities/linux/system_checks' autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/linux/package_manager' autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/linux/fuse' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/linux/000077500000000000000000000000001360014246500253315ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/linux/fuse.rb000066400000000000000000000011071360014246500266170ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Linux module Fuse class << self def bindfs_fuse_installed(machine) machine.communicate.test('test -f /etc/fuse.conf') end def bindfs_fuse_loaded(machine) machine.communicate.test('lsmod | grep -q fuse') end def bindfs_fuse_load(machine) machine.communicate.sudo('/sbin/modprobe fuse') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/linux/package_manager.rb000066400000000000000000000005611360014246500307450ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Linux module PackageManager class << self def bindfs_package_manager_install(_machine) raise VagrantBindfs::Vagrant::Error, :package_manager_missing end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/linux/system_checks.rb000066400000000000000000000011741360014246500305250ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Linux module SystemChecks class << self def bindfs_exists_user(machine, user) ( user.nil? || \ machine.communicate.test("getent passwd #{user.shellescape}") ) end def bindfs_exists_group(machine, group) ( group.nil? || \ machine.communicate.test("getent group #{group.shellescape}") ) end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/redhat.rb000066400000000000000000000006041360014246500257660ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module RedHat autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/redhat/package_manager' autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/redhat/fuse' autoload :Bindfs, 'vagrant-bindfs/vagrant/capabilities/redhat/bindfs' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/redhat/000077500000000000000000000000001360014246500254415ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/redhat/bindfs.rb000066400000000000000000000033121360014246500272320ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module RedHat module Bindfs class << self def bindfs_bindfs_search(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.test("[[ $(yum search bindfs 2>/dev/null | egrep -i '^bindfs\.' | wc -l) != 0 ]]") end def bindfs_bindfs_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('yum -y install bindfs') end def bindfs_bindfs_search_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.tap do |comm| comm.sudo('yum -y install yum-utils') comm.execute("repoquery --show-duplicates bindfs-#{version}* 2>/dev/null | head -n1") do |_, output| package_name = output.strip return package_name unless package_name.empty? end end false end def bindfs_bindfs_install_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) package_name = machine.guest.capability(:bindfs_bindfs_search_version, version) machine.communicate.sudo("yum -y install #{package_name.shellescape}") end def bindfs_bindfs_install_compilation_requirements(machine) machine.communicate.sudo('yum -y install make automake gcc gcc-c++ kernel-devel wget tar fuse-devel') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/redhat/fuse.rb000066400000000000000000000006251360014246500267330ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module RedHat module Fuse class << self def bindfs_fuse_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('yum -y install fuse') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/redhat/package_manager.rb000066400000000000000000000007001360014246500310500ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module RedHat module PackageManager class << self def bindfs_package_manager_name(_machine) 'yum' end def bindfs_package_manager_update(machine) machine.communicate.sudo('yum clean expire-cache') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/suse.rb000066400000000000000000000005741360014246500255040ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Suse autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/suse/package_manager' autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/suse/fuse' autoload :Bindfs, 'vagrant-bindfs/vagrant/capabilities/suse/bindfs' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/suse/000077500000000000000000000000001360014246500251515ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/suse/bindfs.rb000066400000000000000000000034311360014246500267440ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Suse module Bindfs class << self def bindfs_bindfs_search(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.test('zypper se -s bindfs') end def bindfs_bindfs_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('zypper -n install bindfs') end def bindfs_bindfs_search_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.tap do |comm| comm.sudo("zypper se -s bindfs | sed -n '/bindfs/,${p}' | cut -d'|' -f2,4 --output-delimiter='-'") do |_, output| package_name = output.strip return package_name if !package_name.empty? && !package_name.match(/^bindfs-#{version}/).nil? end end false end def bindfs_bindfs_install_version(machine, version) machine.guest.capability(:bindfs_package_manager_update) package_name = machine.guest.capability(:bindfs_bindfs_search_version, version) machine.communicate.sudo("zypper -n in -f #{package_name.shellescape}") end def bindfs_bindfs_install_compilation_requirements(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.tap do |comm| comm.sudo('zypper -n install make automake gcc gcc-c++ kernel-devel wget tar fuse-devel') end end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/suse/fuse.rb000066400000000000000000000006261360014246500264440ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Suse module Fuse class << self def bindfs_fuse_install(machine) machine.guest.capability(:bindfs_package_manager_update) machine.communicate.sudo('zypper -n install fuse') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/suse/package_manager.rb000066400000000000000000000006701360014246500305660ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Suse module PackageManager class << self def bindfs_package_manager_name(_machine) 'zypper' end def bindfs_package_manager_update(machine) machine.communicate.sudo('zypper ref -s') end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/ubuntu.rb000066400000000000000000000003271360014246500260430ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Ubuntu autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/ubuntu/fuse' end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/ubuntu/000077500000000000000000000000001360014246500255145ustar00rootroot00000000000000vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/capabilities/ubuntu/fuse.rb000066400000000000000000000010611360014246500270010ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant module Capabilities module Ubuntu module Fuse class << self # Ubuntu 6.10 and after automatically load fuse. # Just check if it is installed def bindfs_fuse_loaded(machine) machine.guest.capability(:bindfs_fuse_installed) end def bindfs_fuse_load(machine) machine.guest.capability(:bindfs_fuse_installed) end end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/config.rb000066400000000000000000000056551360014246500233460ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant class Config < ::Vagrant.plugin('2', :config) attr_reader :debug attr_accessor :bindfs_version attr_reader :install_bindfs_from_source attr_reader :default_options attr_accessor :bound_folders attr_accessor :skip_validations attr_reader :force_empty_mountpoints def initialize @debug = false @bindfs_version = UNSET_VALUE @install_bindfs_from_source = false @bound_folders = {} @default_options = Bindfs::OptionSet.new(nil, 'force-user' => 'vagrant', 'force-group' => 'vagrant', 'perms' => 'u=rwX:g=rD:o=rD') @skip_validations = [] @force_empty_mountpoints = false end def debug=(value) @debug = (value == true) end def source_version=(value) @bindfs_version = Gem::Version.new(value.to_s) end def install_bindfs_from_source=(value) @install_bindfs_from_source = (value == true) end def default_options=(options = {}) @default_options = Bindfs::OptionSet.new(nil, options) end def force_empty_mountpoints=(value) @force_empty_mountpoints = (value == true) end def bound_folder=(*_any_variant) raise VagrantBindfs::Vagrant::ConfigError, :bound_folders end def bind_folder(source, destination, options = {}) hook = options.delete(:after) || :synced_folders folder = Bindfs::Folder.new(hook, source, destination, options) @bound_folders[folder.id] = folder end def merge(other) # rubocop:disable Metrics/AbcSize super.tap do |result| result.debug = (debug || other.debug) result_bindfs_version = [bindfs_version, other.bindfs_version].reject { |v| v == UNSET_VALUE }.min result.bindfs_version = result_bindfs_version unless result_bindfs_version.nil? result.install_bindfs_from_source = (install_bindfs_from_source || other.install_bindfs_from_source) result.default_options = default_options.merge(other.default_options) result.bound_folders = bound_folders.merge(other.bound_folders) result.skip_validations = (skip_validations + other.skip_validations).uniq result.force_empty_mountpoints = (force_empty_mountpoints || other.force_empty_mountpoints) end end def finalize! @bindfs_version = :latest if @bindfs_version == UNSET_VALUE end def validate(_machine) errors = _detected_errors bound_folders.each_value do |folder| validator = Bindfs::Validators::Config.new(folder) errors << validator.errors unless validator.valid? end { 'vagrant-bindfs' => errors.flatten } end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/errors.rb000066400000000000000000000004251360014246500234030ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant class Error < ::Vagrant::Errors::VagrantError error_namespace('vagrant-bindfs.errors') end class ConfigError < Error error_namespace('vagrant-bindfs.errors.config') end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/vagrant/plugin.rb000066400000000000000000000023321360014246500233640ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs module Vagrant class Plugin < ::Vagrant.plugin('2') name 'bindfs' description <<-DESC A Vagrant plugin to automate bindfs mount in the VM. This allow you to change owner, group and permissions on files and, for example, work around NFS share permissions issues. DESC config(:bindfs) do Config end include Capabilities %w[up reload].each do |action| action_hook(:bindfs, "machine_action_#{action}".to_sym) do |hook| hooks.each do |(name, middleware)| hook.before(middleware, Actions::Mounter, name) end hook.before(hooks[hooks.keys.first], Actions::Installer) end end class << self def hooks @hooks ||= begin { synced_folders: synced_folders_hook, provision: ::Vagrant::Action::Builtin::Provision } end end def synced_folders_hook if ::Vagrant::Action::Builtin.const_defined? :NFS ::Vagrant::Action::Builtin::NFS else ::Vagrant::Action::Builtin::SyncedFolders end end end end end end vagrant-bindfs-1.1.5/lib/vagrant-bindfs/version.rb000066400000000000000000000001141360014246500221050ustar00rootroot00000000000000# frozen_string_literal: true module VagrantBindfs VERSION = '1.1.5' end vagrant-bindfs-1.1.5/locales/000077500000000000000000000000001360014246500160465ustar00rootroot00000000000000vagrant-bindfs-1.1.5/locales/en.yml000066400000000000000000000066141360014246500172020ustar00rootroot00000000000000en: vagrant-bindfs: actions: installer: start: "Checking for bindfs in VM..." end: "Machine is ready to use bindfs!" package_manager: not_installed: "Package manager seems to not be installed on the virtual machine, installing now" installed: "Package manager detected: %{name}" fuse: not_installed: "Fuse seems to not be installed on the virtual machine, installing now" installed: "Fuse kernel module is installed" not_loaded: "Fuse kernel module seems to be not loaded on the virtual machine, loading now" loaded: "Fuse kernel module is loaded" bindfs: not_installed: "Bindfs seems to not be installed on the virtual machine, installing now" not_found_in_repository: "Bindfs %{version} can not be found in any of the repositories, installing now from sources" detected: "Bindfs %{version} is installed" mounter: start: "Creating bind mounts after %{hook}..." entry: "%{source} => %{dest}" force_empty_mountpoints: "All content in '%{dest}' as been removed before mount" validations: source_path_required: "A source path is required as argument to bind_folder" source_path_does_not_exist: "Source path '%{path}' doesn't exist" destination_path_required: "A destination path is required as argument to bind_folder" destination_already_mounted: "Destination path '%{dest}' is already a bindfs mount" path_must_be_absolute: "Path '%{path}' is relative but an absolute path is attended" user_does_not_exist: "User '%{user}' doesn't exist" group_does_not_exist: "Group '%{group}' doesn't exist" invalid_hook: "Invalid hook specified. Must use one of %{hooks}" errors_found: "Cannot create bind mount from '%{source}' to '%{dest}': %{errors}" errors: package_manager_missing: "No package manager found on the virtual machine. You may use an unsupported flavour of Linux." config: bound_folders: "config.bindfs.bound_folders= must no be called. Use config.bindfs.bind_folders instead." conflicting_options: "Another option has already been set for the canonical name '%{name}'" bindfs: mount_failed: |- A bindfs command failed to run! Command (runned via sudo): %{command} Standard output: %{stdout} Error output: %{stderr} Please check options values and compatibility. For a complete documentation, run `sudo bindfs --help` on the VM. You can see it online at http://bindfs.org/docs/bindfs.1.html deprecations: disabled: |- ':disabled' option is not supported anymore. Please comment or remove the line in your Vagrantfile instead. skip_verify_user: |- ':skip_verify_user' option is not supported anymore via bind_folder. If you need vagrant-bindfs to not check user existence, use the 'skip_validations' configuration options: config.bindfs.skip_validations << :user skip_verify_group: |- ':skip_verify_group' option is not supported anymore via bind_folder. If you need vagrant-bindfs to not check user existence, use the 'skip_validations' configuration options: config.bindfs.skip_validations << :group hook: |- ':hook' option is not supported anymore. Please use ':after' instead. vagrant-bindfs-1.1.5/spec/000077500000000000000000000000001360014246500153565ustar00rootroot00000000000000vagrant-bindfs-1.1.5/spec/spec_helper.rb000066400000000000000000000117021360014246500201750ustar00rootroot00000000000000# frozen_string_literal: true # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be loaded, without a need to explicitly require it in any # files. # # Given that it is always loaded, you are encouraged to keep this file as # light-weight as possible. Requiring heavyweight dependencies from this file # will add to the boot time of your test suite on EVERY test run, even for an # individual file that may not need all of that loaded. Instead, consider making # a separate helper file that requires the additional dependencies and performs # the additional setup, and require it from the spec files that actually need # it. # # The `.rspec` file also contains a few flags that are not defaults but that # users commonly want. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. config.expect_with :rspec do |expectations| # This option will default to `true` in RSpec 4. It makes the `description` # and `failure_message` of custom matchers include text for helper methods # defined using `chain`, e.g.: # be_bigger_than(2).and_smaller_than(4).description # # => "be bigger than 2 and smaller than 4" # ...rather than: # # => "be bigger than 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end # rspec-mocks config goes here. You can use an alternate test double # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| # Prevents you from mocking or stubbing a method that does not exist on # a real object. This is generally recommended, and will default to # `true` in RSpec 4. mocks.verify_partial_doubles = true end # This option will default to `:apply_to_host_groups` in RSpec 4 (and will # have no way to turn it off -- the option exists only for backwards # compatibility in RSpec 3). It causes shared context metadata to be # inherited by the metadata hash of host groups and examples, rather than # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = :random # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. # This allows you to limit a spec run to individual examples or groups # you care about by tagging them with `:focus` metadata. When nothing # is tagged with `:focus`, all examples get run. RSpec also provides # aliases for `it`, `describe`, and `context` that include `:focus` # metadata: `fit`, `fdescribe` and `fcontext`, respectively. # config.filter_run_when_matching :focus # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. We recommend # you configure your source control system to ignore this file. # config.example_status_persistence_file_path = "spec/examples.txt" # Limits the available syntax to the non-monkey patched syntax that is # recommended. For more details, see: # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode # config.disable_monkey_patching! # This setting enables warnings. It's recommended, but in some cases may # be too noisy due to issues in dependencies. # config.warnings = true # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an # individual spec file. if config.files_to_run.one? # Use the documentation formatter for detailed output, # unless a formatter has already been configured # (e.g. via a command-line flag). config.default_formatter = 'doc' end # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow. # config.profile_examples = 10 # Seed global randomization in this process using the `--seed` CLI option. # Setting this allows you to use `--seed` to deterministically reproduce # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. # Kernel.srand config.seed end require 'vagrant-bindfs' vagrant-bindfs-1.1.5/spec/unit/000077500000000000000000000000001360014246500163355ustar00rootroot00000000000000vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/000077500000000000000000000000001360014246500212425ustar00rootroot00000000000000vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/bindfs/000077500000000000000000000000001360014246500225075ustar00rootroot00000000000000vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/bindfs/command_spec.rb000066400000000000000000000022031360014246500254610ustar00rootroot00000000000000# frozen_string_literal: true describe VagrantBindfs::Bindfs::Command do it 'should build bindfs command as expected' do options = { force_user: 'vagrant', chown_deny: true, o: 'debug,allow_others', r: true } folder = VagrantBindfs::Bindfs::Folder.new(:synced_folder, '/etc', '/etc-bound', options) folder.to_version!('1.13.3') command = described_class.new(folder) expect(command.to_s).to eq('bindfs --force-user=vagrant --chown-deny -o debug,allow_others -r /etc /etc-bound') end it 'should build bindfs command according to bindfs version' do options = { force_user: 'vagrant', force_group: 'vagrant', perms: 'u=rwX:g=rD:o=rD' } folder = VagrantBindfs::Bindfs::Folder.new(:synced_folder, '/etc', '/etc-bound', options) folder.to_version!('1.13.3') command = described_class.new(folder) expect(command.to_s).to eq('bindfs --force-user=vagrant --force-group=vagrant --perms=u=rwX:g=rD:o=rD /etc /etc-bound') folder.to_version!('1.11') command = described_class.new(folder) expect(command.to_s).to eq('bindfs --user=vagrant --group=vagrant --perms=u=rwX:g=rD:o=rD /etc /etc-bound') end end vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/bindfs/folder_spec.rb000066400000000000000000000026431360014246500253260ustar00rootroot00000000000000# frozen_string_literal: true describe VagrantBindfs::Bindfs::Folder do subject do described_class.new(:synced_folders, '/etc', '/etc-bound', force_user: 'vagrant', force_group: 'vagrant', uid_offset: 50) end it 'should store binding arguments' do expect(subject).to respond_to(:source) expect(subject).to respond_to(:destination) expect(subject).to respond_to(:options) end it 'should relate to a binding hook' do expect(subject).to respond_to(:hook) end it 'should merge additional options' do subject.merge!(force_user: 'another-user', mirror_only: 'joe,bob') expect(subject.options.keys).to contain_exactly('force-user', 'force-group', 'mirror-only', 'uid-offset') expect(subject.options['force-user']).to eq('another-user') end it 'should merge additional options without loss' do subject.reverse_merge!(force_user: 'another-user', mirror_only: 'joe,bob') expect(subject.options.keys).to contain_exactly('force-user', 'force-group', 'mirror-only', 'uid-offset') expect(subject.options['force-user']).to eq('vagrant') end it 'should be losslessly convertible to another bindfs version' do subject.to_version!('1.13.1') expect(subject.options.keys).to contain_exactly('force-user', 'force-group') subject.to_version!('1.13.3') expect(subject.options.keys).to contain_exactly('force-user', 'force-group', 'uid-offset') end end vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/bindfs/option_set_spec.rb000066400000000000000000000122361360014246500262350ustar00rootroot00000000000000# frozen_string_literal: true describe VagrantBindfs::Bindfs::OptionSet do it 'should normalize option names' do option_set = VagrantBindfs::Bindfs::OptionSet.new(nil, 'force-user' => 'vagrant', 'force_group' => 'vagrant', :mirror_only => 'joe,bob', :'create-as-user' => true) expect(option_set.keys).to contain_exactly('force-user', 'force-group', 'mirror-only', 'create-as-user') end it 'should canonicalize option names' do option_set = VagrantBindfs::Bindfs::OptionSet.new(nil, 'owner' => 'vagrant', :n => true) expect(option_set.keys).to contain_exactly('force-user', 'no-allow-other') end it 'should raise an error when more than one option refers to the same canonical name' do expect do VagrantBindfs::Bindfs::OptionSet.new(nil, 'owner' => 'vagrant', 'user' => 'another-user') end.to raise_error(VagrantBindfs::Vagrant::ConfigError) end it 'should remove invalid option names' do option_set = VagrantBindfs::Bindfs::OptionSet.new(nil, 'force-user' => 'vagrant', 'force_group' => 'vagrant', :invalid => true) expect(option_set.keys).to contain_exactly('force-user', 'force-group') expect(option_set.invalid_options.keys).to contain_exactly('invalid') end it 'should remove unsupported option names' do option_set = VagrantBindfs::Bindfs::OptionSet.new('1.13.1', 'force-user' => 'vagrant', 'force_group' => 'vagrant', 'uid-offset' => 50) expect(option_set.keys).to contain_exactly('force-user', 'force-group') expect(option_set.unsupported_options.keys).to contain_exactly('uid-offset') end it 'should cast option values according to option type' do option_set = VagrantBindfs::Bindfs::OptionSet.new(nil, 'force-user' => :vagrant, 'force-group' => true, 'uid-offset' => 50, :'create-as-user' => 1, 'create-as-mounter' => 'off') expect(option_set['force-user']).to eq('vagrant') expect(option_set['force-group']).to eq('true') expect(option_set['uid-offset']).to eq('50') expect(option_set['create-as-user']).to be true expect(option_set['create-as-mounter']).to be false end it 'should consider nil as a proper value for non boolean options' do option_set = VagrantBindfs::Bindfs::OptionSet.new(nil, 'force-user' => :vagrant, 'force-group' => nil, 'uid-offset' => 50, :'create-as-user' => nil) expect(option_set['force-user']).to eq('vagrant') expect(option_set['force-group']).to eq(nil) expect(option_set['uid-offset']).to eq('50') expect(option_set['create-as-user']).to be false end it 'should be mergeable' do first_set = VagrantBindfs::Bindfs::OptionSet.new(nil, 'force-user' => 'vagrant', 'force_group' => 'vagrant', :invalid => true, 'perms' => 'u=rwX:g=rD:o=rD') second_set = VagrantBindfs::Bindfs::OptionSet.new(nil, 'force_group' => 'other-group', 'mirror-only' => 'joe,bob', :invalid => true, 'perms' => nil) first_set.merge(second_set) expect(first_set.keys).to contain_exactly('force-user', 'force-group', 'mirror-only', 'perms') expect(first_set['force-group']).to eq('other-group') expect(first_set['perms']).to be nil end it 'should be losslessly convertible to another version of bindfs' do set1132 = VagrantBindfs::Bindfs::OptionSet.new('1.13.2', 'user' => 'vagrant', 'force_group' => 'vagrant', 'uid-offset' => 50) set1130 = set1132.to_version('1.13.0') set1134 = set1130.to_version('1.13.4') expect(set1132.keys).to contain_exactly('force-user', 'force-group', 'uid-offset') expect(set1132.unsupported_options.keys.size).to eq(0) expect(set1130.keys).to contain_exactly('force-user', 'force-group') expect(set1130.unsupported_options.keys).to contain_exactly('uid-offset') expect(set1134.keys).to contain_exactly('force-user', 'force-group', 'uid-offset') expect(set1134.unsupported_options.keys.size).to eq(0) end end vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/bindfs_spec.rb000066400000000000000000000022611360014246500240470ustar00rootroot00000000000000# frozen_string_literal: true describe VagrantBindfs::Bindfs do describe 'normalize_version_in_tar_name' do it 'normalize bindfs version number to match tarballs names' do expect(subject.normalize_version_in_tar_name('1.12')).to eq('1.12') expect(subject.normalize_version_in_tar_name('1.12.0')).to eq('1.12') expect(subject.normalize_version_in_tar_name('1.12.7')).to eq('1.12.7') expect(subject.normalize_version_in_tar_name('1.13')).to eq('1.13.0') expect(subject.normalize_version_in_tar_name('1.13.0')).to eq('1.13.0') expect(subject.normalize_version_in_tar_name('1.13.10')).to eq('1.13.10') end end describe 'source_tar_basename' do it 'return correct tarball names' do expect(subject.source_tar_basename('1.12')).to eq('bindfs-1.12') expect(subject.source_tar_basename('1.13')).to eq('bindfs-1.13.0') end end describe 'source_tar_urls' do it 'return correct tarball urls' do expect(subject.source_tar_urls('1.12')).to include('https://bindfs.org/downloads/bindfs-1.12.tar.gz') expect(subject.source_tar_urls('1.13')).to include('https://bindfs.org/downloads/bindfs-1.13.0.tar.gz') end end end vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/vagrant/000077500000000000000000000000001360014246500227045ustar00rootroot00000000000000vagrant-bindfs-1.1.5/spec/unit/vagrant-bindfs/vagrant/config_spec.rb000066400000000000000000000106771360014246500255230ustar00rootroot00000000000000# frozen_string_literal: true describe VagrantBindfs::Vagrant::Config do subject { described_class.new } it 'has an option to enable/disable debugging' do expect(subject).to respond_to(:debug) expect(subject).to respond_to(:debug=) end describe '#debug' do it 'should force the debug option to a boolean' do subject.debug = 'true' expect(subject.debug).to be false end end it 'has an option to enable/disable installation of bindfs from sources' do expect(subject).to respond_to(:install_bindfs_from_source) expect(subject).to respond_to(:install_bindfs_from_source=) end describe '#install_bindfs_from_source' do it 'should force the option to a boolean' do subject.install_bindfs_from_source = 'true' expect(subject.install_bindfs_from_source).to be false end end it 'has an option for bindfs version when installed from sources' do expect(subject).to respond_to(:bindfs_version) expect(subject).to respond_to(:bindfs_version=) end describe '#bindfs_version=' do it 'should convert given version to a Gem::Version instance' do subject.source_version = '1.0.0' expect(subject.bindfs_version).to eq(Gem::Version.new('1.0.0')) end end it 'has an option for default bindfs options' do expect(subject).to respond_to(:default_options) expect(subject).to respond_to(:default_options=) end describe '#default_options' do it 'should be an instance of VagrantBindfs::Command::OptionSet' do expect(subject.default_options).to be_a(VagrantBindfs::Bindfs::OptionSet) end end describe '#default_options=' do it 'should convert options to an instance of VagrantBindfs::Command::OptionSet' do subject.default_options = { group: 'dummy', user: 'dummy' } expect(subject.default_options).to be_a(VagrantBindfs::Bindfs::OptionSet) expect(subject.default_options.keys).to contain_exactly('force-group', 'force-user') end end it 'has an option for bound folders set' do expect(subject).to respond_to(:bound_folders) end describe '#bind_folder' do end describe '#merge' do let(:first) do config = described_class.new config.debug = false config.default_options = { create_as_user: true } config.skip_validations << :user config.bind_folder '/bin', '/bin-bound' config.bind_folder '/etc', '/etc-bound', user: 'dummy', create_as_user: false config end let(:second) do config = described_class.new config.debug = true config.default_options = { create_as_mounter: true } config.skip_validations << :group config.bind_folder '/etc', '/etc-bound', group: 'dummy', create_as_user: true config.bind_folder '/usr/bin', '/usr-bin-bound' config end subject { first.merge(second) } it 'should pick the most verbose value for debug options' do expect(subject.debug).to be(true) end it 'should merge default bindfs options' do expect(subject.default_options.keys).to contain_exactly('create-as-user', 'create-as-mounter') expect(subject.default_options['create-as-user']).to be true expect(subject.default_options['create-as-mounter']).to be true end it 'should merge bound folders set' do expect(subject.bound_folders.collect { |(_, f)| f.destination }).to include('/etc-bound', '/usr-bin-bound', '/bin-bound') end it 'should merge skip_validations set' do expect(subject.skip_validations).to contain_exactly(:user, :group) end end it 'should respond to #finalize!' do expect(subject).to respond_to(:finalize!) end context 'when finalized' do before { subject.finalize! } it 'defaults to disable debug' do expect(subject.debug).to eq(false) end it 'defaults to install bindfs from sources of the latest supported version' do expect(subject.bindfs_version).to eq(:latest) end it 'defaults to basics bindfs options' do expect(subject.default_options.keys).to contain_exactly('force-user', 'force-group', 'perms') end it 'defaults to empty bound folders set' do expect(subject.bound_folders).to eq({}) end it 'defaults to empty skip_validations set' do expect(subject.skip_validations).to eq([]) end end it 'should respond to #validate' do expect(subject).to respond_to(:validate) end describe '#validate' do it 'should return a hash of errors' do end end end vagrant-bindfs-1.1.5/spec/unit/vagrant_bindfs_spec.rb000066400000000000000000000000751360014246500226650ustar00rootroot00000000000000# frozen_string_literal: true describe VagrantBindfs do end vagrant-bindfs-1.1.5/spec/vagrantfile_helper.rb000066400000000000000000000020371360014246500215460ustar00rootroot00000000000000# frozen_string_literal: true def tests_setup(machine, options = {}) # rubocop:disable Metrics/MethodLength machine.bindfs.bind_folder '/etc', '/etc-bound-after-synced-folder', options.merge(owner: 'root') machine.bindfs.bind_folder '/etc', '/etc-bound-after-provisioning', options.merge(owner: 'root', after: :provision) machine.vm.provision :shell do |p| p.name = 'create non emtpy mountpoints' p.inline = <<-COMMANDS mkdir -p /home/vagrant/mountpoint/non/empty mkdir -p /home/vagrant/mountpoint-nonempty/non/empty COMMANDS end machine.bindfs.bind_folder '/etc', '/home/vagrant/mountpoint', options.merge(owner: 'root', after: :provision) machine.bindfs.bind_folder '/etc', '/home/vagrant/mountpoint-nonempty', options.merge(owner: 'root', o: 'nonempty', after: :provision) end vagrant-bindfs-1.1.5/vagrant-bindfs.gemspec000066400000000000000000000022201360014246500206720ustar00rootroot00000000000000# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path('lib', __dir__) require 'vagrant-bindfs/version' Gem::Specification.new do |s| s.name = 'vagrant-bindfs' s.version = VagrantBindfs::VERSION s.summary = 'A Vagrant plugin to automate bindfs mount in the VM' s.description = <<-DESC.gsub(/[\s]+/, ' ') A Vagrant plugin to automate bindfs mount in the VM. This allow you to change owner, group and permissions on files and, for example, work around NFS share permissions issues. DESC s.license = 'MIT' s.authors = ['Gaël-Ian Havard', 'Igor Serebryany', 'Thomas Boerger'] s.email = ['gaelian.havard@gmail.com', 'igor.serebryany@airbnb.com'] s.homepage = 'https://github.com/gael-ian/vagrant-bindfs' if s.respond_to?(:metadata=) s.metadata = { 'allowed_push_host' => 'https://rubygems.org', 'issue_tracker' => 'https://github.com/gael-ian/vagrant-bindfs/issues' } end s.files = Dir['{lib,locales}/**/*'] + ['README.md', 'Rakefile', 'MIT-LICENSE'] s.test_files = Dir['{specs}/**/*'] + ['Vagrantfile'] s.required_ruby_version = '~> 2.2', '< 2.7' s.required_rubygems_version = '>= 1.3.6' end