Bug 2224162 - selinux denial prevents logging in
Summary: selinux denial prevents logging in
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: tuigreet
Version: 38
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Aleksei Bavshin
QA Contact:
URL: https://lists.sr.ht/~kennylevinsen/gr...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-20 03:44 UTC by Jeff Peeler
Modified: 2023-07-28 02:43 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-07-28 02:43:45 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Jeff Peeler 2023-07-20 03:44:28 UTC
I originally reported this upstream as I didn't even consider SELinux initially. The denials I was getting were:

type=AVC msg=audit(1688321821.033:2282): avc:  denied  { transition } for  pid=386427 comm="greetd" path="/usr/bin/bash" dev="dm-1" ino=1720366 scontext=system_u:system_r:unconfined_service_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0 tclass=process permissive=0

echo 'type=AVC msg=audit(1688321821.033:2282): avc:  denied  { transition } for  pid=386427 comm="greetd" path="/usr/bin/bash" dev="dm-1" ino=1720366 scontext=system_u:system_r:unconfined_service_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0 tclass=process permissive=0' | audit2allow -M greetd-pol
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i greetd-pol.pp

---
After making the above policy change everything works.

Reproducible: Always

Steps to Reproduce:
1. Attempt to login (on silverblue)
Actual Results:  
Logging in is not possible

Expected Results:  
Logging in success

See the URL for some additional, but maybe unnecessary context.

Comment 2 Aleksei Bavshin 2023-07-20 04:57:25 UTC
> scontext=system_u:system_r:unconfined_service_t:s0

That doesn't look right. `/usr/bin/greetd` should be labeled as `system_u:object_r:xdm_exec_t:s0` and transition to `system_u:system_r:xdm_t:s0-*` on start.
Can you check if you have `greetd-selinux` installed and there's no unlabeled greetd binary in /usr/local/bin?

Comment 3 Jeff Peeler 2023-07-22 01:51:01 UTC
$ ls -lZ /usr/bin/greetd
-rwxr-xr-x. 3 root root system_u:object_r:bin_t:s0 839488 Dec 31  1969 /usr/bin/greetd*

$ rpm -q greetd-selinux
greetd-selinux-0.9.0-4.fc38.noarch

There are no other greetd binaries. I can try reinstalling greetd if you'd like, but how do I undo the policy changes that were recommended above?

Also, I'm sorry that I failed to mention that this is on Silverblue.

$ rpm -ql greetd-selinux
/usr/share/selinux/packages/targeted/greetd.pp.bz2
/var/lib/selinux/targeted/active/modules/200/greetd

I noticed that the second file isn't on the filesystem. But when I installed it inside a toolbox container it is present as expected.

Comment 4 Aleksei Bavshin 2023-07-26 05:11:02 UTC
On a clean Sericea VM:

$ rpm-ostree install greetd tuigreet
$ systemctl reboot
<...>
$ rpm-ostree status
...
LayeredPackages: greetd tuigreet
$ ls -Z /usr/bin/greetd
system_u:object_r:xdm_exec_t:s0 /usr/bin/greetd
# semodule -lfull |grep greetd
200 greetd            pp
# semodule -lstandard |grep greetd
greetd
# semanage fcontext -l |grep greetd
/etc/greetd(/.*)?                                  all files          system_u:object_r:xdm_etc_t:s0
/usr/bin/greetd                                    regular file       system_u:object_r:xdm_exec_t:s0
/var/lib/greetd(/.*)?                              all files          system_u:object_r:xdm_var_lib_t:s0
/var/run/greetd[^/]*\.sock                         socket             system_u:object_r:xdm_var_run_t:s0
/var/run/greetd\.run                               regular file       system_u:object_r:xdm_var_run_t:s0

I'm pretty sure this worked on Silverblue as well. Have no idea what went wrong on your system. 
Do you see the same output from the semodule/semanage commands above? Is there anything in the journal mentioning SELinux module errors?

> how do I undo the policy changes that were recommended above?

semodule -r greetd-pol

Comment 5 Jeff Peeler 2023-07-28 02:43:45 UTC
Apologies, I'm closing this. I'm running my own Ublue image and recognize now that there are all kinds of things that can go wrong in doing so.

https://github.com/ublue-os/main/issues/223


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