---
title: "How to configure SELinux enforcing mode"
description: "Configuring SELinux enforcing mode for OP5 Monitor involves enabling SELinux and adjusting permissions for required services. The guide provides commands and a script to allow necessary features, ensuring OP5 Monitor runs properly with SELinux enforcing."
url: "https://docs.itrsgroup.com/docs/faq/op5/360023683114-op5-monitor-how-to-configure-selinux-enforcing-mode/index.html"
---
## This procedure is not supported

This article was written for version 8.0.3 of OP5 Monitor and has been tested on that version. It is not part of a [standard configuration](https://support.itrsgroup.com/hc/en-us/articles/360021129974) of OP5 Monitor.

## Intro

This guide explains how to configure SELinux in EL7 to run with OP5 Monitor and its required services.

## Prerequisites

- OP5 Monitor version 8.0.3 or above installed & running
- SSH access with root privileges
- Internet connection to download installation packages

## Step-by-step guide

Login to your OP5-server with SSH using root privileges.

Enable SELinux by opening: /etc/selinux/config

Set: `SELINUX=enforcing`

To make all files & folders to get the correct selinux-context, create the file /.autorelabel and reboot to initialize it.

```
touch /.autorelabel
reboot
```

When the system is running again, SELinux are blocking several key features in OP5 Monitor that needs to be allowed.

Run the following commands to allow them, or run the BASH-script attached to this document.

```
## Install needed packages
yum install -y policycoreutils-python setroubleshoot

## Variables
monitor_path="/opt/monitor"
unconfined_type="bin_t"

## Disable all abrt services. OP5 requires these but they cause selinux errors.
abrt_services="abrt-ccpp.service abrtd.service abrt-oops.service abrt-pstoreoops.service abrt-vmcore.service abrt-xorg.service"
/usr/bin/systemctl disable $abrt_services &>/dev/null
/usr/bin/systemctl stop $abrt_services &>/dev/null
usr/bin/systemctl mask $abrt_services &>/dev/null

## Set file contexts
echo "Setting file contexts..."
## Run http unconfined, since Nacoma lives in the http context.
semanage fcontext -a -t $unconfined_type /usr/sbin/httpd
restorecon /usr/sbin/httpd
## Run snmpd unconfined - to allow OP5 self monitoring.
semanage fcontext -a -t $unconfined_type /usr/sbin/snmpd
restorecon /usr/sbin/snmpd
## Run smsd unconfined
semanage fcontext -a -t $unconfined_type /usr/sbin/smsd
restorecon /usr/sbin/smsd

semanage fcontext -a -t ssh_home_t "${monitor_path}/.ssh(/.*)?"
semanage fcontext -a -t var_log_t  "${monitor_path}/var"
semanage fcontext -a -t var_log_t  "${monitor_path}/var/naemon.log"
semanage fcontext -a -t var_log_t  "${monitor_path}/var/archives(/.*)?"
semanage fcontext -a -t var_run_t  "${monitor_path}/var/rw(/.*)?"
semanage fcontext -a -t var_run_t  "/var/cache/naemon(/.*)?"
semanage fcontext -a -t etc_t      "${monitor_path}/op5/merlin/merlin.conf"
semanage fcontext -a -t etc_t      "${monitor_path}/etc(/.*)?"
restorecon -R ${monitor_path}/var
restorecon -R ${monitor_path}/.ssh
restorecon -R ${monitor_path}/op5/merlin
restorecon -R ${monitor_path}/etc
restorecon -R /var/cache/naemon

## Done
echo "Done"
```

OP5 Monitor is now running with all bells & whistles, with SELinux enforcing.

## Related downloads

- [op5-configure-selinux.sh](/faq/downloads/op5/360023683114-360036758873-op5-configure-selinux.sh)


