6bec19
From 14053bc98adfa7f57e7a3ec61ddb1b7b36a7200e Mon Sep 17 00:00:00 2001
6bec19
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
6bec19
Date: Wed, 27 Nov 2019 12:20:36 +0100
6bec19
Subject: [PATCH] sysctl: Make reapply_sysctl ignore configs from /usr
6bec19
MIME-Version: 1.0
6bec19
Content-Type: text/plain; charset=UTF-8
6bec19
Content-Transfer-Encoding: 8bit
6bec19
6bec19
The reapply_sysctl functionality was originally added to address
6bec19
rhbz#1302953, which was about Tuned overriding sysctl config files
6bec19
from /etc, which was deemed undesirable. The bug said nothing about
6bec19
sysctl config files from /usr/lib/sysctl.d, /lib/sysctl.d or
6bec19
/usr/local/lib/sysctl.d.
6bec19
6bec19
Having sysctl configs from /usr override Tuned profiles causes
6bec19
problems (rhbz#1759597). Also, it seems reasonable for Tuned profiles
6bec19
to override sysctl configs from /usr - a Tuned profile is often
6bec19
explicitly chosen by the user, whereas sysctl configs from /usr are
6bec19
provided by system packages whether the user wants them or not.
6bec19
6bec19
Also, in RHEL-6, tuned used to ignore sysctl config files from /usr,
6bec19
as far as I can tell.
6bec19
6bec19
Resolves rhbz#1759597
6bec19
6bec19
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
6bec19
---
6bec19
 man/tuned-main.conf.5          | 16 ++++++++--------
6bec19
 tuned-main.conf                |  7 ++++---
6bec19
 tuned/plugins/plugin_sysctl.py |  5 +----
6bec19
 3 files changed, 13 insertions(+), 15 deletions(-)
6bec19
6bec19
diff --git a/man/tuned-main.conf.5 b/man/tuned-main.conf.5
6bec19
index 9418d258..1c8dba70 100644
6bec19
--- a/man/tuned-main.conf.5
6bec19
+++ b/man/tuned-main.conf.5
6bec19
@@ -61,14 +61,14 @@ applicable if \fBdaemon\fR is enabled. By default it's set to \fBTrue\fR.
6bec19
 
6bec19
 .TP
6bec19
 .BI reapply_sysctl= BOOL
6bec19
-This controls whether to reapply sysctl settings from the \fI/etc/sysctl.conf\fR,
6bec19
-\fI/etc/sysctl.d/*.conf\fR, \fI/usr/lib/sysctl.d/*.conf\fR,
6bec19
-\fI/usr/local/lib/sysctl.d/*.conf\fR, \fI/lib/sysctl.d/*.conf\fR,
6bec19
-\fI/run/sysctl.d/*.conf\fR, i.e. all locations supported by
6bec19
-\fBsysctl --system\fR after Tuned sysctl settings are applied, i.e. if
6bec19
-set to \fBTrue\fR or \fB1\fR Tuned sysctl settings will not override system
6bec19
-sysctl settings. If set to \fBFalse\fR or \fB0\fR Tuned sysctl settings will
6bec19
-override system sysctl settings. By default it's set to \fBTrue\fR.
6bec19
+This controls whether to reapply sysctl settings from \fI/run/sysctl.d/*.conf\fR,
6bec19
+\fI/etc/sysctl.d/*.conf\fR and \fI/etc/sysctl.conf\fR after Tuned sysctl
6bec19
+settings are applied. These are locations supported by \fBsysctl --system\fR,
6bec19
+excluding those that contain sysctl configuration files provided by system packages.
6bec19
+So if \fBreapply_sysctl\fR is set to \fBTrue\fR or \fB1\fR, Tuned sysctl settings
6bec19
+will not override user-provided system sysctl settings. If set to \fBFalse\fR or
6bec19
+\fB0\fR, Tuned sysctl settings will override system sysctl settings. By default
6bec19
+it's set to \fBTrue\fR.
6bec19
 
6bec19
 .TP
6bec19
 .BI default_instance_priority= INT
6bec19
diff --git a/tuned-main.conf b/tuned-main.conf
6bec19
index 6d060e59..40c4be25 100644
6bec19
--- a/tuned-main.conf
6bec19
+++ b/tuned-main.conf
6bec19
@@ -22,9 +22,10 @@ update_interval = 10
6bec19
 # one hardcoded profile (by default "balanced").
6bec19
 recommend_command = 1
6bec19
 
6bec19
-# Whether to reapply sysctl from the e.g /etc/sysctl.conf, /etc/sysctl.d, ...
6bec19
-# If enabled these sysctls will be re-appliead after Tuned sysctls are
6bec19
-# applied, i.e. Tuned sysctls will not override system sysctls.
6bec19
+# Whether to reapply sysctl from /run/sysctl.d/, /etc/sysctl.d/ and
6bec19
+# /etc/sysctl.conf.  If enabled, these sysctls will be re-appliead
6bec19
+# after Tuned sysctls are applied, i.e. Tuned sysctls will not
6bec19
+# override user-provided system sysctls.
6bec19
 reapply_sysctl = 1
6bec19
 
6bec19
 # Default priority assigned to instances
6bec19
diff --git a/tuned/plugins/plugin_sysctl.py b/tuned/plugins/plugin_sysctl.py
6bec19
index b298bfa8..ee7596d5 100644
6bec19
--- a/tuned/plugins/plugin_sysctl.py
6bec19
+++ b/tuned/plugins/plugin_sysctl.py
6bec19
@@ -12,10 +12,7 @@
6bec19
 
6bec19
 DEPRECATED_SYSCTL_OPTIONS = [ "base_reachable_time", "retrans_time" ]
6bec19
 SYSCTL_CONFIG_DIRS = [ "/run/sysctl.d",
6bec19
-		"/etc/sysctl.d",
6bec19
-		"/usr/local/lib/sysctl.d",
6bec19
-		"/usr/lib/sysctl.d",
6bec19
-		"/lib/sysctl.d" ]
6bec19
+		"/etc/sysctl.d" ]
6bec19
 
6bec19
 class SysctlPlugin(base.Plugin):
6bec19
 	"""