Commit 055b404f by Simon Zimmermann

Correctly compare values as returned from 'sysctl -e -n'

parent b8676203
......@@ -148,7 +148,7 @@ class SysctlModule(object):
if self.args['sysctl_set']:
if self.proc_value is None:
self.changed = True
elif self.proc_value != self.args['value']:
elif self._compare_values(self.proc_value, self.args['value']):
self.changed = True
self.set_proc = True
......@@ -161,6 +161,21 @@ class SysctlModule(object):
if self.set_proc:
self.set_token_value(self.args['name'], self.args['value'])
def _compare_values(self, a, b):
"""Expects two string values. It will split the string by whitespace
and compare each value. It will return True if both lists are the same,
contain the same elements and the same order."""
if a is None or b is None:
return False
a = a.split()
b = b.split()
if len(a) != len(b):
return False
return len([i for i, j in zip(a, b) if i == j]) != len(a)
# ==============================================================
# SYSCTL COMMAND MANAGEMENT
# ==============================================================
......
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