Commit graph

95 commits

Author SHA1 Message Date
Tom Gundersen 6f5cf8a8b1 udevd: parse_argv - warn if argumens are invalid
Found by Coverity. Fixes CID #1238780.
2014-09-18 19:02:42 +02:00
Tom Gundersen f1e8664e4a udevd: use safe_ato*() in place of strto*() 2014-09-16 12:12:56 +02:00
Tom Gundersen 4d6dac13ad udev: apply permissions to static nodes before signallying READY
Processes expecting static nodes to have the right permissions may order themselves after systemd-udevd.service,
make sure that actually guarantees what is expected.
2014-09-16 12:12:56 +02:00
Tom Gundersen ebc164ef40 udev: only print after final log level has been determined
This delays label_init(), and drops the (duplicate) printing of version
information.
2014-09-16 12:12:56 +02:00
Tom Gundersen 3f56f784b9 udevd: initialize epoll_event structs on allocation
Also move the rest of event initialization next to the event loop (no functional change).
2014-09-16 12:12:56 +02:00
Tom Gundersen 5c67cf2774 udev: don't close std{in,out,err}
Rather than printing debug output to stderr and redirecting this to /dev/null when not wanted,
use the correct log_*() function in the first place.
2014-09-16 12:12:56 +02:00
Tom Gundersen 959d654105 udev: drop duplicate logging
Once upon a time logging during early boot was unreliable, so extra logging messages were
sent by udev to stderr. That is no longer a concern, so drop all fprintf() calls from udved.
2014-09-16 12:12:56 +02:00
Tom Gundersen bba7a48439 udev: split out parse_argv()
Also rename some global variables to arg_* to make it clearer where they come from.
2014-09-16 12:12:55 +02:00
Tom Gundersen ed216e1ff0 udev: split out help and modernise a bit 2014-09-16 12:12:55 +02:00
Tom Gundersen 6711741365 udev: timeout - warn after a third of the timeout before killing 2014-09-11 23:45:01 +02:00
Tom Gundersen b5338a1986 udev: timeout - increase timeout
Some kernel modules still take more than one minute to insmod, we no longer rely on the timeout
killing insmod within a given period of time, so just bump this to a much higher value. Its only
purpose is to make sure that nothing stays aronud forever.
2014-09-10 18:10:06 +02:00
Tom Gundersen 9d19a679f2 udev - drop print_kmsg
The only remaining user was 'starting version XXX', which is now logged using log_info().
2014-09-09 22:48:57 +02:00
Tom Gundersen 4c83d99456 udev: event - keep one rtnl per worker, rather than per event
Creating the rtnl context is cheap, but freeing it may not be, due to
synchronous close().

Also drop some excessive logging. We now log about the changing ifname
exactly once.
2014-09-09 15:30:10 +02:00
Kay Sievers 2e92633dba udev: bump event timeout to 60 seconds 2014-08-30 11:36:32 +02:00
Kay Sievers be2ea723b1 udev: remove userspace firmware loading support 2014-08-30 11:34:20 +02:00
Zbigniew Jędrzejewski-Szmek a2a5291b3f Reject invalid quoted strings
String which ended in an unfinished quote were accepted, potentially
with bad memory accesses.

Reject anything which ends in a unfished quote, or contains
non-whitespace characters right after the closing quote.

_FOREACH_WORD now returns the invalid character in *state. But this return
value is not checked anywhere yet.

Also, make 'word' and 'state' variables const pointers, and rename 'w'
to 'word' in various places. Things are easier to read if the same name
is used consistently.

