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

shouldn't selinux::fcontext do the necessary exec_restorecon ? #322

Open
dvanders opened this issue May 5, 2020 · 2 comments
Open

shouldn't selinux::fcontext do the necessary exec_restorecon ? #322

dvanders opened this issue May 5, 2020 · 2 comments

Comments

@dvanders
Copy link

dvanders commented May 5, 2020

Normally when we persist an fcontext change we need to also use restorecon to apply the change [1].
It can happen that users are unaware of this requirement, and expect that the selinux::fcontext alone is sufficient.
So, I propose that we either document this minor annoyance in the list of known issues/limitations or, better, add an optional feature to selinux::fcontext to manage the implied selinux::exec_restorecon.

E.g. I'm proposing that it should be sufficient to do:

selinux::fcontext { '/var/www/usage':
  seltype  => 'httpd_sys_content_t',
}

but users currently need to do:

selinux::fcontext { '/var/www/usage':
  seltype  => 'httpd_sys_content_t',
}
~> selinux::exec_restorecon { '/var/www/usage': }

Thanks!

[1] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/sect-security-enhanced_linux-working_with_selinux-selinux_contexts_labeling_files#sect-Security-Enhanced_Linux-SELinux_Contexts_Labeling_Files-Persistent_Changes_semanage_fcontext

@ekohl
Copy link
Member

ekohl commented May 5, 2020

A parameter exec_restorecon_on_change (or similar) makes sense to me. Just for compatibility with previous versions I'm leaning to defaulting to false. An additional reason to do it inside the define is that you can nicely encapsulate the behavior.

Could you come up with a patch for this?

@bschonec
Copy link

bschonec commented Mar 21, 2024

I've been struggling with this same problem for the last two days. Only today did I realize that exec_restorecon needs to be invoked in code in order for the context to be applied. At the very least, the README.md should be updated.

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

No branches or pull requests

3 participants