diff --git a/lib/puppet/module_tool/tar/gnu.rb b/lib/puppet/module_tool/tar/gnu.rb index f0fd2af5b..9f3d95165 100644 --- a/lib/puppet/module_tool/tar/gnu.rb +++ b/lib/puppet/module_tool/tar/gnu.rb @@ -1,19 +1,19 @@ require 'shellwords' class Puppet::ModuleTool::Tar::Gnu def unpack(sourcefile, destdir, owner) sourcefile = File.expand_path(sourcefile) destdir = File.expand_path(destdir) Dir.chdir(destdir) do Puppet::Util::Execution.execute("gzip -dc #{Shellwords.shellescape(sourcefile)} | tar xof -") Puppet::Util::Execution.execute("find . -type d -exec chmod 755 {} +") - Puppet::Util::Execution.execute("find . -type f -exec chmod a-wst {} +") + Puppet::Util::Execution.execute("find . -type f -exec chmod u+rw,g+r,a-st {} +") Puppet::Util::Execution.execute("chown -R #{owner} .") end end def pack(sourcedir, destfile) Puppet::Util::Execution.execute("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}") end end diff --git a/spec/unit/module_tool/tar/gnu_spec.rb b/spec/unit/module_tool/tar/gnu_spec.rb index 79a84d727..0bf8f6a41 100644 --- a/spec/unit/module_tool/tar/gnu_spec.rb +++ b/spec/unit/module_tool/tar/gnu_spec.rb @@ -1,23 +1,23 @@ require 'spec_helper' require 'puppet/module_tool' describe Puppet::ModuleTool::Tar::Gnu do let(:sourcefile) { '/space path/the/module.tar.gz' } let(:destdir) { '/space path/the/dest/dir' } let(:sourcedir) { '/space path/the/src/dir' } let(:destfile) { '/space path/the/dest/file.tar.gz' } it "unpacks a tar file" do Dir.expects(:chdir).with(File.expand_path(destdir)).yields(mock) Puppet::Util::Execution.expects(:execute).with("gzip -dc #{Shellwords.shellescape(File.expand_path(sourcefile))} | tar xof -") Puppet::Util::Execution.expects(:execute).with("find . -type d -exec chmod 755 {} +") - Puppet::Util::Execution.expects(:execute).with("find . -type f -exec chmod a-wst {} +") + Puppet::Util::Execution.expects(:execute).with("find . -type f -exec chmod u+rw,g+r,a-st {} +") Puppet::Util::Execution.expects(:execute).with("chown -R .") subject.unpack(sourcefile, destdir, '') end it "packs a tar file" do Puppet::Util::Execution.expects(:execute).with("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}") subject.pack(sourcedir, destfile) end end