From d0b43e8b74aa9c1ae3ab69abf7fb8ece713b7ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Fri, 22 Nov 2019 12:12:22 +0100 Subject: [PATCH] Use re.DOTALL in the udev device matcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to allow matching multiple parameter-value pairs in a single regex, we need to use re.DOTALL, because the parameter-value pairs are on separate lines. Consider the following regex: ^ID_MODEL=SD_MMC$.*^ID_MODEL_ID=0316$ Previously it would not much a string such as the following: ID_MODEL=SD_MMC ID_MODEL_ENC=SD\x2fMMC\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 ID_MODEL_ID=0316 Now it does match. It should be noted that this change is not entirely backwards-compatible. Some user-written regexes can now start to match where they shouldn't. For example the following regex will now match even if 'ID_MODEL_ID' and '0316' are on different lines. ID_MODEL_ID.*0316 The primary motivation for this change is making the udev matcher behave the same as the cpuinfo matcher that will be written to resolve rhbz#1748965. Signed-off-by: Ondřej Lysoněk --- tuned/hardware/device_matcher_udev.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tuned/hardware/device_matcher_udev.py b/tuned/hardware/device_matcher_udev.py index e690d5b..c86d33b 100644 --- a/tuned/hardware/device_matcher_udev.py +++ b/tuned/hardware/device_matcher_udev.py @@ -21,4 +21,4 @@ class DeviceMatcherUdev(device_matcher.DeviceMatcher): for key, val in list(items): properties += key + '=' + val + '\n' - return re.search(regex, properties, re.MULTILINE) is not None + return re.search(regex, properties, re.MULTILINE | re.DOTALL) is not None