summaryrefslogtreecommitdiff
path: root/lib/facter
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facter')
-rw-r--r--lib/facter/facter_dot_d.rb8
-rw-r--r--lib/facter/root_home.rb13
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/facter/facter_dot_d.rb b/lib/facter/facter_dot_d.rb
index e414b20..b058437 100644
--- a/lib/facter/facter_dot_d.rb
+++ b/lib/facter/facter_dot_d.rb
@@ -15,7 +15,7 @@
class Facter::Util::DotD
require 'yaml'
- def initialize(dir="/etc/facts.d", cache_file="/tmp/facts_cache.yml")
+ def initialize(dir="/etc/facts.d", cache_file=File.join(Puppet[:libdir], "facts_dot_d.cache"))
@dir = dir
@cache_file = cache_file
@cache = nil
@@ -23,7 +23,7 @@ class Facter::Util::DotD
end
def entries
- Dir.entries(@dir).reject{|f| f =~ /^\.|\.ttl$/}.sort.map {|f| File.join(@dir, f) }
+ Dir.entries(@dir).reject { |f| f =~ /^\.|\.ttl$/ }.sort.map { |f| File.join(@dir, f) }
rescue
[]
end
@@ -40,7 +40,7 @@ class Facter::Util::DotD
def txt_parser(file)
File.readlines(file).each do |line|
- if line =~ /^(.+)=(.+)$/
+ if line =~ /^([^=]+)=(.+)$/
var = $1; val = $2
Facter.add(var) do
@@ -113,7 +113,7 @@ class Facter::Util::DotD
def cache_save!
cache = load_cache
- File.open(@cache_file, "w", 0600) {|f| f.write(YAML.dump(cache)) }
+ File.open(@cache_file, "w", 0600) { |f| f.write(YAML.dump(cache)) }
rescue
end
diff --git a/lib/facter/root_home.rb b/lib/facter/root_home.rb
index 8249f7d..b4f87ff 100644
--- a/lib/facter/root_home.rb
+++ b/lib/facter/root_home.rb
@@ -17,3 +17,16 @@ end
Facter.add(:root_home) do
setcode { Facter::Util::RootHome.get_root_home }
end
+
+Facter.add(:root_home) do
+ confine :kernel => :darwin
+ setcode do
+ str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root")
+ hash = {}
+ str.split("\n").each do |pair|
+ key,value = pair.split(/:/)
+ hash[key] = value
+ end
+ hash['dir'].strip
+ end
+end