Commit 90c371fc authored by Jaroslav Škarvada's avatar Jaroslav Škarvada

sysctl: support assignment modifiers as other plugins do

I.e. one can now write:

And the kernel.pid_max will be set to 32768 if the current value is
lower or untouched if it is higher (i.e. it will be 32768 or higher).

Related: rhbz#1561005
Signed-off-by: default avatarJaroslav Škarvada <>
parent 0653b3c7
......@@ -44,7 +44,7 @@ class SysctlPlugin(base.Plugin):
original_value = self._read_sysctl(option)
if original_value != None:
instance._sysctl_original[option] = original_value
self._write_sysctl(option, self._variables.expand(self._cmd.unquote(value)))
self._write_sysctl(option, self._process_assignment_modifiers(self._variables.expand(self._cmd.unquote(value)), original_value))
self._storage.set("options", instance._sysctl_original)
......@@ -58,8 +58,10 @@ class SysctlPlugin(base.Plugin):
ignore_missing = True
for option, value in list(instance._sysctl.items()):
curr_val = self._read_sysctl(option)
if self._verify_value(option, self._cmd.remove_ws(self._variables.expand(value)), curr_val, ignore_missing) == False:
ret = False
value = self._process_assignment_modifiers(self._variables.expand(value), curr_val)
if value is not None:
if self._verify_value(option, self._cmd.remove_ws(value), curr_val, ignore_missing) == False:
ret = False
return ret
def _instance_unapply_static(self, instance, full_rollback = False):
......@@ -31,7 +31,7 @@ class commands:
return {"Y":"1", "YES":"1", "T":"1", "TRUE":"1", "N":"0", "NO":"0", "F":"0", "FALSE":"0"}.get(v, value)
def remove_ws(self, s):
return re.sub('\s+', ' ', s).strip()
return re.sub('\s+', ' ', str(s)).strip()
def unquote(self, v):
return re.sub("^\"(.*)\"$", r"\1", v)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment