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

(GH-552) Fix home directory evaluation #553

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

chelnak
Copy link

@chelnak chelnak commented Jun 29, 2022

Prior to this PR the module would fail when executed under the context of systemd.

This was because Dir.home tries to expand ~ when no UID is passed.
However the HOME environment variable is not available when the agent is executed by systemd resulting in the following error:

Could not evaluate: couldn't find login name -- expanding ~

This commit fixes this by reverting to using Etc.getpwuid so that we can retrieve the home dir from the uid of the current process.

For consistency, retrieval of home dirs for a given user has also been changed to use Etc.getpwnam.

Fixes #552

@chelnak chelnak added the bugfix label Jun 29, 2022
@chelnak chelnak requested a review from a team as a code owner June 29, 2022 13:30
@chelnak chelnak self-assigned this Jun 29, 2022
@chelnak chelnak force-pushed the GH-552-home_directory_evaluation_fix branch from 2c6a035 to eb4d3ac Compare June 29, 2022 13:33
Prior to this commit the module would fail when executed under the
context of systemd.

This was because Dir.home tries to expand `~` when
no UID is passed.
However the HOME environment variable is not available
when the agent is executed by systemd resulting in the following error:

`Could not evaluate: couldn't find login name -- expanding ~`

This commit fixes this by reverting to using Etc.getpwuid so that we can
retrieve the home dir from the  uid of the current process.

For consistency, retrieval of home dirs for a given user has also been
changed to use Etc.getpwnam.
@chelnak chelnak force-pushed the GH-552-home_directory_evaluation_fix branch from eb4d3ac to 28c8a65 Compare June 29, 2022 13:36
@david22swan david22swan merged commit 8d0cd41 into main Jun 29, 2022
@david22swan david22swan deleted the GH-552-home_directory_evaluation_fix branch June 29, 2022 14:33
jameslikeslinux added a commit to jameslikeslinux/puppet-nest that referenced this pull request Nov 14, 2022
vcsrepo doesn't officially support Windows, but I make it work on
Cygwin with a series of wrappers and hacks.

puppetlabs/puppetlabs-vcsrepo#553 changes the
way home directories are evaluated and breaks on Windows as described at
puppetlabs/puppetlabs-vcsrepo#559.
elfranne added a commit to elfranne/puppetlabs-vcsrepo that referenced this pull request Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

couldn't find login name -- expanding `~' since 5.1.0 with Centos 7
2 participants