Bug 1478118

Summary: system update blocked by PREIN error in setroubleshoot-server
Product: Red Hat Enterprise Linux 7 Reporter: Przemek Klosowski <przemek>
Component: setroubleshootAssignee: Vit Mojzis <vmojzis>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: dapospis, lvrabec, mgrepl, mmalik, plautrba, przemek
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 09:47:31 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 Przemek Klosowski 2017-08-03 15:41:54 UTC
Description of problem:
system update blocked by PREIN error in setroubleshoot-server

Version-Release number of selected component (if applicable):
setroubleshoot-server.x86_64 0:3.2.27.2-3.el7

How reproducible: every time

Steps to Reproduce:
1.yum update

Actual results:
Loaded plugins: product-id, search-disabled-repos, subscription-manager
Resolving Dependencies
--> Running transaction check
---> Package setroubleshoot-server.x86_64 0:3.2.27.2-3.el7 will be updated
---> Package setroubleshoot-server.x86_64 0:3.2.28-3.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================
 Package                                             Arch                                 Version                                       Repository                                        Size
===============================================================================================================================================================================================
Updating:
 setroubleshoot-server                               x86_64                               3.2.28-3.el7                                  rhel-7-server-rpms                               384 k

Transaction Summary
===============================================================================================================================================================================================
Upgrade  1 Package

Total download size: 384 k
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for rhel-7-server-rpms
setroubleshoot-server-3.2.28-3.el7.x86_64.rpm                                                                                                                           | 384 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
useradd: group setroubleshoot exists - if you want to add this user to that group, use -g.
error: %pre(setroubleshoot-server-3.2.28-3.el7.x86_64) scriptlet failed, exit status 9
Error in PREIN scriptlet in rpm package setroubleshoot-server-3.2.28-3.el7.x86_64
setroubleshoot-server-3.2.27.2-3.el7.x86_64 was supposed to be removed but is not!
  Verifying  : setroubleshoot-server-3.2.27.2-3.el7.x86_64                                                                                                                                 1/2 
  Verifying  : setroubleshoot-server-3.2.28-3.el7.x86_64                                                                                                                                   2/2 

Failed:
  setroubleshoot-server.x86_64 0:3.2.27.2-3.el7                                                   setroubleshoot-server.x86_64 0:3.2.28-3.el7                                                  

Complete!


Expected results: successful update without errors

Comment 2 Przemek Klosowski 2017-08-03 15:47:17 UTC
A workaround is to delete the packages and group setroubleshoot, and reinstall:
yum erase setroubleshoot*
groupdel setroubleshoot
yum install setroubleshoot*

Comment 3 Milos Malik 2017-08-04 09:14:35 UTC
I managed to reproduce the situation you described, but I had to delete the setroubleshoot user and then create the setroubleshoot group manually.

Could you run following commands before "yum update" on the machine where the situation still happens?

# getent passwd setroubleshoot
# getent group setroubleshoot

Thank you!

Comment 4 Petr Lautrbach 2017-08-04 12:45:12 UTC
We could be more defensive and check for the existence of setroubleshoot group first:

diff --git a/setroubleshoot.spec b/setroubleshoot.spec
index 98cff01..608df0d 100644
--- a/setroubleshoot.spec
+++ b/setroubleshoot.spec
@@ -124,7 +124,8 @@ about the problem and help track its resolution. Alerts can be configured
 to user preference. The same tools can be run on existing log files.
 
 %pre server
-getent passwd %{username} >/dev/null || useradd -r -U -s /sbin/nologin -d %{pkgvardatadir} %{username}
+getent group %{username} >/dev/null || groupadd -r %{username}
+getent passwd %{username} >/dev/null || useradd -r -g %{username} -s /sbin/nologin -d %{pkgvardatadir} %{username}
 
 %post server
 %systemd_post auditd.service

Comment 5 Przemek Klosowski 2017-08-04 14:18:12 UTC
sorry, I don't have a machine with this problem any more. I did check that when the problem was appearing, the group 'setroubleshoot' existed in /etc/group (IIRC group number was 993) but the user 'setroubleshoot' did not appear in /etc/passwd
After I executed my workaround, the group and user were created.

[root@comsolcalc comsol]#  getent passwd setroubleshoot
setroubleshoot:x:994:989::/var/lib/setroubleshoot:/sbin/nologin
[root@comsolcalc comsol]# getent group setroubleshoot
setroubleshoot:x:989:

This may be related to the fact that we are trying to apply CIS hardening guidelines, which include removing setroubleshoot. Now, the root cause of this may be some RPM packaging issues: I noticed that erasing setroubleshoot does not affect setroubleshoot{-plugins,-server}, so there may be some cleanup issues. We may have removed and reinstalled setroubleshoot while messing with the CIS ansible rules. Please take a look at the pre/postinst scripts: perhaps they mess up group/user creation and/or detection when the package is installed/removed.

Comment 9 errata-xmlrpc 2018-10-30 09:47:31 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.

https://access.redhat.com/errata/RHBA-2018:3100