CloudInsidr

Cyber security, infotech

  • Subscribe!
  • Privacy Policy
  • Legal
  • Contact Us

Join us on Twitter: @CloudInsidr

Follow us on Twitter: @cloudinsidr
  • news & alerts
    • events
    • industry analysis
    • industry gossip
    • people
  • cloud, edge & co.
    • AWS
    • administration & orchestration
      • web servers in the cloud
      • mail servers
      • databases
  • cybersec & warfare
    • encryption
  • blockchain
Home cloud, edge and everything in between administration and orchestration How to Build a SELinux Module for MariaDB
How to Build a SELinux Module for MariaDB

Cloud Insidr 2016-07-24 Leave a Comment

How to Build a SELinux Module for MariaDB

When updating MariaDB, the popular successor to MySQL, you may, once upon a time, hit a roadblock which you won’t be able to track down in the error log. Even though web visitors get to see the plain text complaint “Can’t connect to the database”, the MariaDB server will be running just fine. Silent errors should be reason enough to suspect SELinux, the oftentimes dreaded and despised but equally popular Security-Enhanced Linux kernel module.

imgres

This happens whenever the new release comes with additional requirements for permissions that were not covered in your prior SELinux configuration, as was recently the case with MariaDB 10.1.16.

Step 1. Switch SELinux to the permissive mode temporarily and let MariaDB do its thing

Switch SELinux to the permissive mode using:

setenforce 0

Restart MariaDB and make an attempt to use the web application which was previously throwing the unsightly error. If it works and your app connects to the server, you are well on your way to creating a permanent fix. While this is going on, SELinux is tracking the activity and logging permissions violations.

Step 2. Save SELinux policy violations

Save permissions violations pertaining to MariaDB using audit2allow by extracting relevant warnings from the log:

grep mysql /var/log/audit/audit.log  | audit2allow -M mymariadb

Remember to grep for MariaDB’s famously compatibility-friendly “mysql” identifier.

Step 3. Verify if policy changes make sense

In order to verify, if proposed changes aren’t going to hurt server security, run this command:

cat mymariadb.te

You should see something like this:

module mymariadb 1.0;

require {
 type httpd_t;
 type init_t;
 class unix_stream_socket connectto;
 }

#============= httpd_t ==============
 allow httpd_t init_t:unix_stream_socket connectto;

If what you are seeing looks halfway reasonable, build the module.

Step 3. Build the module

In order to build the new module, run this command:

semodule -i mymariadb.pp

Step 4. Activate the SELinux enforcing mode

Activate enforcing:

setenforce 1

Verify that SELinux is indeed enforcing:

getenforce

Test your web application again. If everything looks the way it should, you have the right policy in place.

Step 5. Verify SELinux configuration

In order to ensure that SELinux won’t forget to enforce its policies after a reboot, have a look at its configuration file:

nano /etc/selinux/config

These settings should activate enforcing (or the permissive mode, at the least, but never deactivate SELinux! because in this case, you wouldn’t even have a track record of what went wrong and why).

Filed Under: administration and orchestration, cloud, edge and everything in between, cybersecurity and cyber warfare, databases, Linux, SELinux Tagged With: MariaDB, SELinux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe

SSL/TLS Certificate Square (250 x 250)

Pearson Education (InformIT)

SSL/TLS Certificate Medium Rectangle (300 x 250)

Recent Posts

  • Upgrading from CentOS 6 to CentOS 7 and Beyond?
  • How To Figure Out Who is Signing In To Dovecot to Send or Retrieve Email
  • OpenSSH 9.9 Introduces Enhanced Quantum-Resistant Algorithms
  • OpenSSL 3.3 Final Release is now live!
  • How to Activate HTTP/2 with TLS 1.3 Encryption in NGINX for Secure Connections without a Performance Penalty
  • Is AWS sucking your budget dry? Strip it down to the nitty-gritty (without breaking stuff)
  • How to attach and mount an NVMe EBS volume on EC2
  • SELinux security contexts: correcting SELinux labels on a file system
  • Intel gobbling up Israeli Tower Semiconductor, Stock Goes Through The Roof
  • NGINX on AWS EC2: setting up a web server from scratch on a domain of your choice
  • Log4j RCE and mitigation techniques
  • Set up logrotate for Postfix

Symantec

Categories

  • administration and orchestration
  • alerts
  • AWS
  • Bitcoin
  • cloud, edge and everything in between
  • cryptocurrencies
  • cybersecurity and cyber warfare
  • databases
  • DNS
  • encryption
  • events
  • FinTech and InsurTech
  • homeland security
  • HTTP Security Headers
  • industries
  • industry analysis
  • industry gossip
  • Java
  • Linux
  • mail servers
  • networking
  • news
  • NGINX
  • people
  • php-fpm
  • reviews
  • SELinux
  • tips and tricks
  • Uncategorized
  • web servers in the cloud

Tags

AMI AWS AWS EBS Azure certificate cipher suites cryptography cyber defense cybersecurity cyber security Diffie-Hellman DNS DNS over HTTPS Dovecot EBS EC2 email encryption Fedora HTTP/2 HTTPS IBM letsencrypt Linux logs MariaDB MFA MySQL NGINX OpenSSL permissions php-fpm PHP 7 postfix RegEx Route 53 RSA SELinux SQL SSH SSL TLS TLS 1.3 TLS vulnerabilities WordPress

Archives

  • January 2025
  • November 2024
  • October 2024
  • May 2024
  • January 2023
  • March 2022
  • February 2022
  • December 2021
  • December 2020
  • November 2020
  • September 2020
  • January 2020
  • November 2019
  • August 2019
  • July 2019
  • April 2019
  • December 2018
  • October 2018
  • September 2018
  • August 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • December 2017
  • November 2017
  • October 2017
  • August 2017
  • April 2017
  • February 2017
  • January 2017
  • November 2016
  • September 2016
  • August 2016
  • July 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • July 2015
  • February 2015

Recent Comments

    Wicked fast Networking (With a Government Clearance to Boot)

    ©2022 CybrAnalytiqa OÜ

    • Content purchasing and syndication