Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File permissions are not set on create #12

Open
func0der opened this issue Mar 16, 2020 · 2 comments
Open

File permissions are not set on create #12

func0der opened this issue Mar 16, 2020 · 2 comments

Comments

@func0der
Copy link

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,
  }
@jamtur01
Copy link
Owner

Are you using the forge module or the HEAD of this repo?

@jamtur01
Copy link
Owner

Can you try the current HEAD of the project and see if that fixes it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants