From 2b6a07d00011560932feda0094e59d010a98bde9 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 20 Jul 2014 22:13:37 -0300 Subject: [PATCH] Skip `chmod 777` for cache bucket root for smb synced folders Closes GH-107 --- CHANGELOG.md | 2 ++ lib/vagrant-cachier/action/install_buckets.rb | 23 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8a5067..46d1010 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,10 @@ IMPROVEMENTS: BUG FIXES: + - Skip `chmod 777` for `smb` mounted folders [[GH-107]] - Do not error if base box has been removed and `:box` is configured as the cache scope [[GH-86]] +[GH-107]: https://github.com/fgrehm/vagrant-cachier/issues/107 [GH-86]: https://github.com/fgrehm/vagrant-cachier/issues/86 [GH-89]: https://github.com/fgrehm/vagrant-cachier/issues/89 diff --git a/lib/vagrant-cachier/action/install_buckets.rb b/lib/vagrant-cachier/action/install_buckets.rb index e8c809b..8a749cf 100644 --- a/lib/vagrant-cachier/action/install_buckets.rb +++ b/lib/vagrant-cachier/action/install_buckets.rb @@ -20,8 +20,13 @@ module VagrantPlugins end def chmod_bucket_root(machine) - @logger.info "'chmod'ing bucket root dir to 777..." - machine.communicate.sudo 'mkdir -p /tmp/vagrant-cache && chmod 777 /tmp/vagrant-cache' + machine.communicate.sudo 'mkdir -p /tmp/vagrant-cache' + + # https://github.com/fgrehm/vagrant-cachier/issues/107 + if ! smb_synced_folder_enabled?(machine) + @logger.info "'chmod'ing bucket root dir to 777..." + machine.communicate.sudo 'chmod 777 /tmp/vagrant-cache' + end end def configure_cache_buckets(env) @@ -41,6 +46,20 @@ module VagrantPlugins data_file = env[:machine].data_dir.join('cache_dirs') data_file.open('w') { |f| f.print env[:cache_dirs].uniq.join("\n") } end + + def smb_synced_folder_enabled?(machine) + synced_folder_opts = machine.config.cache.synced_folder_opts + synced_folder_opts ||= {} + + # If smb was explicitly enabled + if synced_folder_opts[:type] && synced_folder_opts[:type].to_s == 'smb' + return true + elsif machine.provider_name.to_sym == :hyperv + # If the provider in use is hyperv, the default synced folder is 'smb' + # unless specified + return synced_folder_opts[:type] == nil + end + end end end end