Disable SELinux in Centos 8

Disable SELinux without restarting in centos 8

Security-Enhanced Linux (SELinux) is a security architecture for linux systems that gives administrators greater control over the people who can access the system. Originally, the National Security Agency (NSA) of the United States developed this product as a series of patches for the Linux kernel using Linux security modules (LSM).
SELinux was made available to the open source community in 2000, and was integrated into the Linux upstream kernel in 2003

How does SELinux work?


SELinux defines access controls for applications, processes and files within a system. It uses security policies, which consist of a set of rules that tell SELinux what can be accessed.
When an application or process, known as subjects, requests access to an object, for example a file, SELinux queries the access vector cache (AVC), where the permissions of the objects and subjects are stored.
In case SELinux cannot make a decision based on the permissions stored in the cache, it sends the request to the firewall, which analyzes the security context of the application or the process and the file. The security context is applied from the SELinux policy database. Then, permission is granted or denied.

If it is denied, the message "avc: denied" will appear in /var/log.messages.

SELinux settings

There are many ways to configure SELinux to protect the system. The most common are specific policy or multi-level security (MLS).
The specific policy is the default option, and includes a series of processes, tasks and services, while MLS is very complex and is generally only used by government agencies.
To know what configuration the system is running with, just consult the file / etc / sysconfig / selinux. The file will contain a section where it will be indicated if SELinux is in permissive, tax or disabled mode, and what policy should be loaded.

SELinux type and labeling application

Type application and labeling are the most important SELinux concepts.
This product works as a labeling system, which means that there is a SELinux tag associated with each file, process and system port. Tags are a logical method to group items, and the kernel manages them during the boot process.
The format of the labels is user: role: type: level (the level is optional). The user, function and level are used in more advanced SELinux implementations, such as MLS. The type of the label is the most important aspect of the specific policy.
SELinux uses the label type application to apply a certain policy defined in the system; that is, SELinux policies define whether a process that runs with a certain type of tag can access a file that has a certain type of tag.

SELinux Enabling

If SELinux is disabled in your environment, you can enable it by editing / etc / selinux / config and setting the SELINUX = permissive setting. Since it was not currently enabled, it is not convenient to set it up as a tax immediately, since it is likely that there are badly labeled elements in the system that could prevent it from starting.
To have the system re-label the file system automatically, create an empty file with the name .autorelabel in the root directory and restart the system. If there are too many errors, you must restart the system in permissive mode for the boot to run correctly. Once all items have been re-tagged, set the SELinux mode to tax with / etc / selinux / config and restart the system, or run the setenforce 1 command.
If the system administrator does not know the command line well, you can use the graphic tools available to manage SELinux.
SELinux provides an additional security layer for your system, which is integrated into linux distributions. If your system is at risk, you must remain activated to protect it.

  • Enforcing: The compliance status denies all unauthorized access. In this state, we refer to it as SELinux enabled.
  • Permissive: In Permissive, SELinux prints warnings. Unlike the first state, this state allows unauthorized access but shows a warning.
  • Disable: The Disable status of SELinux means that the function is disabled and allows access without warnings.

How to disable it:
setenforce 0
sed -i "s / SELINUX =. * / SELINUX = permissive /" / etc / sysconfig / selinux

with the help of thirst you could make a scrip

Comentarios