Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1945481

Summary: [insights-client|Bug] System motd should not be modified if already set
Product: Red Hat Enterprise Linux 8 Reporter: Bryan Kinney <bkinney>
Component: insights-clientAssignee: Link Dupont <link>
Status: CLOSED ERRATA QA Contact: Pavol Kotvan <pakotvan>
Severity: high Docs Contact:
Priority: high    
Version: 8.2CC: cww, gmccullo, jcrafts, kdixon, link, peter.vreman, prgutier
Target Milestone: betaKeywords: Triaged, ZStream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 3.1.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-08-10 14:00:02 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 Bryan Kinney 2021-04-01 05:25:36 UTC
Description of problem:
The insights-client is modifying the /etc/motd.d/insights-client file even though the symlink already exists.
If that symlink already exist it should not be modified.

The init should check if the symlink exists first before trying to modify it.
   https://github.com/RedHatInsights/insights-client/blob/28ce32e3b05adc2a370e3c54dbe7318b2492be14/src/insights_client/__init__.py#L137

The symlink's mtime is evidence that the file was changed by insights-client.
System files that are already set, should not be changed.


Version-Release number of selected component (if applicable):
insights-client 3.1.x

How reproducible:

Steps to Reproduce:
1. On clean RHEL 8 server setup a symbolic link /etc/motd.d/insights-client to /dev/null
2. Check the mtime manually or with Puppet
3. Register the server with insights-client
4. Check the mtime of the symlink

Actual results:
Symlink is edited and automation scripting like Puppet and etc pick up the mtime difference.
A pre-existing system file has been modified.

Expected results:
insights-client should check if system file exist already.
If so no changes should be made to that file.
Log the error for diagnosis if possible.

Additional info:
This is a correction of the code change made to satisfy bugzilla case: https://bugzilla.redhat.com/show_bug.cgi?id=1806156

Comment 4 Bryan Kinney 2021-05-24 08:22:13 UTC
Could you confirm that version 3.1.4 will be available to RHEL 7.9 as well?
I assume that RHEL 8.5.0 is just the OS where the client version 3.1.4 will be installed by default.

Comment 5 jcrafts 2021-05-24 17:39:43 UTC
Yup, we'll be targeting a z-stream release for 7.9 at the next possible opportunity.

Comment 6 Link Dupont 2021-05-24 17:42:21 UTC
This bug in particular shouldn't be affecting RHEL 7.9, as it does not have a pam_motd.so module that supports /etc/motd.d. We will probably be backporting insights-client 3.1.4 into RHEL 7.9 for another bug fix, but this bug won't be cloned and targeted to RHEL 7.9. The backport will be fixing a different bug.

Comment 7 jcrafts 2021-05-24 21:26:13 UTC
Ah yep... mistook this bug for a separate one. Carry on.

Comment 8 Peter Vreman 2021-05-26 11:49:29 UTC
Link,

Even that RHEL7.9 does not have pam_motd.so the insights-client is still touching and modifying the SELinux content on the /etc/motd.d/insighst-client file even it content is not change (and maybe even not used, but i cannot test it because it already do not want it be seen)

Below the reproducer that proves that RHEL7.9 insight-client is also impacted and modifying the SELInux content and modifying the ctime and mtime.
------
vrempet-admin@li-lc-1437 ~
$ rpm -q insights-client
insights-client-3.1.1-1.el7_9.noarch

vrempet-admin@li-lc-1437 ~
$ sudo insights-client --version
Client: 3.1.1
Core: 3.0.222-1

vrempet-admin@li-lc-1437 ~
$ ls -lZ /etc/motd.d/insights-client
lrwxrwxrwx. root root system_u:object_r:etc_t:s0       /etc/motd.d/insights-client -> /dev/null

vrempet-admin@li-lc-1437 ~
$ ls -l /etc/motd.d/insights-client
lrwxrwxrwx. 1 root root 9 May 26 01:34 /etc/motd.d/insights-client -> /dev/null

vrempet-admin@li-lc-1437 ~
$ stat /etc/motd.d/insights-client
  File: ‘/etc/motd.d/insights-client’ -> ‘/dev/null’
  Size: 9               Blocks: 0          IO Block: 4096   symbolic link
Device: fd00h/64768d    Inode: 1893        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:etc_t:s0
Access: 2021-05-26 02:06:53.700383564 +0000
Modify: 2021-05-26 01:34:07.651863779 +0000
Change: 2021-05-26 01:34:07.651863779 +0000
 Birth: -

vrempet-admin@li-lc-1437 ~
$ sudo insights-client
Starting to collect Insights data for [crash/LI/IPS/OSDev-7.9-backup] li-lc-1437.hag.hilti.com
Uploading Insights data.
Successfully uploaded report from [crash/LI/IPS/OSDev-7.9-backup] li-lc-1437.hag.hilti.com to account XXXXXXXXXX.
View details about this system on cloud.redhat.com:
https://cloud.redhat.com/insights/inventory/xxxxxxxxxxxxxxxx

vrempet-admin@li-lc-1437 ~
$ date
Wed May 26 11:29:44 UTC 2021

vrempet-admin@li-lc-1437 ~
$ ls -lZ /etc/motd.d/insights-client
lrwxrwxrwx. root root unconfined_u:object_r:etc_t:s0   /etc/motd.d/insights-client -> /dev/null

vrempet-admin@li-lc-1437 ~
$ stat /etc/motd.d/insights-client
  File: ‘/etc/motd.d/insights-client’ -> ‘/dev/null’
  Size: 9               Blocks: 0          IO Block: 4096   symbolic link
Device: fd00h/64768d    Inode: 1893        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:etc_t:s0
Access: 2021-05-26 11:29:48.531341224 +0000
Modify: 2021-05-26 11:29:40.803215768 +0000
Change: 2021-05-26 11:29:40.803215768 +0000
 Birth: -

vrempet-admin@li-lc-1437 ~
$
------------

Comment 9 Link Dupont 2021-05-26 13:17:03 UTC
Wow, thank you Peter. That's a very interesting point. I need to double-check which version of PAM introduced the motd.d support, but, assuming that RHEL 7.9 does not have /etc/motd.d support, I think the fix for RHEL 7.9 is to make sure that /etc/motd.d/insights-client is never created in the first place.

Comment 10 Link Dupont 2021-05-26 13:31:20 UTC
[root@rhel7-devbox ~]# rpm -q pam
pam-1.1.8-23.el7.x86_64

Looks like /etc/motd.d was added to PAM around pam-1.4.0. So RHEL 7.9 doesn't support /etc/motd.d. We should stop insights-client from creating /etc/motd.d/insights-client on RHEL 7.9. I'll open another bug for that.

Comment 13 Bryan Kinney 2021-07-15 00:49:51 UTC
Hello,

Does mean the insights-client will no longer touch the motd file?
Is this available in 8.5.0-17 zstream?
Could the fixed insights-client version be given as well?

Bryan

Comment 22 errata-xmlrpc 2021-08-10 14:00:02 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 (insights-client bug fix and enhancement update), 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-2021:3080