summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-event.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use proper unicode © instead of (C) where we canLennart Poettering2018-06-141-1/+1
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN loggingLennart Poettering2018-01-041-4/+2
|
* tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2017-12-251-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new safe_fork() wrapper around fork() and makes use of it everywhere. The new wrapper does a couple of things we previously did manually and separately in a safer, more correct and automatic way: 1. Optionally resets signal handlers/mask in the child 2. Sets a name on all processes we fork off right after forking off (and the patch assigns useful names for all processes we fork off now, following a systematic naming scheme: always enclosed in () – in order to indicate that these are not proper, exec()ed processes, but only forked off children, and if the process is long-running with only our own code, without execve()'ing something else, it gets am "sd-" prefix.) 3. Optionally closes all file descriptors in the child 4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe way so that the parent dying before this happens being handled safely. 5. Optionally reopens the logs 6. Optionally connects stdin/stdout/stderr to /dev/null 7. Debug logs about the forked off processes.
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2017-12-141-4/+8
| | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* Add SPDX license identifiers to source files under the GPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
|
* udev-rules: all values can contain escaped double quotes now (#6890)Franck Bui2017-09-281-3/+5
| | | | | | | | | | | | | | | | | This is primarly useful to support escaped double quotes in PROGRAM or IMPORT{program} directives. The only possibilty before this patch was to use an external shell script but this seems too cumbersome for trivial logics such as PROGRAM=="/bin/sh -c 'FOO=\"%s{model}\"; echo ${FOO:0:4}'" or any similar shell constructs that needs to deals with patterns including whitespaces. As it's the case for single quote and for directives running a program, words within escaped double quotes will be considered as a single argument. Fixes: #6835
* udev: fix buffer overflow in udev_event_apply_format()Zbigniew Jędrzejewski-Szmek2017-09-161-3/+4
| | | | Fixes #6664.
* udev: fix some incorrect usages of CLOCK_BOOTTIME (#6198)Lennart Poettering2017-06-271-5/+5
| | | | | | | | | | | CLOCK_BOOTTIME should only be used if we actually want the clock to count on while we are suspended, and it is hence not useful for normal code execution time limits, fix that. Moreover, a couple of uses were even more broken, as clock_bottime_or_monotonic() was called where actually now(clock_boottime_or_monotic()) was supposed to be called. Ouch! Fixes: #5903
* udev-event: use in-place whitespace replacementDan Streetman2017-01-271-35/+15
| | | | | | | Instead of using a temp buffer to replace whitespace in variable substitutions, just allow util_replace_whitespace to replace in-place. Add a comment to util_replace_whitespace indicating it is used to replace in-place, to prevent accidental future breakage.
* udev-event: refactor udev_event_apply_formatDan Streetman2017-01-271-199/+212
| | | | Move the large case statement into its own function
* udev: fix variable assignmentZbigniew Jędrzejewski-Szmek2017-01-151-1/+1
| | | | | | gcc doesn't like &, even though &sbuf and buf are the same things afaiu. Follow-up for e20a917105b.
* udev-event: add replace_whitespace param to udev_event_apply_formatDan Streetman2017-01-031-4/+35
| | | | | | | | | | | | | | | | | 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.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* treewide: fix typos and remove accidental repetition of wordsTorstein Husebø2016-07-111-1/+1
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* Merge pull request #2110 from keszybz/udev-indentationDaniel Mack2015-12-091-0/+2
|\ | | | | Udev indentation
| * udev: add emacs header lineZbigniew Jędrzejewski-Szmek2015-12-071-0/+2
| | | | | | | | | | Otherwise emacs wants to use 2-space indentation and other attrocities.
* | udev: fix NULL deref when executing rulesZbigniew Jędrzejewski-Szmek2015-12-071-4/+4
|/ | | | | | | | We quite obviously check whether event->dev_db is nonnull, and right after that call a function which asserts the same. Move the call under the same if. https://bugzilla.redhat.com/show_bug.cgi?id=1283971
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* treewide: apply errno.cocciMichal Schmidt2015-11-091-3/+1
| | | | with small manual cleanups for style.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-10/+11
| | | | | | | | | | | | | | 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.
* tree-wide: make use of log_error_errno() return valueLennart Poettering2015-09-091-4/+2
| | | | | | | | | | | | | | | | | | | | Turns this: r = -errno; log_error_errno(errno, "foo"); into this: r = log_error_errno(errno, "foo"); and this: r = log_error_errno(errno, "foo"); return r; into this: return log_error_errno(errno, "foo");
* tree-wide: drop redundant if checks before safe_close()Lennart Poettering2015-09-091-12/+4
| | | | | | | | | | | Replace this: if (fd >= 0) safe_close(fd); by this: safe_close(fd);
* tree-wide: make more code use safe_close()Lennart Poettering2015-09-091-8/+4
| | | | | | | | | | | Replace this: close(fd); fd = -1; write this: fd = safe_close(fd);
* udev: event - simplify udev_event_spawn() logicTom Gundersen2015-06-291-26/+24
| | | | | 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.
* udev: event - check return code of dup2()Tom Gundersen2015-06-231-10/+28
| | | | This fixes CID#1304688.
* Merge pull request #144 from teg/udev-spawn-log-less-2Kay Sievers2015-06-141-10/+15
|\ | | | | udevd: event - don't log about failures of spawn processes when this …
| * udevd: event - don't log about failures of spawn processes when this is expectedTom Gundersen2015-06-101-10/+15
| | | | | | | | | | | | | | 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.
* | sd-netlink: rename from sd-rtnlTom Gundersen2015-06-131-2/+2
|/
* tree-wide: remove spurious spaceThomas Hindoe Paaboel Andersen2015-06-081-3/+3
|
* udevd: simplify signal mask handlingTom Gundersen2015-06-031-14/+10
| | | | | | | | 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.
* udev: add some assertsTom Gundersen2015-06-021-0/+2
| | | | Mostly for documentation purposes.
* util: split out signal-util.[ch] from util.[ch]Lennart Poettering2015-05-291-1/+2
| | | | No functional changes.
* udevd: event - port spawn_wait() to sd-eventTom Gundersen2015-05-291-84/+106
| | | | | | | | | This allows us to drop the special sigterm handling in spawn_wait() as this will now be passed directly to the worker event loop. We now log failing spawend processes at 'warning' level, and timeouts are in terms of CLOCK_BOOTTIME when available, otherwise the behavior is unchanged.
* udevd: fix REMOVE handlingTom Gundersen2015-04-231-3/+4
| | | | | | | | This reverts b67f944. Lazy loading of device properties does not work for devices that are received over netlink, as these are sealed. Reinstate the unconditional loading of the device db. Reported by: Mantas Mikulėnas <grawity@gmail.com>.
* udev: event - update tags before writing out dbTom Gundersen2015-04-231-3/+2
| | | | | | The old tags are read from the db when deciding which tags to clear, make sure we don't write out the new db before the old one has been read.
* shared: add formats-util.hRonny Chevalier2015-04-101-0/+1
|
* udev: make set_usec_initialized() internal to libudevTom Gundersen2015-03-131-4/+1
| | | | | Instead introduce ensure_usec_initialized(), which copies the timestamp if possible otherwise sets it to now(CLOCK_MONOTONIC).
* libudev: introduce clone_with_db()Tom Gundersen2015-03-121-4/+1
| | | | This allows us to move the db reading from udevd to libudev.
* udevd: event - make db loading lazy in REMOVE event handlingTom Gundersen2015-03-121-4/+3
| | | | | | | | | We were explicitly eagerly loading the db, then deletenig the backing file and then processing the rules/symlinks. Instead we delete the backnig db file as the last step and let the db loading be lazy as everywhere else. This may save us a bit of work in casese where the db is not needed, but more importantly it hides some implementation details of libudev-device form udevd.
* libudev: introduce udev_device_properties_copy()Tom Gundersen2015-03-121-12/+2
| | | | To copy properties from one device to another. Drop the equivalent functionality from udevd.
* libudev: add missing hunksTom Gundersen2015-03-091-3/+1
| | | | | This should have been committed with udev_device_add_property - implicitly mark properties for saving to db
* libudev: udev_device_read_db - drop unused argumentTom Gundersen2015-03-091-2/+2
|
* udev/libudev: event - move {OLD_,}INTERFACE handling from udevd to libudevTom Gundersen2015-03-091-9/+1
| | | | This should be internal to the library as it is only about reflecting the sysfs state in the udev_device.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* include <poll.h> instead of <sys/poll.h>Thomas Hindoe Paaboel Andersen2015-02-121-1/+1
| | | | | | include-what-you-use automatically does this and it makes finding unnecessary harder to spot. The only content of poll.h is a include of sys/poll.h so should be harmless.
* udev: event - minor nitTom Gundersen2015-01-261-1/+1
| | | | | Stay uniform and use 'dev' rather than 'event->dev', as these are aliases (and event->dev looks like it may be a typo for event->dev_db).
* udev: event - introduce and use internal udev_device_shallow_clone()Tom Gundersen2015-01-261-4/+1
|