mbiebl_> am I correct that something like this doesn't work
mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"'
mbiebl_> systemd seems to strip of the quotes
mbiebl_> systemctl status shows
mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS  $RootDir $MountPoint
mbiebl_> which is pretty weird
2014-07-31 04:00:31 -04:00
Kay Sievers 9ec6e95b04 udev: place opening { at the same line as the function declaration 2014-07-29 15:49:25 +02:00
Kay Sievers dd5eddd28a udev: unify event timeout handling 2014-07-29 15:18:27 +02:00
Hannes Reinecke 9719859c07 udevd: add --event-timeout commandline option
Some events take longer than the default 30 seconds. Killing those
events will leave the machine halfway configured.

Add a commandline option '--event-timeout' to handle these cases.
2014-07-29 13:45:07 +02:00
Kay Sievers 2e5b17d013 udev: exclude MD from block device ownership event locking
MD instantiates devices at open(). This is incomptible with the
locking logic, as the "change" event emitted when stopping a
device will bring it back.
2014-07-24 23:37:35 +02:00
Thomas Hindoe Paaboel Andersen 47a3fa0f76 udev: check the return value from udev_enumerate_scan_devices
The return value from udev_enumerate_scan_devices was stored but
never used. I assume this was meant to be checked.
2014-06-10 19:06:50 +02:00
Christian Hesse 638ca89c53 udev: really exclude device-mapper from block device ownership event locking
Arguments were wrong order, no?
This fixes commits:

e918a1b5a9
3d06f41834
2014-06-10 16:08:25 +02:00
Kay Sievers 02ba8fb335 udev: guard REREADPT by exclusive lock instead of O_EXCL 2014-06-04 16:28:03 +02:00
Kay Sievers e9fc29f4ec udev: make sure we always get "change" for the disk
The kernel will return 0 for REREADPT when no partition table
is found, we have to send out "change" ourselves.
2014-06-04 15:17:15 +02:00
Kay Sievers 10fab50a30 udev: guard REREADP logic with open(O_ECXL) 2014-06-04 14:09:31 +02:00
Kay Sievers ede344452a udev: try first re-reading the partition table
mounted partitions:
  # dd if=/dev/zero of=/dev/sda bs=1 count=1
  UDEV  [4157.369250] change   .../0:0:0:0/block/sda (block)
  UDEV  [4157.375059] change   .../0:0:0:0/block/sda/sda1 (block)
  UDEV  [4157.397088] change   .../0:0:0:0/block/sda/sda2 (block)
  UDEV  [4157.404842] change   .../0:0:0:0/block/sda/sda4 (block)

unmounted partitions:
  # dd if=/dev/zero of=/dev/sdb bs=1 count=1
  UDEV  [4163.450217] remove   .../target6:0:0/6:0:0:0/block/sdb/sdb1 (block)
  UDEV  [4163.593167] change   .../target6:0:0/6:0:0:0/block/sdb (block)
  UDEV  [4163.713982] add      .../target6:0:0/6:0:0:0/block/sdb/sdb1 (block)
2014-06-04 13:35:02 +02:00
Kay Sievers f3a740a5da udev: synthesize "change' events for partitions when tools change the disk
This should make sure that fdisk-like programs will automatically
cause an update of all partitions, just like mkfs-like programs cause
an update of the partition.
2014-06-04 12:21:44 +02:00
Kay Sievers edd32000c8 udevd: inotify - modernizations 2014-06-04 11:16:30 +02:00
Kay Sievers e918a1b5a9 udev: exclude device-mapper from block device ownership event locking 2014-06-03 16:49:38 +02:00
Kay Sievers 3d06f41834 udev: always close lock file descriptor
https://bugs.freedesktop.org/show_bug.cgi?id=79576
2014-06-03 11:06:43 +02:00
Thomas Hindoe Paaboel Andersen bf9bead187 udev: avoid use of uninitialized err
After 1ea972174b err is no longer
set unless we hit a special case. Initialize it to 0 and remove
a check that will never fail.
2014-05-17 08:41:48 +02:00
Kay Sievers 1ea972174b udev: do not skip the execution of RUN when renaming a network device fails 2014-05-15 10:32:26 +02:00
Kay Sievers 3ebdb81ef0 udev: serialize/synchronize block device event handling with file locks 2014-04-13 19:54:27 -07:00
Kay Sievers 9ea28c55a2 udev: remove seqnum API and all assumptions about seqnums
The way the kernel namespaces have been implemented breaks assumptions
udev made regarding uevent sequence numbers. Creating devices in a
namespace "steals" uevents and its sequence numbers from the host. It
confuses the "udevadmin settle" logic, which might block until util a
timeout is reached, even when no uevent is pending.

Remove any assumptions about sequence numbers and deprecate libudev's
API exposing these numbers; none of that can reliably be used anymore
when namespaces are involved.
2014-04-13 17:12:14 -07:00
Lennart Poettering c8a202b7d4 everywhere: always use O_CLOEXEC where it makes sense 2014-02-13 14:59:56 +01:00
Lennart Poettering 955d98c9c1 everywhere: make use of new0() and macro() macros, and stop using perror() 2014-02-13 14:45:51 +01:00
Greg KH 29804cc1e0 use memzero(foo, length); for all memset(foo, 0, length); calls
In trying to track down a stupid linker bug, I noticed a bunch of
memset() calls that should be using memzero() to make it more "obvious"
that the options are correct (i.e. 0 is not the length, but the data to
set).  So fix up all current calls to memset(foo, 0, length) to
memzero(foo, length).
2014-01-31 11:55:01 +01:00
Kay Sievers ed14edc04f udev: LOG_PRIORITY -> LOG_LEVEL 2013-12-29 18:05:25 +01:00
Lennart Poettering 9f6445e34a log: log_error() and friends add a newline after each line anyway, so avoid including it in the log strings 2013-12-24 16:39:37 +01:00
Kay Sievers e3dc56a219 udev: declare some symbols static 2013-11-12 18:09:08 +01:00
Lennart Poettering 74df0fca09 util: unify reading of /proc/cmdline
Instead of individually checking for containers in each user do this
once in a new call proc_cmdline() that read the file only if we are not
in a container.
2013-11-06 03:15:16 +01:00
Zbigniew Jędrzejewski-Szmek 97fec53e5e udev: use initialization instead of zeroing in one place 2013-10-13 17:56:55 -04:00
Colin Walters 73814ca287 Revert "udevd: simplify sigterm check"
This reverts commit 47e737dc13 - it
introduced a use-after-free.  The only way the code would get simpler
is with a cleanup function, but eh, not worth it for just this one
bit.

Reviewed by kay on IRC.
2013-08-22 17:07:02 -04:00
Kay Sievers 47e737dc13 udevd: simplify sigterm check 2013-08-15 19:55:32 +02:00
Tom Gundersen 689a97f523 udevd: respect the log-level set in /etc/udev/udev.conf
A regression introduced when we moved to systemd's logging is that the only
way to adjust the log-level of the udev daemon is via the env var, kernel
commandline or the commandline.

This reintroduces support for specifying this in the configuration file.
2013-08-09 01:38:17 +02:00
Tom Gundersen 84b6ad702e udev: export tags of "dead" device nodes to /run/udev/static_node-tags/
Based on a patch by Kay Sievers.

A tag is exported at boot as a symlinks to the device node in the folder
/run/udev/static_node-tags/<tagname>/, if the device node exists.

These tags are cleaned up by udevadm info --cleanup-db, but are otherwise
never removed.
2013-07-16 20:07:57 +02:00
Tom Gundersen edeb68c53f static-nodes: move creation of static nodes from udevd to tmpfiles
As of kmod v14, it is possible to export the static node information from
/lib/modules/`uname -r`/modules.devname in tmpfiles.d(5) format.

Use this functionality to let systemd-tmpfilesd create the static device nodes
at boot, and drop the functionality from systemd-udevd.

As an effect of this we can move from systemd-udevd to systemd-tmpfiles-setup-dev:

 * the conditional CAP_MKNOD (replaced by checking if /sys is mounted rw)
 * ordering before local-fs-pre.target (see 89d09e1b5c)
2013-07-08 21:26:24 +02:00
Lennart Poettering 7027ff61a3 nspawn: introduce the new /machine/ tree in the cgroup tree and move containers there
Containers will now carry a label (normally derived from the root
directory name, but configurable by the user), and the container's root
cgroup is /machine/<label>. This label is called "machine name", and can
cover both containers and VMs (as soon as libvirt also makes use of
/machine/).

libsystemd-login can be used to query the machine name from a process.

This patch also includes numerous clean-ups for the cgroup code.
2013-04-16 04:41:21 +02:00
Lennart Poettering 574d5f2dfc util: rename write_one_line_file() to write_string_file()
You can write much more than just one line with this call (and we
frequently do), so let's correct the naming.
2013-04-03 20:12:56 +02:00
Václav Pavlín f459285212 udev: check return value of uname. 2013-03-28 23:45:58 -04:00