2 module Facter::Util::RootHome
4 # A facter fact to determine the root home directory.
5 # This varies on PE supported platforms and may be
6 # reconfigured by the end user.
8 # determines the root home directory
10 root_ent = Facter::Util::Resolution.exec('getent passwd root')
11 # The home directory is the sixth element in the passwd entry
12 # If the platform doesn't have getent, root_ent will be nil and we should
13 # return it straight away.
14 root_ent && root_ent.split(':')[5]
19 Facter.add(:root_home) do
20 setcode { Facter::Util::RootHome.returnt_root_home }
23 Facter.add(:root_home) do
24 confine :kernel => :darwin
26 str = Facter::Util::Resolution.exec('dscacheutil -q user -a name root')
28 str.split("\n").each do |pair|
29 key, value = pair.split(%r{:})
36 Facter.add(:root_home) do
37 confine :kernel => :aix
40 str = Facter::Util::Resolution.exec('lsuser -c -a home root')
41 str && str.split("\n").each do |line|
42 next if line =~ %r{^#}
43 root_home = line.split(%r{:})[1]