Skip to content

Commit f9a2df2

Browse files
authored
Merge pull request #36405 from amitkh-msft/patch-22
Update sql-server-linux-security-selinux.md
2 parents 2198596 + d139953 commit f9a2df2

1 file changed

Lines changed: 58 additions & 11 deletions

File tree

docs/linux/sql-server-linux-security-selinux.md

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ title: Get Started with SQL Server on SELinux
33
description: Learn about installing and configuring SQL Server on SELinux, using a Red Hat Enterprise Linux distribution.
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: 10/20/2025
6+
ms.reviewer: amitkh
7+
ms.date: 01/27/2026
78
ms.service: sql
89
ms.subservice: linux
910
ms.topic: how-to
@@ -12,7 +13,7 @@ ms.custom:
1213
---
1314
# Get started with SQL Server on SELinux
1415

15-
This article guides you in getting started with [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] as a *confined service* on a Security-Enhanced Linux (SELinux) distribution based on Red Hat Enterprise Linux (RHEL).
16+
This article helps you get started with [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] as a *confined service* on a Security-Enhanced Linux (SELinux) distribution based on Red Hat Enterprise Linux (RHEL).
1617

1718
## What is Security-Enhanced Linux?
1819

@@ -28,7 +29,7 @@ A *confined service* with SELinux means that it's restricted by security rules,
2829

2930
## Prerequisites
3031

31-
1. SELinux should be enabled and in `enforcing` mode. You can check the SELinux status by running the command `sestatus`.
32+
1. Enable SELinux and set it to `enforcing` mode. Check the SELinux status by running the `sestatus` command.
3233

3334
```bash
3435
sestatus
@@ -54,6 +55,52 @@ A *confined service* with SELinux means that it's restricted by security rules,
5455
> [!NOTE]
5556
> If any of the prerequisites aren't met, [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] runs as an *unconfined service*.
5657
58+
### Minimum RHEL minor version requirement
59+
60+
To run [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] as a confined application on RHEL 9, you must use a minimum RHEL minor version. This requirement exists because of point-release dependencies in SELinux packages. The `mssql-server-selinux` package, which you need to run [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] in confined mode, depends on the `selinux-policy` and `selinux-policy-base` packages.
61+
62+
#### Steps to identify minimum RHEL minor version
63+
64+
1. Add the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] repository that contains `mssql-server-selinux`.
65+
66+
For [!INCLUDE [sssql25-md](../includes/sssql25-md.md)] on RHEL 9:
67+
68+
```bash
69+
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/9/mssql-server-2025.repo
70+
```
71+
72+
For [!INCLUDE [sssql22-md](../includes/sssql22-md.md)] on RHEL 9:
73+
74+
```bash
75+
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/9/mssql-server-2022.repo
76+
```
77+
78+
> [!NOTE]
79+
> If you plan to install on RHEL 10, then change to the RHEL 10 repositories.
80+
81+
1. Run the following command to view the SELinux policy dependencies:
82+
83+
```bash
84+
sudo dnf repoquery --requires --latest-limit=1 mssql-server-selinux | egrep '^selinux-policy(-base)?'
85+
```
86+
87+
1. The output includes the minimum SELinux policy version required, indicated by a suffix such as `.el9_6`. This suffix represents the minimum RHEL 9 minor release that the policy was built for. For example, `.el9_6` corresponds to RHEL 9.6.
88+
89+
If no such suffix appears in the output, refer to Red Hat documentation to determine the minimum RHEL minor version associated with that SELinux policy build. In the following example, the required SELinux base version is `38.1.53-5`.
90+
91+
```bash
92+
sudo dnf repoquery --requires --latest-limit=1 mssql-server-selinux | egrep '^selinux-policy(-base)?'
93+
```
94+
95+
Here's example output:
96+
97+
```output
98+
selinux-policy >= 38.1.53-5.el9_6
99+
selinux-policy-base >= 38.1.53-5.el9_6
100+
```
101+
102+
In this example, the highest minor-version-tagged requirement is `38.1.53-5.el9_6`. So, you need at least RHEL 9.6 to install [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] with SELinux (`mssql-server-selinux`), and run it as a confined application on RHEL 9.
103+
57104
## Install SQL Server as a confined service
58105

59106
By default, the `mssql-server` package installs [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] without the SELinux policy, and [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] runs as an unconfined service. The `mssql-server` package installation automatically enables the `selinux_execmode` Boolean. You can verify that [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] is running unconfined using the following command:
@@ -68,7 +115,7 @@ Here's the expected output.
68115
system_u:system_r:unconfined_service_t:s0 48265 ? 00:00:02 sqlservr
69116
```
70117

