summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-rules.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* udev: make tags "sticky"Lennart Poettering2020-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This tries to address the "bind"/"unbind" uevent kernel API breakage, by changing the semantics of device tags. Previously, tags would be applied on uevents (and the database entries they result in) only depending on the immediate context. This means that if one uevent causes the tag to be set and the next to be unset, this would immediately effect what apps would see and the database entries would contain each time. This is problematic however, as tags are a filtering concept, and if tags vanish then clients won't hence notice when a device stops being relevant to them since not only the tags disappear but immediately also the uevents for it are filtered including the one necessary for the app to notice that the device lost its tag and hence relevance. With this change tags become "sticky". If a tag is applied is once applied to a device it will stay in place forever, until the device is removed. Tags can never be removed again. This means that an app watching a specific set of devices by filtering for a tag is guaranteed to not only see the events where the tag is set but also all follow-up events where the tags might be removed again. This change of behaviour is unfortunate, but is required due to the kernel introducing new "bind" and "unbind" uevents that generally have the effect that tags and properties disappear and apps hence don't notice when a device looses relevance to it. "bind"/"unbind" events were introduced in kernel 4.12, and are now used in more and more subsystems. The introduction broke userspace widely, and this commit is an attempt to provide a way for apps to deal with it. While tags are now "sticky" a new automatic device property CURRENT_TAGS is introduced (matching the existing TAGS property) that always reflects the precise set of tags applied on the most recent events. Thus, when subscribing to devices through tags, all devices that ever had the tag put on them will be be seen, and by CURRENT_TAGS it may be checked whether the device right at the moment matches the tag requirements. See: #7587 #7018 #8221
* udev: use path_startswith() instead of startswith() in two more casesLennart Poettering2020-08-271-1/+1
|
* udev: tweak debug logs for udev rulesZbigniew Jędrzejewski-Szmek2020-07-161-7/+7
| | | | | We shouldn't say "ignoring" when running a program because the result is used for the match/nomatch result of the rule.
* udev: accept OPTIONS+= without any fussZbigniew Jędrzejewski-Szmek2020-07-161-3/+1
| | | | | | | | | There is no reason to consider this wrong. In fact one could argue that += is more appropriate, because we always add to options, and not replace previous assignments. If we output a debug message, we implicitly ask people to "fix" this, and we shouldn't. Also, all our rules use += right now.
* udev: accept IMPORT{}= without any fussZbigniew Jędrzejewski-Szmek2020-07-161-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Udev logs are full of messages about wrong operator type: ... Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules /usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:54 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:57 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:60 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:63 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:66 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:67 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:93 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:107 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:110 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-storage.rules:113 IMPORT key takes '==' or '!=' operator, assuming '=='. Reading rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules /usr/lib/udev/rules.d/60-persistent-v4l.rules:7 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-v4l.rules:9 IMPORT key takes '==' or '!=' operator, assuming '=='. /usr/lib/udev/rules.d/60-persistent-v4l.rules:16 IMPORT key takes '==' or '!=' operator, assuming '=='. ... The warning was downgraded in f0beb6f816035e438d684cc52ae76fc4a44fc197, but I think it should be removed altogether. IMPORT{program}="asdf" seems like an obvious way to write this, and people don't expect to have to write "==". So let's just allow any operator.
* udev: specify the end of valuegaoyi2020-07-121-0/+5
| | | | | | NULSTR_FOREACH may read the illegal match Signed-off-by: gaoyi <ymuemc@163.com>
* fuzz-udev-rules: -ENOBUFS should be accepted tooZbigniew Jędrzejewski-Szmek2020-06-251-2/+5
| | | | | In udev_rules_load(), add a debug message. Otherwise there'd be no indication that parsing was aborted.
* udev: split rules object creation and loadingZbigniew Jędrzejewski-Szmek2020-06-231-11/+19
| | | | | The only functional change is to downgrade the log line to avoid double logging.
* udev: make signal that we use to kill workers on timeout configurableMichal Sekletár2020-06-051-7/+11
|
* proc-cmdline: make checking of EFI options variable optionalLennart Poettering2020-05-201-1/+1
| | | | | | | | | | | | | | | And do not use it in the IMPORT{cmdline} udev code. Wherever we expose direct interfaces to check the kernel cmdline, let's not consult our systemd-specific EFI variable, but strictly use the actual kernel variable, because that's what we claim we do. i.e. it's fine to use the EFI variable for our own settings, but for the generic APIs to the kernel cmdline we should not use it. Specifically, this applies to IMPORT{cmdline} and ConditionKernelCommandLine=. In the latter case we weren#t checking the EFI variable anyway, hence let's do the same for the udev case, too. Fixes: #15739
* udev: use STR_IN_SET() wher eit makes senseLennart Poettering2020-04-231-5/+1
|
* udev: prepare memory for extra NUL termination for NULSTRLennart Poettering2020-04-231-1/+3
| | | | Fixes: #15162
* tree-wide: spellcheck using codespellZbigniew Jędrzejewski-Szmek2020-04-161-1/+1
| | | | Fixes #15436.
* udev: fix SECLABEL{selinux} issue (#15064)Valery0xff2020-03-111-1/+1
| | | | | | | | Add SECLABEL{selinux}="some value" cause udevadm crash systemd-udevd[x]: Worker [x] terminated by signal 11 (SEGV) It happens since 25de7aa7b90 (Yu Watanabe 2019-04-25 01:21:11 +0200) when udev rules processing changed to token model. Yu forgot store attr to SECLABEL token so fix it.
* udev: do not use exact match of file permissionYu Watanabe2020-01-071-1/+1
| | | | | | This partially reverts 25de7aa7b90c23d33ea50ada1e50c5834a414237. Fixes #14473.
* udev: do not propagate error in executing PROGRAM and IMPORT{program}Yu Watanabe2019-11-191-7/+11
| | | | | | Also, this adds more logs. Fixes #14027.
* udev: silence warning about PROGRAM+= or IMPORT+= rulesYu Watanabe2019-11-181-8/+2
| | | | Closes #14062.
* Merge pull request #13984 from yuwata/udev-fix-13976Zbigniew Jędrzejewski-Szmek2019-11-121-2/+3
|\ | | | | udev: fix issue #13976
| * udev: fix error code in the log messageYu Watanabe2019-11-121-2/+1
| |
| * udev: ignore ENOENT when chmod_and_chown() device nodeYu Watanabe2019-11-121-0/+2
| |
* | udev: do not append newline when write attributesYu Watanabe2019-11-121-1/+1
|/ | | | | | | | Before 25de7aa7b90c23d33ea50ada1e50c5834a414237, the content is written by `fprintf()` without new line. So WRITE_STRING_FILE_AVOID_NEWLINE flag is necessary. Fixes #13985.
* udev: introduce CONST key nameJan Synacek2019-10-141-0/+20
| | | | | | | | | | | | Currently, there is no way to match against system-wide constants, such as architecture or virtualization type, without forking helper binaries. That potentially results in a huge number of spawned processes which output always the same answer. This patch introduces a special CONST keyword which takes a hard-coded string as its key and returns a value assigned to that key. Currently implemented are CONST{arch} and CONST{virt}, which can be used to match against the system's architecture and virtualization type.
* udev: fix memleak caused by wrong cleanup functionYu Watanabe2019-10-121-1/+1
| | | | Fixes #13764.
* Merge pull request #13519 from yuwata/udev-fix-multi-matchZbigniew Jędrzejewski-Szmek2019-09-131-34/+47
|\ | | | | udev: fix multi match
| * udev: fix multi matchYu Watanabe2019-09-111-34/+47
| | | | | | | | Fixes #13518.
* | udev: also logs file permissionYu Watanabe2019-09-081-1/+1
| |
* | udev: add missing flag for OPTIONS=static_nodeYu Watanabe2019-09-081-0/+3
|/ | | | Fixes RHBZ#1740664.
* udev: do not try to import properties on commented out linesYu Watanabe2019-08-041-2/+8
| | | | Fixes #13257.
* udev: warn on rules files with weird access modesLennart Poettering2019-07-291-0/+2
|
* tree-wide: drop duplicated blank linesYu Watanabe2019-07-151-2/+0
| | | | | | | ``` $ for i in */*.[ch] */*/*.[ch]; do sed -e '/^$/ {N; s/\n$//g}' -i $i; done $ git checkout HEAD -- basic/linux shared/linux ```
* tree-wide: some more [static] related fixesLennart Poettering2019-07-121-0/+2
| | | | | | | | | | | let's add [static] where it was missing so far Drop [static] on parameters that can be NULL. Add an assert() around parameters that have [static] and can't be NULL hence. Add some "const" where it was forgotten.
* udev: accept lines which have only PROGRAM=Yu Watanabe2019-07-011-1/+1
| | | | As PROGRAM= may cause side effect, and users may expect that.
* udev-rules: add more info to errors about attr formatsZbigniew Jędrzejewski-Szmek2019-06-281-15/+23
|
* udev-rules: add precise information to rule failure logsZbigniew Jędrzejewski-Szmek2019-06-281-37/+32
| | | | | | | | | | | | | | | | | | | It is pretty hard to figure out what the problem actually is, esp. when the rule is long. On my machine: systemd[1]: Starting udev Kernel Device Manager... systemd-udevd[217399]: /usr/lib/udev/rules.d/11-dm-lvm.rules:40 Invalid value for OPTIONS key, ignoring: 'event_timeout=180' systemd-udevd[217399]: /usr/lib/udev/rules.d/11-dm-lvm.rules:40 The line takes no effect, ignoring. systemd-udevd[217399]: /etc/udev/rules.d/60-ipath.rules:4 Invalid value "kcopy/%02n" for NAME (char 7: invalid substitution type), ignoring, but please fix it. systemd-udevd[217399]: /usr/lib/udev/rules.d/65-md-incremental.rules:28 Invalid value "/sbin/mdadm -I $env{DEVNAME} --export $devnode --offroot ${DEVLINKS}" for IMPORT (char 58: invalid substitution type), ignoring, but please fix it. systemd-udevd[217399]: /etc/udev/rules.d/73-special-net-names.rules:14 Invalid value "/bin/sh -ec 'D=${DEVPATH#*/vio/}; D=${D%%%%/*}; D=${D#????}; D=${D#0}; D=${D#0}; D=${D#0}; D=${D#0}; echo ${D:-0}'" for PROGRAM (char 16: invalid substitution type), ignoring, but please fix it. systemd-udevd[217399]: /usr/lib/udev/rules.d/84-nm-drivers.rules:10 Invalid value "/bin/sh -c 'ethtool -i $1 | sed -n s/^driver:\ //p' -- $env{INTERFACE}" for PROGRAM (char 24: invalid substitution type), ignoring, but please fix it. systemd-udevd[217399]: /usr/lib/udev/rules.d/90-libgpod.rules:19 IMPORT key takes '==' or '!=' operator, assuming '==', but please fix it. systemd-udevd[217399]: /usr/lib/udev/rules.d/90-libgpod.rules:23 IMPORT key takes '==' or '!=' operator, assuming '==', but please fix it. systemd-udevd[217399]: /usr/lib/udev/rules.d/99-vmware-scsi-udev.rules:5 Invalid value "/bin/sh -c 'echo 180 >/sys$DEVPATH/device/timeout'" for RUN (char 27: invalid substitution type), ignoring, but please fix it. systemd-udevd[217399]: /usr/lib/udev/rules.d/99-vmware-scsi-udev.rules:6 Invalid value "/bin/sh -c 'echo 180 >/sys$DEVPATH/device/timeout'" for RUN (char 27: invalid substitution type), ignoring, but please fix it. systemd[1]: Started udev Kernel Device Manager.
* udev: move rule structure definitions into the .c fileZbigniew Jędrzejewski-Szmek2019-06-281-0/+146
| | | | They are (and should) only be used there, no need to expose them.
* udev: move rules logging functions into the .c fileZbigniew Jędrzejewski-Szmek2019-06-281-7/+66
| | | | They are (and can) only be used there, no need to expose them.
* udev: check formatting of attribute or value earlierYu Watanabe2019-06-031-10/+61
|
* udev: evaluate formatting in RUN= key earlierYu Watanabe2019-06-031-1/+3
| | | | Closes #12291.
* udev: modernize udev-rules.cYu Watanabe2019-06-021-2212/+1672
| | | | | | | | | | | This does the following: - rename enum udev_builtin_cmd -> UdevBuiltinCmd - rename struct udev_builtin -> UdevBuiltin - move type definitions to udev-rules.h - move prototypes of functions defined in udev-rules.c to udev-rules.h - drop to use strbuf - propagate critical errors in applying rules, - drop limitation for number of tokens per line.
* tree-wide: port various places over to use chmod_and_chown()Lennart Poettering2019-05-241-17/+7
| | | | Doing this properly is hard, hence let's unify the code.
* udev: whitespace fixLennart Poettering2019-04-181-1/+1
|
* Check for final assignments in RUN keys (#12309)Florian Dollinger2019-04-151-0/+5
| | | As described in #12291
* udev: use strempty() where appropriateLennart Poettering2019-04-021-2/+1
|
* tree-wide: constify a few static string tablesLennart Poettering2019-03-251-3/+3
|
* udev: refuse to modify SEQNUM by udev rulesYu Watanabe2019-03-111-0/+1
|
* udevd: use device_get_action() and device_get_seqnum()Yu Watanabe2019-03-111-4/+5
|
* udev: restore debug level when logging a failure in the external prog called ↵Franck Bui2019-03-051-1/+1
| | | | | | | | | | by IMPORT{program} It was already the case before commit a75211421fc9366068e6d9446e8e567246c72feb, which upgraded the log to warning. This seems an unintended side effect as the commit message doesn't mention it and the old behavior looks more appropriate.
* udev: run programs in the specified orderYu Watanabe2019-03-051-6/+6
| | | | | | | | | | | | This fixes bugs introduced by 29448498c724da7ade1b5efb20d7472c1b128d2c and d838e14515c82b05a07f2bf393cce057b45b2b53. Previously, RUN and SECLABEL keys are stored in udev_list with its unique flag is false. If the flag is false, then udev_list is just a linked list and new entries are always added in the last. So, we should use OrderedHashmap instead of Hashmap. Fixes #11368.
* udev-rules: do not ignore short linesYu Watanabe2019-02-211-4/+2
| | | | | | Otherwise, a short line continues the previous continuation. This fixes a bug introduced by f10aa08e3e48de7dcb71be348f021c6b1385304f.
* Merge pull request #10408 from keszybz/analyze-cat-presetsLennart Poettering2019-02-181-9/+4
|\ | | | | systemd-analyze cat-presets