From 938d3cb881bac8ee26159f8c6d7d959704225dba Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Tue, 28 Jan 2014 18:30:23 -0500 Subject: [PATCH] Send dmidecode errors to /dev/null in the virtual fact MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When run as a non-root user, facter would always spew "/dev/mem: Permission denied" because it called dmidecode without redirecting stderr. This was filed upstream as FACT-86¹. It's unclear what is insufficient about this method, but failing tests that are not visible aren't as much of a concern to me as clearly useless output on every run of the command. ¹ https://tickets.puppetlabs.com/browse/FACT-86 --- facter-1.7.4-dmidecode-drop-stderr.patch | 12 ++++++++++++ facter.spec | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 facter-1.7.4-dmidecode-drop-stderr.patch diff --git a/facter-1.7.4-dmidecode-drop-stderr.patch b/facter-1.7.4-dmidecode-drop-stderr.patch new file mode 100644 index 0000000..f461d91 --- /dev/null +++ b/facter-1.7.4-dmidecode-drop-stderr.patch @@ -0,0 +1,12 @@ +diff -up facter-1.7.4/lib/facter/virtual.rb.dmidecode-drop-stderr facter-1.7.4/lib/facter/virtual.rb +--- facter-1.7.4/lib/facter/virtual.rb.dmidecode-drop-stderr 2013-12-17 15:23:22.000000000 -0500 ++++ facter-1.7.4/lib/facter/virtual.rb 2014-01-28 18:28:27.604949053 -0500 +@@ -133,7 +133,7 @@ Facter.add("virtual") do + end + + # Parse dmidecode +- output = Facter::Util::Resolution.exec('dmidecode') ++ output = Facter::Util::Resolution.exec('dmidecode 2>/dev/null') + if output + lines = output.split("\n") + next "parallels" if lines.any? {|l| l =~ /Parallels/ } diff --git a/facter.spec b/facter.spec index e40cc90..65e70c1 100644 --- a/facter.spec +++ b/facter.spec @@ -28,6 +28,8 @@ License: ASL 2.0 URL: https://puppetlabs.com/%{name} Source0: https://downloads.puppetlabs.com/%{name}/%{name}-%{version}.tar.gz Source1: https://downloads.puppetlabs.com/%{name}/%{name}-%{version}.tar.gz.asc +# https://tickets.puppetlabs.com/browse/FACT-86 +Patch0: facter-1.7.4-dmidecode-drop-stderr.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: ruby >= 1.8.1 @@ -69,6 +71,8 @@ key off the values returned by facts. %prep %setup -q +%patch0 -p1 -b .dmidecode-drop-stderr + %build # Nothing to build @@ -118,6 +122,7 @@ rspec spec * Tue Jan 28 2014 Todd Zullinger - 1.7.4-1 - Update to 1.7.4 - Create /etc/facter/facts.d for external facts +- Send dmiddecode errors to /dev/null in the virtual fact (FACT-86) * Tue Oct 8 2013 Sam Kottler - 1.7.3-1 - Update to 1.7.3 (BZ #1016817)