Skip to content

Determine root_home without shelling out #1278

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

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

ekohl
Copy link
Collaborator

@ekohl ekohl commented Oct 14, 2022

This uses Ruby's Etc library to determine the root home. This avoids shelling out and writing multiple implementations.

hash['dir'].strip
end
end

Facter.add(:root_home) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice removal of code @ekohl.

What do you think about confining the fact to osx and linux? I noticed the test just checks for nil when :kernel is Windows.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today there's also fact for AIX and I'd expect this code to work on any unix (like Solaris). However, I can't test that since I don't have access to those systems. Any you could confine it to non-Windows but I think this is effectively the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point!

This uses Ruby's Etc library to determine the root home. This avoids
shelling out and writing multiple implementations.
@ekohl ekohl force-pushed the simplify-root-home branch from 8a8ebc0 to 657cd71 Compare October 17, 2022 11:15
Copy link
Contributor

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks @ekohl.

@jordanbreen28 jordanbreen28 merged commit 199e514 into puppetlabs:main Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants