summaryrefslogtreecommitdiff
path: root/src/udev/udev-rules.c
AgeCommit message (Collapse)Author
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
2014-11-28treewide: drop unnecessary trailing \n in log_*() callsMichal Schmidt
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-11-13udev: support ENV{}=="" global property matchesKay Sievers
2014-11-12udev: use properly the systemd logging functionsRonny Chevalier
2014-11-12udev: use the systemd logging functions in udev toolsKay Sievers
2014-09-17udev: rules - close empty fileTom Gundersen
If the file is found to be empty, we exit early without closing the file first. Found by coverity. Fixes CID #1237759.