This show has been flagged as Clean by the host.
The most basic security toggle on your Linux computer is the
command. Using just a single instruction, you can configure SELinux to allow a violation it would normally prevent. There are two states: Enabled and Permissive. By default, SELinux is (also represented as when using Boolean values). To set SELinux to permissive mode:
When something works in Permissive mode, you've successfully identified the symptom, but you haven't fixed the problem yet. Activate Enforcing mode again:
Check the status of SELinux
You can check the state of SELinux at any time using the
command:
Look at labels and contexts
If you have a running Linux system, then you have an example of what SELinux requires for normal operation. You don't have to learn about security contexts or memorize labels. For most anything you try to do on your computer, there are likely already files doing something similar. Use those files as templates.
You can look at the security labels of any file you have access to by using the
(that's a capital Z) option of :
An empty file created by a user in the user's own home directory has, as you might expect, a very specific security profile. Even with the executable bit set, that file would not be permitted to run as a systemwide service. It just doesn't have the correct security context.
If you use an
alias, try adding the option to its option list so you get used to seeing SELinux labels. The more you see what labels exist on your system, and how they relate to various system roles, you're more likely to recognize when they're wrong.
Copy contexts
Suppose you were developing a custom SELinux service for your laptop. You've written a shell script, a service file, and you've placed them in the appropriate system locations. You're also careful to set ownership and permissions correctly. But no matter what you do, you get errors when attempting to start the service.
You suspect that SELinux might be preventing an unrecognized service from running. That would normally be appreciated, but in this case you want to make an exception.
First, confirm that the service runs successfully with SELinux in Permissive mode:
Then look at the files you've created using the
and compare them with other files that you know to be working properly. Note the differences:
The working service (
in this example, chosen at random) features the label as well as a special label. Suppose you know from previous experience with that a common SELinux label for systemd service files is so you ignore that difference. However, and seem to be important.
Use the
("change context") command to change the security context of your service file:
Your systemd service is probably triggering some executable file on your system. If you created that yourself, it probably also has the incorrect security context. Comparing it to a known working script:
Again, there's one obvious difference, which you can correct with
:
Provide feedback on this episode.
Informações
- Podcast
- FrequênciaDiário
- Publicado5 de março de 2025 às 00:00 UTC
- ClassificaçãoLivre