Bug 2100528 - %systemd_user_postun_with_restart spews errors and doesn't work
Summary: %systemd_user_postun_with_restart spews errors and doesn't work
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 35
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Zdenek Pytela
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2106722 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-06-23 15:47 UTC by Maxwell G
Modified: 2022-10-02 02:43 UTC (History)
21 users (show)

Fixed In Version: selinux-policy-35.19-1.fc35
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-10-02 02:43:04 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Journalctl Log (7.69 KB, text/plain)
2022-06-23 17:36 UTC, Maxwell G
no flags Details
ausearch output without dontaudit (6.01 KB, text/plain)
2022-06-23 20:31 UTC, Maxwell G
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github fedora-selinux selinux-policy pull 1272 0 None open Support using systemd-update-helper in rpm scriptlets 2022-07-09 16:04:02 UTC

Description Maxwell G 2022-06-23 15:47:06 UTC
Description of problem:
%systemd_user_postun_with_restart spews errors and doesn't work

Version-Release number of selected component (if applicable):
systemd-rpm-macros-249.12-5.fc35.noarch

How reproducible:
Always

Steps to Reproduce:
See https://paste.sr.ht/~gotmax23/4c65f75a120cb8563eac191a48d5df92bba7429c for the steps to reproduce.

Actual results:
Failed to start transient service unit: Connection reset by peer
Failed to set unit properties on syncthing.service: Transport endpoint is not connected

Service doesn't restart

Expected results:

The service should restart and the macro shouldn't print a bunch of error messages.

Additional info:

There were similar issues with this macro in the past:

https://bugzilla.redhat.com/show_bug.cgi?id=2020374
https://bugzilla.redhat.com/show_bug.cgi?id=2020415

Comment 1 Zbigniew Jędrzejewski-Szmek 2022-06-23 16:11:40 UTC
Please don't use pastebins for bug reports: those pages are dropped after some time, and then
the bug report will be completely useless.

I suppose this could be related to selinux. Can you attach the output from 'journalctl -b' from
around the upgrade?

Comment 2 Maxwell G 2022-06-23 17:35:16 UTC
> Please don't use pastebins for bug reports: those pages are dropped after some time, and then
the bug report will be completely useless.

I purposely used a pastebin that doesn't delete anything :). I don't like that either.

> I suppose this could be related to selinux. 

Yes, it works fine when selinux is set to Permissive.

> Can you attach the output from 'journalctl -b' from
around the upgrade?

Sure.

Comment 3 Maxwell G 2022-06-23 17:36:12 UTC
Created attachment 1892237 [details]
Journalctl Log

Comment 4 Zbigniew Jędrzejewski-Szmek 2022-06-23 19:06:37 UTC
Unfortunately I don't see any avcs in the log. But anyway, if it works with Permissive, it's 
a question of a policy update.

Comment 5 Milos Malik 2022-06-23 19:34:57 UTC
It's possible that certain SELinux denials are hidden. The following command removes the dontaudit rules from active policy:

# semodule -DB

Re-run the Steps to Reproduce.

Please collect the SELinux denials that appeared in last 10 minutes:

# ausearch -m avc -m user_avc -m selinux_err -i -ts recent

Attach them here.

Thank you.

Comment 6 Milos Malik 2022-06-23 19:36:17 UTC
The following command returns the dontaudit rules back to active policy:

# semodule -B

Comment 7 Maxwell G 2022-06-23 20:31:58 UTC
Created attachment 1892300 [details]
ausearch output without dontaudit

Comment 8 Maxwell G 2022-06-23 20:33:57 UTC
> It's possible that certain SELinux denials are hidden.

Yes, that seems to be the case. I was surprised to see no denials in the audit log when I first checked.

Comment 9 Milos Malik 2022-06-23 21:23:28 UTC
Relevant part of https://paste.sr.ht/~gotmax23/4c65f75a120cb8563eac191a48d5df92bba7429c

  Running scriptlet: syncthing-1.20.2-1.fc35.x86_64                                                             2/2 
Failed to start transient service unit: Connection reset by peer
Failed to set unit properties on syncthing.service: Transport endpoint is not connected

Above-mentioned error messages indicate that the following SELinux denials can cause the problem:

----
type=AVC msg=audit(06/23/2022 15:31:28.730:2712) : avc:  denied  { read write } for  pid=871 comm=dbus-broker path=socket:[2405808] dev="sockfs" ino=2405808 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:rpm_script_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=0 
----
type=AVC msg=audit(06/23/2022 15:31:28.740:2713) : avc:  denied  { read write } for  pid=871 comm=dbus-broker path=socket:[2407739] dev="sockfs" ino=2407739 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:rpm_script_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=0 
----

Here is a policy module which can solve the problem:

# cat testpolicy.cil
( allow system_dbusd_t rpm_script_t ( unix_stream_socket ( read write )))
# semodule -i testpolicy.cil
#

Let me know if the situation improved.

To remove the policy module, please use the following command:

# semodule -r testpolicy

Comment 10 Maxwell G 2022-06-23 23:01:48 UTC
I was able to get it work with

$ cat testpolicy.cil                                                                          
( allow system_dbusd_t rpm_script_t ( unix_stream_socket ( read write )))
( allow init_t rpm_script_t ( unix_stream_socket ( read write )))

Comment 11 Fabio Valentini 2022-07-08 08:53:14 UTC
This also affected the recent GNOME updates in F36:

(...)
  Cleanup          : gnome-remote-desktop-42.2-2.fc36.x86_64              33/50 
  Running scriptlet: gnome-remote-desktop-42.2-2.fc36.x86_64              33/50 
Failed to start transient service unit: Connection reset by peer
Failed to set unit properties on gnome-remote-desktop.service: Transport endpoint is not connected
(...)
  Cleanup          : tracker-3.3.1-1.fc36.x86_64                          45/50 
  Running scriptlet: tracker-3.3.1-1.fc36.x86_64                          45/50 
Failed to start transient service unit: Connection reset by peer
Failed to set unit properties on tracker-xdg-portal-3.service: Transport endpoint is not connected
(...)

Comment 12 Fabio Valentini 2022-07-13 11:34:04 UTC
*** Bug 2106722 has been marked as a duplicate of this bug. ***

Comment 13 Fedora Update System 2022-09-16 09:00:51 UTC
FEDORA-2022-b6f216be9a has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-b6f216be9a

Comment 14 Fedora Update System 2022-09-17 01:43:22 UTC
FEDORA-2022-b6f216be9a has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-b6f216be9a`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-b6f216be9a

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 15 Fedora Update System 2022-10-02 02:43:04 UTC
FEDORA-2022-b6f216be9a has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.


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