puppetlabs / puppetlabs/puppetlabs-stdlib
pw_hash used in exported ressource return a base64 entry
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 349
- Forks
- 573
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 1
Description
Describe the Bug
We use pw_hash to generate password for user creation. When we use it directly in puppet, the user is created with a correct password.
We have create an exported ressource user and when we retrieve it, we get a base64 as password on the system.
Expected Behavior
When using pw_hash in an exported ressource, we must retrieve a correct hash and not a base64 entry from the puppetdb.
Steps to Reproduce
Steps to reproduce the behavior:
Use this code:
@@user { $newuser:
ensure => present,
home => "/home/${newuser}",
managehome => true,
password => pw_hash('password', 'SHA-512', 'salt'),
tag => 'mytag',
}
And get the result with:
User <<| tag == 'mytag' |>>
And then look your /etc/shadow
Environment
- Version 8.5
- Platform Centos 7
Additional Context
I found that there is a problem if an exported ressource is encoded in 8bit ASCII: https://github.com/voxpupuli/hiera-eyaml/issues/273
pw_hash use crypt and on the FAQ of this function (http://crypt.finalstep.com.au/faq.html):
_Does this work for unicode?
Yes it does, but you have to take care of setting the desired encoding. When you provide a unicode string, it is automatically converted into 8-bit ascii for purposes of encryption (we need to deal with bytes). But when you decrypt, you will get an 8-bit ascii string and if you want unicode, you will need to force the encoding like this:
decrypted = decrypted.force_encoding("UTF-8")_
It may be a simple encoding problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the pw_hash entry point and the exported-resource flow shown in the reproduction, then inspect how the value is encoded through PuppetDB retrieval. Reproduce the example on the stated environment and compare the retrieved password with /etc/shadow; done means the exported resource installs the correct hash rather than a base64 value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100