]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/lib/facter/root_home.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / lib / facter / root_home.rb
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
5 module Facter::Util::RootHome
6   class << self
7   def get_root_home
8     root_ent = Facter::Util::Resolution.exec("getent passwd root")
9     # The home directory is the sixth element in the passwd entry
10     # If the platform doesn't have getent, root_ent will be nil and we should
11     # return it straight away.
12     root_ent && root_ent.split(":")[5]
13   end
14   end
15 end
16
17 Facter.add(:root_home) do
18   setcode { Facter::Util::RootHome.get_root_home }
19 end
20
21 Facter.add(:root_home) do
22   confine :kernel => :darwin
23   setcode do
24     str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root")
25     hash = {}
26     str.split("\n").each do |pair|
27       key,value = pair.split(/:/)
28       hash[key] = value
29     end
30     hash['dir'].strip
31   end
32 end