From fe676f0ac4e1d96e77ba7fe894408d8e7647eacc Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Thu, 16 Jan 2014 22:22:38 -0800 Subject: (PUP-1459) Add support for root_home on OS X 10.9 getent does not exist on 10.9 so this commit uses dscacheutil to query the homedir for the root user. --- lib/facter/root_home.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/facter') 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 -- cgit v1.2.3 From 68acb59bf77d8d818489b1e2a97491cb7f327a0a Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 22 Apr 2014 23:14:16 +0200 Subject: Adjust the regular expression for facts. Previously this was incorrectly handling facts that were of the form foo=1+1=2 due to the ='s in the actual fact contents. Fix this and add tests to try and prevent regressions. --- lib/facter/facter_dot_d.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/facter') diff --git a/lib/facter/facter_dot_d.rb b/lib/facter/facter_dot_d.rb index e414b20..2c096b0 100644 --- a/lib/facter/facter_dot_d.rb +++ b/lib/facter/facter_dot_d.rb @@ -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 -- cgit v1.2.3 From b11311ad65c925c074e6a0b34d8182b70c570225 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Fri, 9 Jan 2015 14:09:03 -0800 Subject: FM-2130 Move cache file to non temp directory --- lib/facter/facter_dot_d.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/facter') diff --git a/lib/facter/facter_dot_d.rb b/lib/facter/facter_dot_d.rb index 2c096b0..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 @@ -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 -- cgit v1.2.3