|
|
3424af |
From efac9c470b2a74da94c92703e87da603bf87296f Mon Sep 17 00:00:00 2001
|
|
|
3424af |
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
|
|
|
3424af |
Date: Wed, 19 Aug 2015 14:09:56 +0200
|
|
|
3424af |
Subject: [PATCH] plugin_sysctl: unquoting sysctl values
|
|
|
3424af |
MIME-Version: 1.0
|
|
|
3424af |
Content-Type: text/plain; charset=UTF-8
|
|
|
3424af |
Content-Transfer-Encoding: 8bit
|
|
|
3424af |
|
|
|
3424af |
Unquoting first and last quotation mark in value, i.e. converting:
|
|
|
3424af |
OPTION="VALUE" to OPTION=VALUE
|
|
|
3424af |
|
|
|
3424af |
Also added unquoting to profile verification, unquoting both
|
|
|
3424af |
(current and requested) values.
|
|
|
3424af |
|
|
|
3424af |
Resolves: rhbz#1254538
|
|
|
3424af |
|
|
|
3424af |
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
|
|
|
3424af |
---
|
|
|
3424af |
tuned/plugins/base.py | 7 +++++--
|
|
|
3424af |
tuned/plugins/plugin_bootloader.py | 5 +----
|
|
|
3424af |
tuned/plugins/plugin_sysctl.py | 2 +-
|
|
|
3424af |
tuned/utils/commands.py | 3 +++
|
|
|
3424af |
4 files changed, 10 insertions(+), 7 deletions(-)
|
|
|
3424af |
|
|
|
3424af |
diff --git a/tuned/plugins/base.py b/tuned/plugins/base.py
|
|
|
3424af |
index e7ff2d2..3b4652a 100644
|
|
|
3424af |
--- a/tuned/plugins/base.py
|
|
|
3424af |
+++ b/tuned/plugins/base.py
|
|
|
3424af |
@@ -3,6 +3,7 @@ import tuned.consts as consts
|
|
|
3424af |
import tuned.profiles.variables
|
|
|
3424af |
import tuned.logs
|
|
|
3424af |
import collections
|
|
|
3424af |
+from tuned.utils.commands import commands
|
|
|
3424af |
|
|
|
3424af |
log = tuned.logs.get()
|
|
|
3424af |
|
|
|
3424af |
@@ -35,6 +36,8 @@ class Plugin(object):
|
|
|
3424af |
|
|
|
3424af |
self._options_used_by_dynamic = self._get_config_options_used_by_dynamic()
|
|
|
3424af |
|
|
|
3424af |
+ self._cmd = commands()
|
|
|
3424af |
+
|
|
|
3424af |
def cleanup(self):
|
|
|
3424af |
self.destroy_instances()
|
|
|
3424af |
|
|
|
3424af |
@@ -415,10 +418,10 @@ class Plugin(object):
|
|
|
3424af |
command["set"](new_value, sim = False)
|
|
|
3424af |
|
|
|
3424af |
def _norm_value(self, value):
|
|
|
3424af |
- v = str(value)
|
|
|
3424af |
+ v = self._cmd.unquote(str(value))
|
|
|
3424af |
if re.match(r'\s*(0+,)+[\da-fA-F]*\s*$', v):
|
|
|
3424af |
return re.sub(r'^\s*(0+,)+', "", v)
|
|
|
3424af |
- return value
|
|
|
3424af |
+ return v
|
|
|
3424af |
|
|
|
3424af |
def _verify_value(self, name, new_value, current_value, device = None):
|
|
|
3424af |
if new_value is None:
|
|
|
3424af |
diff --git a/tuned/plugins/plugin_bootloader.py b/tuned/plugins/plugin_bootloader.py
|
|
|
3424af |
index e0ff646..27b7132 100644
|
|
|
3424af |
--- a/tuned/plugins/plugin_bootloader.py
|
|
|
3424af |
+++ b/tuned/plugins/plugin_bootloader.py
|
|
|
3424af |
@@ -105,9 +105,6 @@ class BootloaderPlugin(base.Plugin):
|
|
|
3424af |
self._grub2_default_env_patch()
|
|
|
3424af |
return True
|
|
|
3424af |
|
|
|
3424af |
- def _unquote(self, v):
|
|
|
3424af |
- return re.sub("^\"(.*)\"$", r"\1", v)
|
|
|
3424af |
-
|
|
|
3424af |
@command_custom("grub2_cfg_file")
|
|
|
3424af |
def _grub2_cfg_file(self, enabling, value, verify):
|
|
|
3424af |
# nothing to verify
|
|
|
3424af |
@@ -118,7 +115,7 @@ class BootloaderPlugin(base.Plugin):
|
|
|
3424af |
|
|
|
3424af |
@command_custom("cmdline", per_device = False, priority = 10)
|
|
|
3424af |
def _cmdline(self, enabling, value, verify):
|
|
|
3424af |
- v = self._variables.expand(self._unquote(value))
|
|
|
3424af |
+ v = self._variables.expand(self._cmd.unquote(value))
|
|
|
3424af |
if verify:
|
|
|
3424af |
cmdline = self._cmd.read_file("/proc/cmdline")
|
|
|
3424af |
if len(cmdline) == 0:
|
|
|
3424af |
diff --git a/tuned/plugins/plugin_sysctl.py b/tuned/plugins/plugin_sysctl.py
|
|
|
3424af |
index 676fd52..70f27af 100644
|
|
|
3424af |
--- a/tuned/plugins/plugin_sysctl.py
|
|
|
3424af |
+++ b/tuned/plugins/plugin_sysctl.py
|
|
|
3424af |
@@ -43,7 +43,7 @@ class SysctlPlugin(base.Plugin):
|
|
|
3424af |
original_value = self._read_sysctl(option)
|
|
|
3424af |
if original_value != None:
|
|
|
3424af |
instance._sysctl_original[option] = original_value
|
|
|
3424af |
- self._write_sysctl(option, self._variables.expand(value))
|
|
|
3424af |
+ self._write_sysctl(option, self._variables.expand(self._cmd.unquote(value)))
|
|
|
3424af |
|
|
|
3424af |
self._storage.set("options", instance._sysctl_original)
|
|
|
3424af |
|
|
|
3424af |
diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py
|
|
|
3424af |
index 4c80783..2392a89 100644
|
|
|
3424af |
--- a/tuned/utils/commands.py
|
|
|
3424af |
+++ b/tuned/utils/commands.py
|
|
|
3424af |
@@ -30,6 +30,9 @@ class commands:
|
|
|
3424af |
def remove_ws(self, s):
|
|
|
3424af |
return re.sub('\s+', ' ', s).strip()
|
|
|
3424af |
|
|
|
3424af |
+ def unquote(self, v):
|
|
|
3424af |
+ return re.sub("^\"(.*)\"$", r"\1", v)
|
|
|
3424af |
+
|
|
|
3424af |
# convert dictionary 'd' to flat list and return it
|
|
|
3424af |
# it uses sort on the dictionary items to return consistent results
|
|
|
3424af |
# for directories with different inserte/delete history
|
|
|
3424af |
--
|
|
|
3424af |
2.4.3
|
|
|
3424af |
|