Bug 2012145
| Summary: | Make selinux config parser more robust | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Thorsten Scherf <tscherf> |
| Component: | libselinux | Assignee: | Vit Mojzis <vmojzis> |
| Status: | CLOSED ERRATA | QA Contact: | Amith <apeetham> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 8.4 | CC: | dwalsh, lvrabec, mmalik, plautrba, ssekidde, vmojzis |
| Target Milestone: | rc | Keywords: | Triaged |
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | libselinux-2.9-6.el8 | Doc Type: | No Doc Update |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2022-11-08 10:54:52 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Thorsten Scherf
2021-10-08 12:15:27 UTC
(In reply to Thorsten Scherf from comment #0) > Description of problem: > Any typo in /etc/selinux/config will create issues during package > installation when the config can't be parsed as expected. A typo in /etc/selinux/config means that libselinux is misconfigured and errors during package installation is just a side effect. > E.g., "SELINUXTYPE= targeted" (note the space after '=') will result in the > following yum error: > > RPM: error: selabel_open (/etc/selinux/ > targeted/contexts/files/files_contexts) No such file or directory > RPM: error: Plugin selinux: hook tsm_pre failed > Error: Could not run transaction Spaces at the end of SELINUXTYPE value is already stripped so I guess spaces on the beginning could be stripped as well. But there's no way how to make it more robust if there's a different typo of typo like SELINUXTYPE=Xtargeted For libselinux it means that the admin wants to use SELinux policy called 'Xtargeted' which is supposed to have files in '/etc/selinux/Xtargeted' and '/var/lib/selinux/Xtargeted' > The same issue occurs when you put some invalid configuration values into > /etc/selinux/config: > > E.g.; "SELINUXTYPE=disabled" (valid configuration values would be > "targeted", "minimum", or "mls". There's no such thing as a valid value for SELINUXTYPE. In Red Hat Enterprise Linux we package "targeted", "minimum", or "mls", but there's also upstream policy called "refpolicy" - https://github.com/SELinuxProject/refpolicy and others. The type of policy is set during build process and users could simply rebuild "targeted" policy and called it "test" and it would be valid. The simplest way how to check whether SELINUXTYPE is valid is to run `semodule -l` If there's "No modules", something is wrong: # semodule -l No modules. Users could get also some helpful information from `sestatus`: # sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: test Current mode: permissive Mode from config file: permissive Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33 As you can see, "Loaded policy name: test" which is probably not correct. Looking into '/etc/selinux/config' I see a misleading comment: # SELINUXTYPE= can take one of these three values: This is not exactly correct. As I already wrote, these 3 policies are packaged in Red Hat Enterprise Linux but SELINUXTYPE could be anything. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (libselinux bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2022:7786 |