Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

- renamed 'mysql_hardening_mysql_conf' var to 'mysql_hardening_mysql_… #22

Merged
merged 3 commits into from
Nov 23, 2016
Merged

- renamed 'mysql_hardening_mysql_conf' var to 'mysql_hardening_mysql_… #22

merged 3 commits into from
Nov 23, 2016

Conversation

agno01
Copy link

@agno01 agno01 commented Oct 14, 2016

  • renamed 'mysql_hardening_mysql_conf' var to 'mysql_hardening_mysql_conf_file'
  • introduced 'mysql_hardening_mysql_conf_dir' variable
  • set default value of 'mysql_hardening_mysql_conf_dir' variable for RedHat, OracleLinux, Debian
  • changed default hardcoded full path in 'mysql_hardening_hardening_conf' var to be based on 'mysql_hardening_mysql_conf_dir' var

…conf_file'

- introduced 'mysql_hardening_mysql_conf_dir' variable
- set default value of 'mysql_hardening_mysql_conf_dir' variable for RedHat, OracleLinux, Debian
- changed default hardcoded full path in 'mysql_hardening_hardening_conf' var to be based on 'mysql_hardening_mysql_conf_dir' var
@rndmh3ro
Copy link
Member

Thanks for that, I'm going to take a look. Since this would be a breaking change, I'd like to hold on to this PR when he some more features.

…o list files and apply custom configuration, otherwise it doesn't apply it
@@ -1,16 +1,16 @@
---

- name: protect my.cnf
file: path='{{mysql_hardening_mysql_conf}}' mode=0600 owner=root group=root follow=yes
file: path='{{mysql_hardening_mysql_conf_file}}' mode=0600 owner=root group=root follow=yes
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About second commit in this PR: On untouched installations of MariaDB/MySQL the permissions of /etc/my.cnf include read for others, that's why mysql process can read config files. However, when we restrict it to 0600 root:root, mysql process can't read it. This should be fixed, but what would be the best way? 0460 mysql:root, 0640 root:mysql or even 0400 mysql:root would do, since root can read it in any case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the mysql unpriviliged process has to be able to read the config files? MySQL itself is started as root and then creates a child process running as user mysql.

@@ -1,2 +1,3 @@
mysql_daemon: mysql
mysql_hardening_mysql_conf: '/etc/mysql/my.cnf'
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
mysql_hardening_mysql_conf_dir: '/etc/mysql/conf.d'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be mysql_hardening_mysql_confd_dir (with a d after conf) since its the conf.d directory?

/etc/mysql/ is the mysql_hardening_mysql_conf_dir.

@@ -5,7 +5,7 @@ mysql_hardening_enabled: yes
mysql_hardening_user: 'mysql'
mysql_hardening_group: 'root'
mysql_datadir: '/var/lib/mysql'
mysql_hardening_hardening_conf: '/etc/mysql/conf.d/hardening.cnf'
mysql_hardening_hardening_conf: '{{mysql_hardening_mysql_conf_dir}}/hardening.cnf'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent, this variable should be named mysql_hardening_mysql_hardening_conf_file.

@@ -1,16 +1,16 @@
---

- name: protect my.cnf
file: path='{{mysql_hardening_mysql_conf}}' mode=0600 owner=root group=root follow=yes
file: path='{{mysql_hardening_mysql_conf_file}}' mode=0600 owner=root group=root follow=yes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the mysql unpriviliged process has to be able to read the config files? MySQL itself is started as root and then creates a child process running as user mysql.

@fitz123
Copy link
Contributor

fitz123 commented Oct 16, 2016

AFAIK default /etc/mysql/my.cnf contains [client] section, therefore it should be readable by users (for mysql cli usage etc). But having 400 mysqld should work just fine (i think ignoring all unreadable for user files)

@agno01
Copy link
Author

agno01 commented Nov 8, 2016

Changes made in 6fa5784. Please review.

@rndmh3ro
Copy link
Member

rndmh3ro commented Nov 9, 2016

Thanks @agno01, I'll try to take a look this week.

@rndmh3ro rndmh3ro merged commit d73fa4f into dev-sec:master Nov 23, 2016
@rndmh3ro
Copy link
Member

Thanks @agno01 for the improvement!

@agno01 agno01 deleted the mysql-hardening-hardening-conf branch March 19, 2019 16:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants