Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SELinux policy rules allowing to create directories under /root #1908

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

grulja
Copy link
Contributor

@grulja grulja commented Feb 7, 2025

We have policy that allows to create ~/.local or ~/.config, but we don't have rule that allows the same under /root directory, where we fail in case any of these directories doesn't exist.

@grulja
Copy link
Contributor Author

grulja commented Feb 7, 2025

This is an attempt to fix https://issues.redhat.com/browse/RHEL-77975. I don't really have SELinux knowledge so it's mostly guessing and opened for a discussion. I also haven't tried it yet. Maybe this gives Tigervnc permission we don't need, but I don't really know.

CCing @zpytela for help.

@grulja
Copy link
Contributor Author

grulja commented Feb 7, 2025

Hmm, it looks we already have ability to create at least ~/.local thanks to:

# Allowed to create ~/.local
optional_policy(`
	gnome_filetrans_home_content(vnc_session_t)
')

So some additions I did are most likely not necessary.

@grulja grulja marked this pull request as draft February 8, 2025 08:35
@grulja grulja force-pushed the selinux-non-existing-dirs branch from 82fd7b6 to 0528bf4 Compare February 12, 2025 08:18
@grulja grulja changed the title Add SELinux policy rules for non-existing directories Add SELinux policy rules allowing to create directories under /root Feb 12, 2025
@grulja
Copy link
Contributor Author

grulja commented Feb 12, 2025

So I think this is close to be working, but it's still missing one thing. The code I added now allows to create /root/.local/state/tigervnc, but tigervnc folder is labeled as admin_home_t and I don't know how to change that.
Obviously running restorecon -Rv /root/.local/state/tigervnc fixes it and it starts to work.

I tried adding:

diff --git a/unix/vncserver/selinux/vncsession.te b/unix/vncserver/selinux/vncsession.te
index e1ed6c11..93fdeaa4 100644
--- a/unix/vncserver/selinux/vncsession.te
+++ b/unix/vncserver/selinux/vncsession.te
@@ -97,6 +97,7 @@ optional_policy(`
                attribute userdomain;
                type gconf_home_t;
        ')
+       userdom_admin_home_dir_filetrans(userdomain, vnc_home_t, dir, ".local")
        userdom_admin_home_dir_filetrans(userdomain, vnc_home_t, dir, ".vnc")
        userdom_user_home_dir_filetrans(userdomain, vnc_home_t, dir, ".vnc")

But that's not it.

@zpytela would you know please? Thank you.

We have policy that allows to create ~/.local or ~/.config, but we don't
have rule that allows the same under /root directory, where we fail in
case any of these directories doesn't exist.
@grulja grulja force-pushed the selinux-non-existing-dirs branch from 0528bf4 to e652f06 Compare February 13, 2025 08:00
@grulja
Copy link
Contributor Author

grulja commented Feb 13, 2025

Alright, after reading some documentation and testing it now seems to work as expected.

@grulja grulja marked this pull request as ready for review February 13, 2025 08:00
Copy link
Member

@CendioOssman CendioOssman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can confirm it fixes the issue here as well. Tested on Fedora 41.

@CendioOssman CendioOssman merged commit 6d10241 into TigerVNC:master Feb 25, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants