Commit graph

159 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 5a664ca10f rules: add a rule to set /dev/kvm access mode and ownership (#5597)
Kernel default mode is 0600, but distributions change it to group kvm, mode
either 0660 (e.g. Debian) or 0666 (e.g. Fedora). Both approaches have valid
reasons (a stricter mode limits exposure to bugs in the kvm subsystem, a looser
mode makes libvirt and other virtualization mechanisms work out of the box for
unprivileged users over ssh).

In Fedora the qemu package carries the relevant rule, but it's nicer to have it
in systemd, so that the permissions are not dependent on the qemu package being
installed. Use of packaged qemu binaries is not required to make use of
/dev/kvm, e.g. it's possible to use a self-compiled qemu or some alternative.

https://bugzilla.redhat.com/show_bug.cgi?id=1431876

To accomodate both approaches, add a rule to set the mode in 50-udev-default.rules,
but allow the mode to be overridden with a --with-dev-kvm-mode configure rule.
The default is 0660, as the (slightly) more secure option.
2017-03-27 12:34:24 +02:00
John Paul Adrian Glaubitz 7c1ebe99b6 rules: allow SPARC vdisk devices when identifying CD drives (#5599) 2017-03-20 11:22:54 +01:00
Peter Hutterer f013e99e16 rules: set ID_BUS=bluetooth for any device with id/bustype attr of 0x0005 (#5539)
Not all bluetooth devices come through the bluetooth subsystem and those that
don't currently lack the ID_BUS=bluetooth env. This again fails to apply udev
rules and/or hwdb entries that rely on the bluetooth bustype to be set.

Fix this by checking the attribute id/bustype on the device instead of just
the subsystem.

Fixes #4566
2017-03-07 07:55:58 +01:00
Thomas Hindoe Paaboel Andersen 3e021232da rules: allow quirks for platform input accelerometers 2017-03-03 21:23:39 +01:00
Daniel Drake 906d8a2ac5 udev: Allow quirks for ACPI input accelerometers
The existing accelerometer rules only support IIO devices, however
iio-sensor-proxy can also work with accelerometers made available
through the input (evdev) subsystem.

In this case I am working with an accelerometer input device backed by an
ACPI driver for which the hierarchy is:
- ACCE0001 (ACPI device)
  -> input8
    -> event7

We want the mount matrix (from hwdb) to be applied to both input8 and
event7. However, to match in 60-sensor.hwdb, we need to be working
with the modalias of the parent device (ACCE0001), and it is tricky
to access that when processing the input8 device which has it's own
modalias.

Instead of working directly with modalias, this ACPI-specific rule
uses the "hid" attribute to reconstruct the ACPI modalias. Since input
and event devices do not provide a hid attribute we will always get this
from the ACPI parent.

The modalias is constructed according to the definition in the kernel's
Documentation/acpi/namespace.txt and create_pnp_modalias(). We will only
use the first _CID/_HID value available, i.e. in some cases we will only
reconstruct the first part of the modalias, but that should be enough
granularity for our needs.
2017-03-02 00:02:22 +01:00
Viktor Mihajlovski fb92fbb1b1 udev: Use parent bus id for virtio disk builtin path-id (#5500)
The builtin path id for virtio block devices has been changed
to use the bus id without a prefix "virtio-pci" to be
compatible with all virtio transport types.

In order to not break existing setups, the by-path symlinks for
virtio block devices on the PCI bus are reintroduced by udev rules.
The virtio-pci symlinks are considered to be deprecated and
should be replaced by the native PCI symlinks.

Example output for a virtio disk in PCI slot 7:
 $ ls  /dev/disk/by-path
 pci-0000:00:07.0
 pci-0000:00:07.0-part1
 virtio-pci-0000:00:07.0
 virtio-pci-0000:00:07.0-part1

See also
[1] https://lists.freedesktop.org/archives/systemd-devel/2017-February/038326.html
[2] https://lists.freedesktop.org/archives/systemd-devel/2017-March/038397.html

This reverts f073b1b but keeps the same symlinks for compatibility.
2017-03-01 15:30:17 -05:00
Lennart Poettering 9d70cba987 udev rules: add udev rule to create /dev/ptp_kvm (#5495)
Its necessary to specify the KVM PTP device name in userspace.

In case a network card with PTP device is assigned to the guest,
it might be the case that KVM PTP gets /dev/ptp0 instead of /dev/ptp1.

Fix a device name for the KVM PTP device.
2017-02-28 21:28:21 +01:00
Keith Busch 5c1be4f730 Export NVMe WWID udev attribute (#5348)
We need this for multipath support without relying on NVMe to SCSI
translations.

Signed-off-by: Keith Busch <keith.busch@intel.com>
2017-02-17 08:46:06 +01:00
Marc-Andre Lureau 36971ed37b rules: add persistent by-path drm rules (#5337)
Create persistent symlinks for DRM devices, ex:
/dev/dri/by-path/pci-0000:00:02.0-card -> /dev/dri/card1
/dev/dri/by-path/pci-0000:00:02.0-render -> /dev/dri/renderD129
etc...

This allows to configure DRM device usage with stable paths.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-02-14 10:18:27 +01:00
Hans de Goede 57bb707d48 rules: Add extended evdev/input match rules for event nodes with the same name
Sometimes a system may have 2 input event nodes with the same name where
we only want to apply keyboard hwdb rules to 1 of the 2 devices.

This problem happens e.g. on devices where the soc_button_array driver is
used (e.g. intel atom based tablets) which registers 2 event nodes with
the name "gpio-keys".

This commit adds a new extended match rule which extends the match to also
check $attr{phys} and $attr{capabilities/ev}, allowing to differentiate
between devices with an identical name.

Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2017-02-12 12:43:23 +01:00
Mirza Krak ce283b8887 rules: allow systemd to manage UBI volumes (#5214)
UBI is a software layer on top of MTD devices that is used with flash
chips.
2017-02-03 09:26:50 +01:00
Lennart Poettering 01af8c019a gpt-auto-generator: support LUKS encrypted root partitions
Previously, we supported GPT auto-discovery for /home and /srv, but not
for the root partition. Add that, too.

Fixes: #859
2016-12-21 19:09:30 +01:00
Franck Bui ebc8968bc0 core: make mount units from /proc/self/mountinfo possibly bind to a device (#4515)
Since commit 9d06297, mount units from mountinfo are not bound to their devices
anymore (they use the "Requires" dependency instead).

This has the following drawback: if a media is mounted and the eject button is
pressed then the media is unconditionally ejected leaving some inconsistent
states.

Since udev is the component that is reacting (no matter if the device is used
or not) to the eject button, users expect that udev at least try to unmount the
media properly.

This patch introduces a new property "SYSTEMD_MOUNT_DEVICE_BOUND". When set on
a block device, all units that requires this device will see their "Requires"
dependency upgraded to a "BindTo" one. This is currently only used by cdrom
devices.

This patch also gives the possibility to the user to restore the previous
behavior that is bind a mount unit to a device. This is achieved by passing the
"x-systemd.device-bound" option to mount(8). Please note that currently this is
not working because libmount treats the x-* options has comments therefore
they're not available in utab for later application retrievals.
2016-12-16 17:13:58 +01:00
Daniel Drake d84071d569 rules: identify internal sound cards on platform bus (#4893)
We have a system which has the HDMI audio capability internally,
but pulseaudio is not giving it a very high priority compared
to e.g. USB sound cards.

The sound device appears on the platform bus and it is not
currently tagged with any form factor information.

It seems safe to assume that any sound card that is directly on the
platform bus is of internal form factor, but we must be careful because
udev rules will match all parent devices, not just the immediate parent,
and you will frequently encounter setups such as:

 Platform bus -> USB host controller -> USB sound card

In that case, SUBSYSTEMS==platform would match even though we're
clearly working with an external USB sound card.

In order to detect true platform devices here, we rely on the observation
that if any parent devices of the sound card are PCI, USB or firewire
devices, then this sound card cannot directly connected to the platform
bus. Otherwise, if we find a parent device on the platform bus, we assume
this is an internal sound card connected directly to the platform bus.
2016-12-15 23:11:11 +01:00
Bastien Nocera 1f886b50f6 udev: Add rules for accelerometer orientation quirks
This commit adds a rules file to extract the properties from hwdb
to set on i2c IIO devices. This is used to set the ACCEL_MOUNT_MATRIX
property on IIO devices, to be consumed by iio-sensor-proxy or
equivalent daemon.

The hwdb file contains documentation on how to write quirks. Note
however that mount information is usually exported in:
- the device-tree for ARM devices
- the ACPI DSDT for Intel-compatible devices
but currently not extracted by the kernel.

Also note that some devices have the framebuffer rotation that changes
between the bootloader and the main system, which might mean that the
accelerometer is then wrongly oriented. This is a missing feature in the
i915 kernel driver: https://bugs.freedesktop.org/show_bug.cgi?id=94894
which needs to be fixed, and won't require quirks.
2016-12-10 02:25:11 -05:00
Kieran Colford 471b9850ee rules: consider MMC device partitions with partition number > 9 (#4831)
Add entries for extra partitions found on MMC devices (common in Chromebooks).
2016-12-06 10:46:13 +01:00
Martin Pitt 561d496d0b rules: add persistent links for nbd devices (#4785)
https://bugs.debian.org/837999
2016-12-01 16:22:47 -05:00
Michal Sekletar a5110c9030 rules: introduce disk/by-id (model_serial) symlinks for NVMe drives (#3974)
$ ls -l /dev/disk/by-id/nvme*
lrwxrwxrwx. 1 root root 13 Aug 17 04:25 /dev/disk/by-id/nvme-HUSPR3216AHP301_STM0001B6780 -> ../../nvme0n1
lrwxrwxrwx. 1 root root 15 Aug 17 04:25 /dev/disk/by-id/nvme-HUSPR3216AHP301_STM0001B6780-part1 -> ../../nvme0n1p1

https://github.com/systemd/systemd/issues/1453
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=779ff75617099f4defe14e20443b95019a4c5ae8
2016-08-17 14:10:28 +02:00
Lennart Poettering 32eae3c2a8 rules: make sure always set at least one property on rfkill devices
The rfkill service waits for rfkill device initialization as reported by
udev_device_is_initialized(), and if that is never reported it might dead-lock.

However, udev never reports completed initialization for devices that have no
properties or tags set. For some rfkill devices this might be the case, in
particular those which are connected to exotic busses, where path_id returns
nothing.

This patch simply sets the SYSTEM_RFKILL property on all rfkill devices, to
ensure that udev_device_is_initialized() always reports something useful and we
don't dead-lock.

Fixes: #2745
2016-07-20 09:17:57 +02:00
Rusty Bird 542127ea96 rules: UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG property (#3714)
Sometimes, the persistent storage rules should be skipped for a subset
of devices. For example, the Qubes operating system prevents dom0 from
parsing untrusted block device content (such as filesystem metadata) by
shipping a custom 60-persistent-storage.rules, patched to bail out early
if the device name matches a hardcoded pattern.

As a less brittle and more flexible alternative, this commit adds a line
to the two relevant .rules files which makes them test the value of the
UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG device property, modeled
after the various DM_UDEV_DISABLE_*_RULES_FLAG properties.
2016-07-15 18:47:42 +02:00
bgbhpe f3bc4ccc2e rules: block: add support for pmem devices (#3683)
Persistent memory devices can be exposed as block devices as /dev/pmemN
and /dev/pmemNs.  pmemN is the raw device and is byte-addressable from
within the kernel and when mmapped by applications from a DAX-mounted
file system.  pmemNs has the block translation table (BTT) layered on top,
offering atomic sector/block access.  Both pmemN and pmemNs are expected
to contain file systems.

blkid(8) and lsblk(8) seem to correctly report on pmemN and pmemNs.
systemd v219 will populate /dev/disk/by-uuid/ when, for example, mkfs is
used on pmem, but systemd v228 does not.

Add pmem to the whitelist.
2016-07-08 17:43:56 +02:00
Peter Hutterer 0bb7b9860f hwdb: add a 70-touchpad.hwdb to tag internal vs external touchpads
Add a new key ID_INPUT_TOUCHPAD_INTEGRATION=internal|external so we have a
single source for figuring out which touchpads are built-in.

Fairly simple approach: bluetooth is external, usb is external unless it's an
Apple touchpad. Everything else is internal.
2016-07-01 15:25:34 +10:00
Peter Hutterer 83b481599b rules: set ID_BUS for bluetooth, rmi and i8042
Something has to so we can have udev rules rely on this. Right now the ID_BUS
setting is inconsistent: usb is set, ata and pci are set, bluetooth is not
set, rmi is too new to be featured.

70-mouse even relied on bluetooth even though it was never set
2016-07-01 15:19:46 +10:00
Lennart Poettering a4e9499d8d rules: block - add scm block devices to whitelist (#3494)
Since the introduction of the whitelist in 60-persistent-storage.rules
block device symlinks are no longer created for scm block devices.

Add scm to the whitelist.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
2016-06-10 15:19:26 +02:00
Uwe Kleine-König cf1d3efce9 rules: add /dev/disk/by-partuuid symlinks also for dos partition tables
blkid reports PARTUUID values also for partitions that are defined by a
dos partitioning scheme. Instead of limiting the partitioning scheme to
"gpt or dos" just drop the test for the partitioning scheme and trust
blkid to do the right thing.
2016-05-19 08:37:20 +02:00
Ming Lin 427a28ecbe rules: add NVMe rules (#3136)
Add NVMe rules using the "wwid" attribute.

root@target:~# cat /sys/block/nvme0n1/wwid
eui.3825004235000591

root@target:~# ls /dev/disk/by-id/ -l |grep nvme
lrwxrwxrwx 1 root root 13 Apr 27 16:08 nvme-eui.3825004235000591 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Apr 27 16:08 nvme-eui.3825004235000591-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Apr 27 16:08 nvme-eui.3825004235000591-part2 -> ../../nvme0n1p2
2016-04-29 13:02:57 +02:00
Wouter Verhelst 565754a37e Mark nbd as inactive until connected (#2422)
Currently, 99-systemd.rules.in contains a line for network block
devices, which mark them as inactive until the first change event, and
as active from then on forward. This is not correct. A network block
device can be connected or disconnected; this state is signalled by the
presence or absense of a "pid" file, which contains the PID of the
nbd client userspace process that started the connection.

Update the rules file so that it checks for the presence of that file to
decide what to set SYSTEMD_READY to.

Note that current kernels do issue a change event upon connecting the
device, but not yet upon disconnecting. While it's possible to wait
until that's been fixed, the behaviour of the rule with TEST!="pid" in
the absence of a proper uevent is exactly the same as the behaviour of
the old rule; so it should be safe to apply now.

Signed-off-by: Wouter Verhelst <w@uter.be>
2016-04-18 16:29:10 +02:00
Lukáš Nykrýn 35a6750d9e rules: set SYSTEMD_READY=0 on DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 only with ADD event (#2747)
The "SYSTEMD_READY=0" will cause automatic unmount
of mountpoint that is on top of such DM device
if this is used with multipath which sets
DM_UDEV_DISABLE_OTHER_RULES_FLAG in case
we have a CHANGE event thatcomes after DM multipath
device reload when one of the paths is down or up.

See https://bugzilla.redhat.com/show_bug.cgi?id=1312011
2016-04-12 07:44:28 +02:00
Lennart Poettering d35c1bb1f4 rfkill: rework and make it listen on /dev/rfkill
With this rework we introduce systemd-rfkill.service as singleton that
is activated via systemd-rfkill.socket that listens on /dev/rfkill. That
way, we get notified each time a new rfkill device shows up or changes
state, in which case we restore and save its current setting to disk.

This is nicer than the previous logic, as this means we save/restore
state even of rfkill devices that are around only intermittently, and
save/restore the state even if the system is shutdown abruptly instead
of cleanly.

This implements what I suggested in #1019 and obsoletes it.
2015-10-01 16:21:09 +02:00
Thomas Meyer 7519d221e0 UML: Fix block device setup
User mode linux block devices start with ubd, e.g. ubda, ubdb, etc..
2015-08-09 18:07:55 +02:00
Kay Sievers 604f02add6 rules: block - add dasd to whitelist 2015-07-05 16:22:30 +02:00
Tom Gundersen ab49ae5ba6 Merge pull request #387 from kaysievers/wip
udev: Remove accelerometer helper
2015-06-29 16:02:33 +02:00
Cédric Delmas ba27fb2111 Process cciss devices
Do not skip the persistent storage rules for cciss devices
2015-06-29 09:54:58 +02:00
Bastien Nocera 0051ebf7e5 udev: Remove accelerometer helper
It's moved to the iio-sensor-proxy D-Bus service.
2015-06-27 21:48:52 +02:00
Greg Kroah-Hartman 57a2bf2329 Merge pull request #353 from kaysievers/hid
rules: remove all power management from udev
2015-06-26 09:51:11 -07:00
Peter Hutterer 0530459245 Revert "hwdb: add a touchpad hwdb"
The main purpose of this hwdb was to tag touchpads that have the physical
trackstick buttons wired to the touchpad (Lenovo Carbon X1 3rd, Lenovo *50
series).  This hwdb is not required on kernels 4.0 and above, the kernel now
re-routes button presses through the trackstick's device node. Userspace does
not need to do anything.

See kernel commit cdd9dc195916ef5644cfac079094c3c1d1616e4c.

This reverts commit 001a247324.
2015-06-26 16:09:48 +10:00
Kay Sievers e2452eef02 rules: remove all power management from udev
It is not udev's task to apply any of these setting that way, or
from udev rules files. Things need to be sortet out in the kernel,
or explicit whitelist can possibly be added to the hardware database.
Until that is sorted out, and general agreement, udev is not
willing to maintain any such lists or power management settings
in general.

"Thanks for digging this out! I thought my Kinesis keyboard got broken
and ordered a new one, only to find out that the new one doesn't work
as well. I'm not sure whether we should start collecting a blacklist
of keyboards which don't work with USB autosuspend, or rather a
whitelist? Or revert this wholesale?"

  https://github.com/systemd/systemd/issues/340
2015-06-24 13:18:53 +02:00
Alex Crawford fb2d301085 rules: re-add cciss rules
The original commit (1aff206) doesn't explain why these were removed.
This adds them back since they are in fact needed.
2015-06-10 15:49:41 -07:00
Alex Crawford bb5c512de2 rules: whitelist xvd* devices
Xen disks need to be whitelisted as well.
2015-06-08 18:22:21 -07:00
Ed Swierk ff2aa01e61 Add /dev/xvd* to 60-persistent-storage whitelist
Without this, systemd-udevd does not create persistent storage symlinks
for xen block devices.
2015-06-03 08:08:37 -07:00
David Mohr 19672f1e5f udev: Bring back persistant storage symlinks for bcache
https://bugs.debian.org/787367
2015-06-01 11:44:52 +02:00
Tom Gundersen b50063512d rules: restore block watch after CHANGE events
When processing an event, the watch is disabled, make sure it is restorted after
a CHANGE event has been processed.
2015-05-30 02:14:25 +02:00
Tom Gundersen f07689517e rules: fix typo in block watch rule
The intention was to turn this rule from using a blacklist to a whitelist, but
there was a stray '!'.
2015-05-30 02:14:25 +02:00
Adam Goode 5c0b72de3a rules: Add more firewire properties for sound, to be closer to USB and PCI
USB and PCI soundcards have a nice set of ID_* properties. It would
be handy for firewire soundcards to have the same.

Note that this removes the explicit setting of ID_ID in the firewire
conditional. Because we are now setting ID_SERIAL, ID_ID will come
from later in the file.
2015-04-23 13:40:54 +02:00
Adam Goode 0414af1dfe rules: Don't use ALSA card id in ID_ID
The ALSA id sysattr is generated by the sound subsystem and is not
a stable identifier. It is generated though some string manipulation
then made unique if there is a conflict. This means that it is
enumeration-dependent and shouldn't be used for ID_ID.

If ID_ID is supposed to be system-unique, it is not already since
for firewire it is generated from the guid and there are broken
firewire devices that have duplicate guids across devices.

This is tracked for PulseAudio at
https://bugs.freedesktop.org/show_bug.cgi?id=90129.

This is essentially a revert of systemd
ed1b2d9fc7.
2015-04-23 13:40:54 +02:00
Zbigniew Jędrzejewski-Szmek c7e3c3ecac rules: finish incomplete rename
Fixup for 51c0c28698.
2015-04-12 10:20:24 -04:00
Matthew Garrett 64713f9252 rules: fix tests for removable state
We only care about whether our direct parent is removable, not whether any
further points up the tree are - the kernel will take care of policy for
those itself. This enables autosuspend on devices where the root hub reports
that its removable state is unknown.
2015-04-11 12:22:17 +02:00
Peter Hutterer 51c0c28698 udev: builtin-keyboard: add support for EVDEV_ABS_*
Parse properties in the form
EVDEV_ABS_00="<min>:<max>:<res>:<fuzz>:<flat>"

and apply them to the kernel device. Future processes that open that device
will see the updated EV_ABS range.

This is particularly useful for touchpads that don't provide a resolution in
the kernel driver but can be fixed up through hwdb entries (e.g. bcm5974).

All values in the property are optional, e.g. a string of "::45" is valid to
set the resolution to 45.

The order intentionally orders resolution before fuzz and flat despite it
being the last element in the absinfo struct. The use-case for setting
fuzz/flat is almost non-existent, resolution is probably the most common case
we'll need.

To avoid multiple hwdb invocations for the same device, replace the
hwdb "keyboard:" prefix with "evdev:" and drop the separate 60-keyboard.rules
file. The new 60-evdev.rules is called for all event nodes
anyway, we don't need a separate rules file and second callout to the hwdb
builtin.
2015-04-11 08:44:33 +10:00
Harald Hoyer a06c8219a3 50-udev-default.rules: don't run anything but REMOVE_CMD on remove
we don't want to run usb_id and input_id on ACTION=="remove"
2015-03-27 15:42:04 +01:00
Mantas Mikulėnas afa91a7231 rules: storage - support MemoryStick (non-Pro) cards
These are handled by a different driver than MemoryStick Pro.
2015-03-24 23:34:58 +01:00