Bug 821005

Summary: Error message when running the rpm plugin on sosreport
Product: Red Hat Enterprise Linux 6 Reporter: Thias <thias.at.work>
Component: sosAssignee: Bryn M. Reeves <bmr>
Status: CLOSED ERRATA QA Contact: David Kutálek <dkutalek>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.2CC: agk, bmr, gavin, prc
Target Milestone: rcKeywords: EasyFix
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: sos-2.2-30.el6 Doc Type: Bug Fix
Doc Text:
Cause: Previous versions of sos passed an unescaped '~~' (double tilde) character sequence to a command executed by the system shell. Consequence: On some systems expansion of the '~~' sequence results in an error written to syslog when the shell's home directory expansion attempts a lookup for an account named '~', Fix: The sequence is now correctly double-quoted to disable shell expansion of the string. Result: No spurious account lookup or log message is triggered.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 10:57:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Thias 2012-05-11 14:32:43 UTC
Description of problem: 
An error message is rised in the logs when sosreport is run: nslcd[27628]: [364d9d] nslcd_passwd_byname(~): invalid user name

Version-Release number of selected component (if applicable):
yum list | grep sos
sos.noarch                          2.2-17.el6_2.3          @rhel-x86_64-server-6

How reproducible:
This happens every time the sosreport is run (with rpm plugin enabled, and nslcd installed - ldap authentication)

Steps to Reproduce:
1. run sosreport -o rpm
2.
3.
  
Actual results:
May 11 15:33:04 srvname nslcd[27628]: [364d9d] nslcd_passwd_byname(~): invalid user name
is logged in /var/log/messages

Expected results:
No error in /var/log/messages

Additional info:
This most likely comes from the /usr/lib/python2.6/site-packages/sos/plugins/rpm.py file containing:
            self.collectExtOutput("/bin/rpm -qa --qf=\"%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}~~%{INSTALLTIME:date}\n\" --nosignature --nodigest|/bin/awk -F ~~ '{printf \"%-60s%s\\n\",$1,$2}'|sort", root_symlink = "installed-rpms")

instead of

            self.collectExtOutput("/bin/rpm -qa --qf=\"%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}~~%{INSTALLTIME:date}\n\" --nosignature --nodigest|/bin/awk -F '~~' '{printf \"%-60s%s\\n\",$1,$2}'|sort", root_symlink = "installed-rpms")

Comment 2 Bryn M. Reeves 2012-05-11 15:40:39 UTC
Thanks for the report and analysis. You're correct - that unguarded tilde is being expanded by the shell. Since it does not expand to a valid user you get the log message.

It's a cosmetic problem but easily fixed and we should be able to get this into the next available release.

commit ee58ac651a264f5614196493f87b4cf0432f23a6
Author: Bryn M. Reeves <bmr>
Date:   Fri May 11 16:17:01 2012 +0100

    Commit changes for testing on private branch
    Resolves: bz821005

diff --git a/sos-bz821005-rpm-quote-tildes-defensively.patch b/sos-bz821005-rpm-quote-tildes-defensively.patch
new file mode 100644
index 0000000..5a2349d
--- /dev/null
+++ b/sos-bz821005-rpm-quote-tildes-defensively.patch
@@ -0,0 +1,12 @@
+diff -up sos-2.2/sos/plugins/rpm.py.orig sos-2.2/sos/plugins/rpm.py
+--- sos-2.2/sos/plugins/rpm.py.orig    2012-05-11 16:10:11.910118556 +0100
++++ sos-2.2/sos/plugins/rpm.py 2012-05-11 16:11:02.309416127 +0100
+@@ -24,7 +24,7 @@ class rpm(sos.plugintools.PluginBase):
+         self.addCopySpec("/var/log/rpmpkgs")
+ 
+         if self.getOption("rpmq"):
+-            self.collectExtOutput("/bin/rpm -qa --qf=\"%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}~~%{INSTALLTIME:date}\n\" --nosignature --nodigest|/bin/awk -F ~~ '{printf \"%-59s %s\\n\",$1,$2}'|sort", symlink = "installed-rpms")
++            self.collectExtOutput("/bin/rpm -qa --qf=\"%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}~~%{INSTALLTIME:date}\n\" --nosignature --nodigest|/bin/awk -F '~~' '{printf \"%-59s %s\\n\",$1,$2}'|sort", symlink = "installed-rpms")
+ 
+         if self.getOption("rpmva"):
+             self.collectExtOutput("/bin/rpm -Va", symlink = "rpm-Va", timeout = 3600)

I can make packages available for testing if you'd like to check that this resolves the problem for you.

Comment 3 Bryn M. Reeves 2012-05-11 16:16:54 UTC
Test packages are available here:

http://people.redhat.com/breeves/packages/sos/2.2/27.el6_3.1.bz821005/

Comment 4 RHEL Program Management 2012-05-15 04:04:26 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 6 RHEL Program Management 2012-07-10 08:46:54 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 7 RHEL Program Management 2012-07-11 01:58:30 UTC
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.

Comment 12 errata-xmlrpc 2013-02-21 10:57:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0474.html