Send dmidecode errors to /dev/null in the virtual fact

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
epel9
Todd Zullinger 11 years ago
parent e6aaf2ad61
commit 938d3cb881

@ -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/ }

@ -28,6 +28,8 @@ License: ASL 2.0
URL: https://puppetlabs.com/%{name} URL: https://puppetlabs.com/%{name}
Source0: https://downloads.puppetlabs.com/%{name}/%{name}-%{version}.tar.gz Source0: https://downloads.puppetlabs.com/%{name}/%{name}-%{version}.tar.gz
Source1: https://downloads.puppetlabs.com/%{name}/%{name}-%{version}.tar.gz.asc 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) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ruby >= 1.8.1 BuildRequires: ruby >= 1.8.1
@ -69,6 +71,8 @@ key off the values returned by facts.
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .dmidecode-drop-stderr
%build %build
# Nothing to build # Nothing to build
@ -118,6 +122,7 @@ rspec spec
* Tue Jan 28 2014 Todd Zullinger <tmz@pobox.com> - 1.7.4-1 * Tue Jan 28 2014 Todd Zullinger <tmz@pobox.com> - 1.7.4-1
- Update to 1.7.4 - Update to 1.7.4
- Create /etc/facter/facts.d for external facts - 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 <skottler@fedoraproject.org> - 1.7.3-1 * Tue Oct 8 2013 Sam Kottler <skottler@fedoraproject.org> - 1.7.3-1
- Update to 1.7.3 (BZ #1016817) - Update to 1.7.3 (BZ #1016817)

Loading…
Cancel
Save