jamtur01-httpauth
jamtur01-httpauth copied to clipboard
File permissions are not set on create
Everytime i create a new file, the permissions are not set correctly.
else
# If the file doesn't exist then create it
File.new(resource[:file], "w", resource[:mode])
mech(resource[:file])
return false
end
This triggers the new file creation in httpauth/lib/puppet/provider/httpauth/httpauth.rb:22
.
Afterwards the file permissions are always 0600
, even though the resource[:mode]
is resource[:mode]
is 0640
.
My umask on the system is 0022
if that is of any consideration.
Even changing the code to:
else
# If the file doesn't exist then create it
File.new(resource[:file], "w")
File.chmod(resource[:mode], resource[:file])
mech(resource[:file])
return false
end
did not change anything.
If I run puppet again and it runs:
if File.exist?(resource[:file])
# Set file mode to given value
File.chmod(resource[:mode], resource[:file])
everything is set correctly.
I am out of ideas. I am not a ruby developer. Maybe the file operations are asynchronous or something is really, really wrong here.
Environment:
vagrant@foo:~$ ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]
vagrant@foo:~$ puppet --version
5.5.18
vagrant@foo:~$ facter --version
3.11.11 (commit 7ae8aff59a71b4992c0f52e0ac61eb58643cb3fc)
Example code:
httpauth { "foo@/etc/nginx/bar.htpasswd":
ensure => present,
file => /etc/nginx/bar.htpasswd,
mode => 0644,
name => foo,
password => bar,
mechanism => basic,
}
Are you using the forge module or the HEAD of this repo?
Can you try the current HEAD of the project and see if that fixes it?