rsync on SmartOS should use pfexec

This commit is contained in:
Eric Saxby 2014-07-31 14:41:06 -07:00
parent 1615325e46
commit 0cb7ec2d52
2 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -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