1+ # frozen_string_literal: true
2+
13# root_home.rb
24module Facter ::Util ::RootHome
35 # @summary
46 # A facter fact to determine the root home directory.
57 # This varies on PE supported platforms and may be
68 # reconfigured by the end user.
79 class << self
8- # determines the root home directory
9- def returnt_root_home
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 ]
15- end
10+ # determines the root home directory
11+ def returnt_root_home
12+ root_ent = Facter ::Util ::Resolution . exec ( 'getent passwd root' )
13+ # The home directory is the sixth element in the passwd entry
14+ # If the platform doesn't have getent, root_ent will be nil and we should
15+ # return it straight away.
16+ root_ent && root_ent . split ( ':' ) [ 5 ]
17+ end
1618 end
1719end
1820
@@ -21,7 +23,7 @@ def returnt_root_home
2123end
2224
2325Facter . add ( :root_home ) do
24- confine : kernel => :darwin
26+ confine kernel : :darwin
2527 setcode do
2628 str = Facter ::Util ::Resolution . exec ( 'dscacheutil -q user -a name root' )
2729 hash = { }
@@ -34,12 +36,12 @@ def returnt_root_home
3436end
3537
3638Facter . add ( :root_home ) do
37- confine : kernel => :aix
39+ confine kernel : :aix
3840 root_home = nil
3941 setcode do
4042 str = Facter ::Util ::Resolution . exec ( 'lsuser -c -a home root' )
41- str && str . split ( "\n " ) . each do |line |
42- next if line =~ %r{^#}
43+ str & .split ( "\n " ) & .each do |line |
44+ next if %r{^#} . match? ( line )
4345 root_home = line . split ( %r{:} ) [ 1 ]
4446 end
4547 root_home
0 commit comments