From 6ca58022c1ed57b64559031d4b2f8c04e8eecf07 Mon Sep 17 00:00:00 2001 From: dajt1725 Date: Sun, 21 Apr 2024 09:34:19 -0400 Subject: [PATCH 1/3] accept a list of possible values for in match_value() This means instead of having ten rules, each of which matches a single uuid, you can provide a list of uuids to a single rule. --- udiskie/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/udiskie/config.py b/udiskie/config.py index 7dab360..f11726e 100644 --- a/udiskie/config.py +++ b/udiskie/config.py @@ -42,6 +42,8 @@ def _format_item(k, v): def match_value(value, pattern): if isinstance(value, (list, tuple)): return any(match_value(v, pattern) for v in value) + if isinstance(pattern, (list, tuple)): + return any(match_value(value, p) for p in pattern) if isinstance(value, str) and isinstance(pattern, str): return fnmatch.fnmatch(value.lower(), pattern.lower()) return lower(value) == lower(pattern) From 347a06f133edb03fabd1bb29478f17e6a733e411 Mon Sep 17 00:00:00 2001 From: dajt1725 Date: Sun, 21 Apr 2024 09:38:24 -0400 Subject: [PATCH 2/3] Document the config file enhancement. --- doc/udiskie.8.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/udiskie.8.txt b/doc/udiskie.8.txt index 1716b8d..af04127 100644 --- a/doc/udiskie.8.txt +++ b/doc/udiskie.8.txt @@ -232,10 +232,14 @@ device_config: # The rules defined here are simply prepended to the builtin device rules, # so that it is possible to completely overwrite the defaults by specifying # a catch-all rule (i.e. a rule without device attributes). + # Filter rules can be passed a list of values, in which case the rule is matched + # if the attribute matches any of the values in the list. - device_file: /dev/dm-5 # [filter] ignore: false # [action] never ignore this device -- id_uuid: 9d53-13ba # [filter] match by device UUID +- id_uuid: # [filter] match by device UUID + - 9d53-13ba # This rule matches on either of these uids + - 8675-309a options: [noexec, nodev] # [action] mount options can be given as list ignore: false # [action] never ignore this device (even if fs=FAT) automount: false # [action] do not automount this device From 37b65b9e4fb7cbd8bfc5b1d62821c7f0792e9dbb Mon Sep 17 00:00:00 2001 From: dajt1725 Date: Sun, 21 Apr 2024 10:36:58 -0400 Subject: [PATCH 3/3] Make flake8 happy --- udiskie/cache.py | 1 + 1 file changed, 1 insertion(+) diff --git a/udiskie/cache.py b/udiskie/cache.py index 54c15c3..61ea06e 100644 --- a/udiskie/cache.py +++ b/udiskie/cache.py @@ -9,6 +9,7 @@ # the two identically named python packages (=keyring). from keyutils import KEY_SPEC_PROCESS_KEYRING + class PasswordCache: def __init__(self, timeout):