root_home.rb 583 B

12345678910111213141516171819
  1. # A facter fact to determine the root home directory.
  2. # This varies on PE supported platforms and may be
  3. # reconfigured by the end user.
  4. module Facter::Util::RootHome
  5. class << self
  6. def get_root_home
  7. root_ent = Facter::Util::Resolution.exec("getent passwd root")
  8. # The home directory is the sixth element in the passwd entry
  9. # If the platform doesn't have getent, root_ent will be nil and we should
  10. # return it straight away.
  11. root_ent && root_ent.split(":")[5]
  12. end
  13. end
  14. end
  15. Facter.add(:root_home) do
  16. setcode { Facter::Util::RootHome.get_root_home }
  17. end