This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
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 2112001 - cron should not be using pam_systemd, leading to CRED failed in audit
Summary: cron should not be using pam_systemd, leading to CRED failed in audit
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: systemd
Version: 9.0
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Michal Sekletar
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On: 2053750
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-28 15:15 UTC by Welterlen Benoit
Modified: 2023-09-21 11:52 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2053750
Environment:
Last Closed: 2023-09-21 11:52:52 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   RHEL-5919 0 None Migrated None 2023-09-21 11:51:36 UTC
Red Hat Issue Tracker RHELPLAN-129495 0 None None None 2022-07-28 15:38:42 UTC

Description Welterlen Benoit 2022-07-28 15:15:52 UTC
+++ This bug was initially created as a clone of Bug #2053750 +++

Description of problem:
Every user cron job is spamming the logs with systemd session messages.

In RHEL9, we also have an CRED error in audit:

type=CRED_ACQ msg=audit(07/18/22 14:34:01.335:375) : pid=4429 uid=root auid=unset ses=unset subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_env,pam_unix acct=test exe=/usr/sbin/crond hostname=? addr=? terminal=cron res=success' 
type=CRED_ACQ msg=audit(07/18/22 14:34:01.478:379) : pid=4432 uid=root auid=unset ses=unset subj=system_u:system_r:init_t:s0 msg='op=PAM:setcred grantors=? acct=test exe=/usr/lib/systemd/systemd hostname=? addr=? terminal=? res=failed'  

Version-Release number of selected component (if applicable):
cronie-1.5.7-5.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create a cron job for a user at some reasonably high frequency, say every 5 minutes
2. Wait for cron job to fire

Actual results:
For every job, messages file is spammed with the like of:

04:06:01 systemd Created slice User Slice of UID 1001.
04:06:01 systemd Starting User runtime directory /run/user/1001...
04:06:01 systemd Started User runtime directory /run/user/1001.
04:06:01 systemd Starting User Manager for UID 1001...
04:06:02 systemd Starting D-Bus User Message Bus Socket.
04:06:02 systemd Started Mark boot as successful after the user session has run 2 minutes.
04:06:02 systemd Reached target Timers.
04:06:02 systemd Reached target Paths.
04:06:02 systemd Listening on D-Bus User Message Bus Socket.
04:06:02 systemd Reached target Sockets.
04:06:02 systemd Reached target Basic System.
04:06:02 systemd Started User Manager for UID 1001.
04:06:02 systemd Reached target Default.
04:06:02 systemd Startup finished in 65ms.
04:06:02 systemd pam_unix(systemd-user:session): session opened for user brian by (uid=0)
04:06:06 systemd session-2180.scope: Succeeded.
04:06:13 systemd session-2177.scope: Succeeded.
04:06:16 systemd Stopping User Manager for UID 1001...
04:06:16 systemd Stopped target Default.
04:06:16 systemd Stopped target Basic System.
04:06:16 systemd Stopped target Timers.
04:06:16 systemd Stopped Mark boot as successful after the user session has run 2 minutes.
04:06:16 systemd Stopped target Paths.
04:06:16 systemd Stopped target Sockets.
04:06:16 systemd Closed D-Bus User Message Bus Socket.
04:06:16 systemd Reached target Shutdown.
04:06:16 systemd Starting Exit the Session...
04:06:16 systemd user: Succeeded.
04:06:16 systemd Stopped User Manager for UID 1001.
04:06:16 systemd Stopping User runtime directory /run/user/1001...
04:06:16 systemd run-user-1001.mount: Succeeded.
04:06:16 systemd user-runtime-dir: Succeeded.
04:06:16 systemd Stopped User runtime directory /run/user/1001.
04:06:16 systemd Removed slice User Slice of UID 1001.
04:06:16 systemd pam_unix(systemd-user:session): session closed for user brian

in audit:

type=CRED_ACQ msg=audit(07/18/22 14:34:01.478:379) : pid=4432 uid=root auid=unset ses=unset subj=system_u:system_r:init_t:s0 msg='op=PAM:setcred grantors=? acct=test exe=/usr/lib/systemd/systemd hostname=? addr=? terminal=? res=failed'  

Expected results:
No landslide of systemd spam for each and every cron job run
No CRED fail in audit

Additional info:

I workaround that with this pam system-auth config:

---
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authselect is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so try_first_pass nullok
auth        required      pam_deny.so

account     required      pam_unix.so

password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password    sufficient    pam_unix.so try_first_pass use_authtok nullok sha512 shadow
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
-session     optional      pam_systemd.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
---

Comment 1 Iker Pedrosa 2022-09-01 13:34:08 UTC
I guess your proposal would be to change system-auth. More specifically to move the following one line above:
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid

From:
session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
-session     optional      pam_systemd.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so

To:
session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
-session     optional      pam_systemd.so
session     required      pam_unix.so

Comment 2 Welterlen Benoit 2022-09-01 13:49:46 UTC
My proposal is to not use pam_systemd in case of crond, thus add "session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid" before "-session     optional      pam_systemd.so"

This line is currently before "session     required      pam_unix.so"
I don't know if pam_unix is required in case of crond or not ...

Tx

Comment 3 Pavel Březina 2022-09-09 09:22:38 UTC
I would like to hear opinions from systemd developers. It sounds like pam_systemd shouldn't be run for session of automated services, but perhaps this is something to implement directly in pam_systemd? Iker will check.

Comment 4 Iker Pedrosa 2022-09-09 13:37:48 UTC
Michal do you think it would be possible to bypass services requests in pam_systemd? They wouldn't need to run all the pam_systemd workflow and we would avoid all this noise.

Comment 5 Michal Sekletar 2022-10-10 15:59:51 UTC
Hello, if pam_systemd.so is invoked as part of the session setup then generally speaking users get two main "side effects". First is associated .scope unit and ability to do resource management of this session through systemd and second is systemd --user instance for the user (if it isn't running yet). We want to introduce ability to avoid starting the --user instance for some sessions (e.g. cron sessions). Couple months ago I've posted the PR to add this https://github.com/systemd/systemd/pull/23569 however latter we reverted the change because Lennart had some reservations regarding the overall design. Since then I haven't spent more time on this but this BZ is a good reminder I need to get back to it.

Comment 6 Iker Pedrosa 2022-10-11 06:59:32 UTC
Thanks for the information. It seems like this bugzilla belongs to systemd, so I'm assigning it to you. I hope it helps you drive this effort forward.

Comment 7 RHEL Program Management 2023-09-21 11:47:46 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 8 RHEL Program Management 2023-09-21 11:52:52 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.