maestrodev / puppet-maven

A puppet recipe for Apache Maven, to download artifacts from a Maven repository, install Maven, configure settings.xml,...
http://www.maestrodev.com
Apache License 2.0
73 stars 77 forks source link

Tempfile permissions are not the same as the user,group specified #29

Closed nikolavp closed 10 years ago

nikolavp commented 10 years ago

We just found a problem with permissions when using the maven type. If we specify a custom user,group with which to download the maven artifact and have an ensure set to latest, we get an error message from maven because the Tempfile is read only.

We had a look at https://github.com/maestrodev/puppet-maven/blob/master/lib/puppet/provider/maven/mvn.rb and it seems that the user,group parameters are only honored for the maven execution but not for the Tempfile.

tempfile = Tempfile.new 'mvn'

is generating a file with owner set to root and 'rw' only for him

root@nikolavp-desktop:~# irb
irb(main):001:0> require 'tempfile'
=> true
irb(main):002:0> Tempfile.new 'mvn'
=> #<File:/tmp/mvn20140523-18968-qds2ic>
irb(main):003:0> 
[1]+  Stopped                 irb
root@nikolavp-desktop:~# ls /tmp/mvn20140523-18968-qds2ic  -l
-rw------- 1 root root 0 May 23 17:49 /tmp/mvn20140523-18968-qds2ic
dbevacqua commented 10 years ago

I just encountered the same problem. Quick fix is to make tempfile world-writable. See my pull request https://github.com/maestrodev/puppet-maven/pull/30

nikolavp commented 10 years ago

I think that

FileUtils.chown(user, group, tempfile)

will be better. See http://ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html.

dbevacqua commented 10 years ago

New pull request created https://github.com/maestrodev/puppet-maven/pull/32

carlossg commented 10 years ago

Fixed in 1.2.0

nikolavp commented 10 years ago

Thanks for the fast response.