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
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]
16 Facter.add(:root_home) do
17 setcode { Facter::Util::RootHome.returnt_root_home }
20 Facter.add(:root_home) do
21 confine :kernel => :darwin
23 str = Facter::Util::Resolution.exec('dscacheutil -q user -a name root')
25 str.split("\n").each do |pair|
26 key, value = pair.split(%r{:})
33 Facter.add(:root_home) do
34 confine :kernel => :aix
37 str = Facter::Util::Resolution.exec('lsuser -c -a home root')
38 str && str.split("\n").each do |line|
39 next if line =~ %r{^#}
40 root_home = line.split(%r{:})[1]