Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the config file, accept lists of possible values, and the rule matches if the attribute is any of the specified values. #286

Merged
merged 3 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/udiskie.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions udiskie/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# the two identically named python packages (=keyring).
from keyutils import KEY_SPEC_PROCESS_KEYRING


class PasswordCache:

def __init__(self, timeout):
Expand Down
2 changes: 2 additions & 0 deletions udiskie/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading