Configuring SELinux Security Policies

In this section

Universal Package Installation Issues

Dr.Web Gateway Security Suite Operation Issues

If your GNU/Linux distribution features the SELinux (Security-Enhanced Linux) security subsystem, you may need to adjust SELinux security policies to enable correct operation of Dr.Web Gateway Security Suite service components (such as the scanning engine) after their installation.

Universal Package Installation Issues

If SELinux is enabled, the installation of the Dr.Web Gateway Security Suite universal package from the installation file (.run) can fail because an attempt to create the drweb special user, as which Dr.Web Gateway Security Suite components run, will be blocked.

If installation of Dr.Web Gateway Security Suite from the installation file (.run) fails due to inability to create the drweb user, check the SELinux operation mode with the getenforce command. The command outputs the current protection mode:

Enforcing—protection is active and a restrictive strategy is used: actions that violate security policies are blocked and registered in the audit log;

Permissive—protection is active but a permissive strategy is used: actions that violate the security policy are only registered in an audit log but not blocked;

Disabled—SELinux is installed but not active.

If SELinux is operating in Enforcing mode, temporarily (during the installation of Dr.Web Gateway Security Suite) change its mode to Permissive. For that purpose, use the following command:

# setenforce 0

This command (until the next reboot) enables Permissive mode for SELinux.

Regardless of the operation mode enabled with the setenforce command, after the restart of the operating system, SELinux returns to the safe operation mode specified in its settings (the file with SELinux settings is usually stored in the /etc/selinux directory).

After Dr.Web Gateway Security Suite is successfully installed from the installation file, enable the Enforcing mode again before starting and activating the product. For that purpose, run the command:

# setenforce 1

Dr.Web Gateway Security Suite Operation Issues

In certain cases when SELinux is running, several Dr.Web Gateway Security Suite components (such as drweb-se and drweb-filecheck) cannot start, thereby hindering object scanning and file system monitoring. A failure to start these components causes the occurrence of 119 and 120 error messages in the system log managed by the syslog service (this log is typically located in the /var/log/ directory).

When the SELinux security system blocks access, such an event is also output to an audit system log. In general, when the audit daemon is used in the system, the audit log is stored in the /var/log/audit/audit.log file. Otherwise, messages about blocked operations are written to the general log file (/var/log/messages or /var/log/syslog).

If the scanning components of the product do not operate because they are blocked by SELinux, compile special security policies for them.

Certain GNU/Linux distributions do not feature the utilities mentioned below. If so, you may need to additionally install them.

To Сonfigure SELinux Security Policies

1.Create a new file with the SELinux policy source code (a .te file). This file defines restrictions related to the described module. The policy source code file can be created in one of the following ways:

1)Using the audit2allow utility, which is the simplest method. The utility generates permissive rules from messages on access denial in system log files. You can set to search messages automatically or specify a path to the log file manually.

You can use this method only if Dr.Web Gateway Security Suite components have violated SELinux security policies and these events have been registered in the audit system log. If not, wait for such an incident triggered by Dr.Web Gateway Security Suite to occur or force-create permissive policies by using the policygentool utility (see below).

 

The audit2allow utility is contained either in the policycoreutils-python package or in the policycoreutils-devel package (for Red Hat Enterprise Linux, CentOS, Fedora operating systems, depending on the version) or in the python-sepolgen package (for Debian and Ubuntu operating systems).

Example of using audit2allow:

# grep drweb-se.real /var/log/audit/audit.log | audit2allow -M drweb-se

In the given example, the audit2allow utility performs a search in the /var/log/audit/audit.log file to find access denial messages for the drweb-se component.

The utility creates two files: the drweb-se.te policy source file and the drweb-se.pp policy module ready to install.

If no corresponding incidents are found in the system audit log, the utility returns an error message.

In most cases, you do not need to modify the policy file created by the audit2allow utility; thus, it is recommended to go to step 4 for the installation of the drweb-se.pp policy module.

The audit2allow utility outputs the semodule command with all arguments. By copying it to the command line and running it, you complete step 4. Go to step 2 only if you want to modify the security policies that were automatically generated for Dr.Web Gateway Security Suite components.

2)Using the policygentool utility. For that purpose, specify the name of the component that you want to be treated differently and the full path to its executable file.

The policygentool utility included in the selinux-policy package for Red Hat Enterprise Linux and CentOS may not operate correctly. If so, use the audit2allow utility.

Example of policy creation using policygentool:

for the drweb-se component:

# policygentool drweb-se /opt/drweb.com/bin/drweb-se.real

for the drweb-filecheck component:

# policygentool drweb-filecheck /opt/drweb.com/bin/drweb-filecheck.real

You will be prompted to specify several general properties for created the domain. After that, three files that determine the policy will be created (for each of the components):

<module_name>.te, <module_name>.fc and <module_name>.if.

2.If required, edit the generated policy source file <module_name>.te, then use the checkmodule utility to create a binary representation (a .mod file) of this source file of the local policy.

This command requires the checkpolicy package to be installed in the system.

Usage example:

# checkmodule -M -m -o drweb-se.mod drweb-se.te

3.Create a policy module for installation (a .pp file) with the help of the semodule_package utility.

Example:

# semodule_package -o drweb-se.pp -m drweb-se.mod

4.To install the created policy module, use the semodule utility.

Example:

# semodule -i drweb-se.pp

For details on SELinux operating principles and configuration, refer to documentation on your GNU/Linux distribution.