From 0cb7ec2d52a826295fffd4747b8ea9bbcbed1c04 Mon Sep 17 00:00:00 2001 From: Eric Saxby Date: Thu, 31 Jul 2014 14:41:06 -0700 Subject: [PATCH] rsync on SmartOS should use pfexec --- plugins/guests/smartos/cap/rsync.rb | 6 +++--- test/unit/plugins/guests/smartos/cap/rsync_test.rb | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/guests/smartos/cap/rsync.rb b/plugins/guests/smartos/cap/rsync.rb index 2d514cd83..76ae2bce2 100644 --- a/plugins/guests/smartos/cap/rsync.rb +++ b/plugins/guests/smartos/cap/rsync.rb @@ -12,13 +12,13 @@ module VagrantPlugins def self.rsync_pre(machine, opts) machine.communicate.tap do |comm| - comm.sudo("mkdir -p '#{opts[:guestpath]}'") + comm.execute("#{machine.config.smartos.suexec_cmd} mkdir -p '#{opts[:guestpath]}'") end end def self.rsync_post(machine, opts) - machine.communicate.sudo("find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + - "xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}") + machine.communicate.execute("find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + + "#{machine.config.smartos.suexec_cmd} xargs -0 chown #{opts[:owner]}:#{opts[:group]}") end end end diff --git a/test/unit/plugins/guests/smartos/cap/rsync_test.rb b/test/unit/plugins/guests/smartos/cap/rsync_test.rb index e8ff0c8c6..4fdeefb15 100644 --- a/test/unit/plugins/guests/smartos/cap/rsync_test.rb +++ b/test/unit/plugins/guests/smartos/cap/rsync_test.rb @@ -30,5 +30,19 @@ describe "VagrantPlugins::VagrantPlugins::Cap::Rsync" do end end end + + describe ".rsync_pre" do + it 'makes the guestpath directory with pfexec' do + communicator.expect_command("pfexec mkdir -p '/sync_dir'") + plugin.rsync_pre(machine, guestpath: '/sync_dir') + end + end + + describe ".rsync_post" do + it 'chowns incorrectly owned files in sync dir' do + communicator.expect_command("find '/sync_dir' '(' ! -user somebody -or ! -group somegroup ')' -print0 | pfexec xargs -0 chown somebody:somegroup") + plugin.rsync_post(machine, guestpath: '/sync_dir', owner: 'somebody', group: 'somegroup') + end + end end