summaryrefslogtreecommitdiff
path: root/src/udev/udev-rules.c
AgeCommit message (Collapse)Author
2017-01-03udev-rules: perform whitespace replacement for symlink subst valuesDan Streetman
If the string_escape option is either unset or 'replace' (i.e. if it is not 'none'), then enable whitespace replacement in SYMLINK variable substitution values, as added in the last patch. This will keep any whitespace that is directly contained in a SYMLINK value, but will replace any whitespace that is added to the SYMLINK value as a result of variable substitution (except $result/%c). This fixes bug 4833.
2017-01-03udev-event: add replace_whitespace param to udev_event_apply_formatDan Streetman
If replace_whitespace is true, each substitution value has all its whitespace removed/replaced by util_replace_whitespace (except the SUBST_RESULT substitution - $result{} or %c{} - which handles spaces itself as field separators). All existing callers are updated to pass false, so no functional change is made by this patch. This is needed so the SYMLINK assignment can replace any spaces introduced through variable substitution, becuase the SYMLINK value is a space-separated list of symlinks to create. Any variables that contain spaces will thus unexpectedly change the symlink value from a single symlink to multiple incorrectly-named symlinks. This is used in the next patch, which enables the whitespace replacement for SYMLINK variable substitution.
2016-12-09tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853)Reverend Homer
2016-12-01Spot inconsistent quoting (just one single quote) (#4732)Tobias Stoeckmann
It is possible to specify only one quote in udev rules, which is not detected as an invalid quoting (" instead of "" for empty string). Technically this doesn't lead to a bug, because the string ends in two terminating nul characters at this position, but a user should still be reminded that his configuration is invalid.
2016-10-28udev: allow substitutions for SECLABEL key (#4505)Michal Sekletar
2016-10-16tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek
2016-05-03udev: fix build with DEBUG=1Lubomir Rintel
Alternatively, this could perhaps be removed since it was broken for a long time and noone seemed to care. But it was helpful for me today.
2016-02-22udev-rules: fix querying of attributesZbigniew Jędrzejewski-Szmek
faccessat returns 0 on success. A cosmetic fix is also included: the slash was doubled unnecessarily.
2016-02-21udev-rules: use _cleanup_ for fcloseZbigniew Jędrzejewski-Szmek
2016-02-21udev-rules: make error messages about rules more uniformZbigniew Jędrzejewski-Szmek
Also downgrade non-fatal warnings to log_warning. Previously rule_add_key() would check the output array and log a cryptic error and return -1. Most of the time the return value was ignored. This does not seems right, because the buffer can overflow with enough rules. It would also check if we have enough space for the *next* rule, even if there might be not next rule, i.e. off-by-one. Replace this with a check that we have enough space for a next rule before we start parsing. Normally using macros to alter flow is not allowed, but in this case I think it is worth it, because it allows lots of boilerplate code to be removed and hides repeated boring parameters, making function logic much easier to follow.
2016-02-21udev-rules: rewrite function to avoid clobbering argumentsZbigniew Jędrzejewski-Szmek
If the attribute wasn't found, the last filename looked at was returned in the input/output argument. This just seems bad style. The return value was ignored, so change function to return void.
2016-02-21udev-rules: modernize syntax a bitZbigniew Jędrzejewski-Szmek
2016-02-21udev-rules: log_oom() on memory error and abort processing of eventZbigniew Jędrzejewski-Szmek
CID #1313566. Also, change the return value to void, because it is ignored anyway.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-12-07udev: add emacs header lineZbigniew Jędrzejewski-Szmek
Otherwise emacs wants to use 2-space indentation and other attrocities.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: split out globbing related calls into glob-util.[ch]Lennart Poettering
2015-10-27util-lib: split stat()/statfs()/stavfs() related calls into stat-util.[ch]Lennart Poettering
2015-10-26util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-10-24util: split out escaping code into escape.[ch]Lennart Poettering
This really deserves its own file, given how much code this is now.
2015-10-01Merge pull request #1428 from franciozzy/tagenhanceKay Sievers
Enhance matching of TAG keys
2015-10-01udev: fix format string after conversion to log_*_errno()Michal Schmidt
Use %m where previously %s was used together with strerrno(). Fixes: e53fc357a9b "tree-wide: remove a number of invocations of strerror() and replace by %m"
2015-09-30Support OP_NOMATCH for TAG keyFelipe Franciosi
The TAG key can be used in rules for event matching. At the moment, it does not support inequality tests. This patch enhances the key test to validate the rule if it does not contain a given TAG (by TAG!="value"). Signed-off-by: Felipe Franciosi <felipe@paradoxo.org>
2015-09-30tree-wide: remove a number of invocations of strerror() and replace by %mLennart Poettering
Let's clean up our tree a bit, and reduce invocations of the thread-unsafe strerror() by replacing it with printf()'s %m specifier.
2015-09-09tree-wide: update empty-if coccinelle script to cover empty-while and moreLennart Poettering
Let's also clean up single-line while and for blocks.
2015-09-09tree-wide: drop {} from one-line if blocksLennart Poettering
Patch via coccinelle.
2015-09-09tree-wide: use coccinelle to patch a lot of code to use mfree()Lennart Poettering
This replaces this: free(p); p = NULL; by this: p = mfree(p); Change generated using coccinelle. Semantic patch is added to the sources.
2015-08-06tree-wide: fix indentationThomas Hindoe Paaboel Andersen
2015-07-31tree-wide: introduce mfree()David Herrmann
Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
2015-07-30tree-wide: use free_and_strdup()Daniel Mack
Use free_and_strdup() where appropriate and replace equivalent, open-coded versions.
2015-06-30Merge pull request #411 from teg/udev-simplify-exec-envpKay Sievers
udev: event - simplify udev_event_spawn() logic
2015-06-30udev: remove WAIT_FOR keyKay Sievers
This facility was never a proper solution, but only papered over real bugs in the kernel. There are no known sysfs "timing bugs" since a long time.
2015-06-29udev: event - simplify udev_event_spawn() logicTom Gundersen
Push the extraction of the envp + argv as close as possible to their use, to avoid code duplication. As a sideeffect fix logging when delaing execution.
2015-06-10udevd: event - don't log about failures of spawn processes when this is expectedTom Gundersen
PROGRAM and IMPORT{program} uses the exit code of the spawn process to decide if a rule matches or not, a failing process is hence normal operation and not something we should warn about. We still warn about other types of failing processes.
2015-06-08tree-wide: remove spurious spaceThomas Hindoe Paaboel Andersen
2015-06-03udevd: simplify signal mask handlingTom Gundersen
We used to block all signals, and restore the original signal mask before exec'ing external processes. Now we just block the signals we care about and unconditionally unblock all signals before exec'ing.
2015-06-02udev: add some assertsTom Gundersen
Mostly for documentation purposes.
2015-03-11udev: add SYSCTL{} supportKay Sievers
2015-03-09libudev: add missing hunksTom Gundersen
This should have been committed with udev_device_add_property - implicitly mark properties for saving to db
2015-03-09libudev: udev_device_add_property - implicitly mark properties for saving to dbTom Gundersen
Properties should only be saved to the db when added to the udev_device by udevd, and only if the property does not start with a '.'. Make this implicit rather than expose the marking of properties.
2014-11-30udev: strings in C are NUL-terminated anyway, no need to add a second NUL...Lennart Poettering
2014-11-28udev: rules - ignore the lack of trailing newlineTom Gundersen
Also accept '\r' as newline character. This dropps warnings of the type: invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('')
2014-11-28udev: rules - print the first invalid characterTom Gundersen
The current code would print the character following the first invalid character. Given an udev rules-file without a trailing newline we would otherwise print garbage: invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('m') This is now changed to print invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('') (still not very good as printing \0 just gives the empty string)
2014-11-28udev: rules - modernise add_rule a bitTom Gundersen
2014-11-28treewide: another round of simplificationsMichal Schmidt
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
2014-11-28treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt
If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
2014-11-28treewide: yet more log_*_errno + return simplificationsMichal Schmidt
Using: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg; print;' $f done And a couple of manual whitespace fixups.
2014-11-28treewide: more log_*_errno() conversionsMichal Schmidt