71-
Once you install the `mssql-server-selinux` package, it enables a custom SELinux policy that confines the `sqlservr` process. When you install this policy, the `selinuxuser_execmod` Boolean is reset, and is replaced by a policy named `mssql`, which confines the `sqlservr` process in the new `mssql_server_t` domain.
118+
When you install the `mssql-server-selinux` package, it enables a custom SELinux policy that confines the `sqlservr` process. When you install this policy, the `selinuxuser_execmod` Boolean is reset, and is replaced by a policy named `mssql`. This policy confines the `sqlservr` process in the new `mssql_server_t` domain.
72119

73120
```bash
74121
ps -eZ | grep sqlservr
@@ -82,20 +129,20 @@ system_u:system_r:mssql_server_t:s0 48941 ? 00:00:02 sqlservr
82129

83130
## SQL Server and SELinux types
84131

85-
When the optional SELinux policy is installed with the `mssql-server-selinux` package, some new types are defined:
132+
When you install the optional SELinux policy using the `mssql-server-selinux` package, it defines some new types:
86133

87134
| SELinux policy | Description |
88135
| --- | --- |
89136
| `mssql_opt_t` | Install files of mssql-server to `/opt/mssql` |
90137
| `mssql_server_exec_t` | Executable files at `/opt/mssql/bin/` |
91-
| `mssql_paldumper_exec_t` | Executables and scripts which require special permissions to manage core dumps |
138+
| `mssql_paldumper_exec_t` | Executables and scripts that require special permissions to manage core dumps |
92139
| `mssql_conf_exec_t` | Management tool at `/opt/mssql/bin/mssql-conf` |
93140
| `mssql_var_t` | Label for files at `/var/opt/mssql` |
94141
| `mssql_db_t` | Label for the database files at `/var/opt/mssql/data` |
95142

96143
## Examples
97144

98-
The following example demonstrates changing the database location when [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] is running as a confined service.
145+
The following example demonstrates changing the database location when [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] runs as a confined service.
99146

100147
1. Create the desired directories and label them as `mssql_db_t`.
101148

@@ -106,7 +153,7 @@ The following example demonstrates changing the database location when [!INCLUDE
106153
sudo restorecon -R -v /opt/mydb
107154
```
108155

109-
The command `semanage fcontext` manages the SELinux file context mapping. The `-a` parameter adds a new file context rule, and the `-t` parameter defines the SELinux type to be applied, which in this case is `mssql_db_t` for [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] database files. Finally, the path pattern is specified, which is `/opt/mydb` in this example, and all the files and subdirectories within it.
156+
The command `semanage fcontext` manages the SELinux file context mapping. The `-a` parameter adds a new file context rule, and the `-t` parameter defines the SELinux type to apply, which in this case is `mssql_db_t` for [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] database files. Finally, the command specifies the path pattern, which is `/opt/mydb` in this example, and includes all the files and subdirectories within it.
110157

111158
1. Set the default database location using **mssql-conf**, and run the setup.
112159

@@ -136,10 +183,10 @@ The following example demonstrates changing the database location when [!INCLUDE
136183
-rw-rw----. 1 mssql mssql system_u:object_r:mssql_db_t:s0 8388608 Aug 2 14:27 TestDatabase.mdf
137184
```
138185

139-
In the previous example, you can see the file has the `mssql_db_t` (type) associated with the new files created.
186+
In the previous example, you can see the file has the `mssql_db_t` type associated with the new files created.
140187

141188
## Related content
142189

143-
- [Security limitations for SQL Server on Linux](sql-server-linux-security-overview.md)
190+
- [Security considerations for SQL Server on Linux](sql-server-linux-security-overview.md)
144191
- [Walkthrough for the security features of SQL Server on Linux](sql-server-linux-security-get-started.md)
145-
- [Quickstart: Install SQL Server and create a database on Red Hat](quickstart-install-connect-red-hat.md)
192+
- [Quickstart: Install SQL Server and create a database on Red Hat Enterprise Linux](quickstart-install-connect-red-hat.md)

0 commit comments

Comments
 (0)