This file is indexed.

/lib/udev/rules.d/60-bit-babbler.rules is in bit-babbler 0.8.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SUBSYSTEM!="usb", GOTO="bb_end"

ACTION!="add|change", GOTO="bb_end_add"

# This is what we'd like to do.  Skip all the rules here if Vendor:Product
# is not 0403:7840 -- but that's not what these two tests will actually do
# (at least with udev versions up to 232-25 which shipped in Stretch).
# If the device we're handling an event for doesn't have the idVendor or
# idProduct attributes at all, then these tests are still false, the same
# as if they did have the values which we are testing for ...
#ATTR{idVendor}!="0403", GOTO="bb_end"
#ATTR{idProduct}!="7840", GOTO="bb_end"

# So instead, we need to explicitly test that they *are* the values we are
# looking for, and play goto leapfrog to get the control flow logic we want.
ATTR{idVendor}=="0403", ATTR{idProduct}=="7840", GOTO="bb_add"
GOTO="bb_end"

LABEL="bb_add"

# Allow users in group bit-babbler to access the device directly.
# Create a symlink to a well known name that can be used in the cgroup_device_acl
# configuration in /etc/libvirt/qemu.conf, and for other similar purposes too.
# And run the bbvirt script to see if this device was configured for hotplugging
# into a virtual machine.
GROUP="bit-babbler", MODE="0660", SYMLINK="bitbabbler/$attr{serial}", \
 RUN+="/usr/bin/bbvirt attach $attr{serial} --busnum $attr{busnum} --devnum $attr{devnum}"

# If ACLs are supported, grant users in the bit-babbler group access to the device
# with them too.  This is mainly so that if a VM is halted, the device will revert
# to normal access from the host system again.  The libvirt 'managed' mode will not
# restore the original ownership when it releases the device, it will just make it
# be root:root, stomping the GROUP we set above.
TEST=="/usr/bin/setfacl", RUN+="/usr/bin/setfacl -m g:bit-babbler:rw $devnode"

# Enable USB autosuspend.  The BitBabbler devices support suspending correctly,
# though not every controller they might be plugged into will always play nicely.
# It should be safe to enable it here, even if an upstream hub or controller
# needs it disabled.  The XHCI controllers seem to be the most troublesome, but
# mostly with older kernels.
TEST=="power/control", ATTR{power/control}="auto"
TEST=="power/autosuspend_delay_ms", ATTR{power/autosuspend_delay_ms}="2000"

LABEL="bb_end_add"


ACTION!="remove", GOTO="bb_end"

# Explicitly detach unplugged devices from the VM if they were passed through to it.
# If we don't do this, the stale <hostdev> configuration will remain, and could
# match some other completely different device that is plugged in later ...
# This is why we can't make persistent changes to the domain definition for VMs that
# aren't running when the device is plugged in, because if the host goes down without
# this rule being run, we'd never clean those up.
#
# We can't test against the attributes here, if this would match they are already gone.
ENV{ID_VENDOR_ID}=="0403", ENV{ID_MODEL_ID}=="7840", \
 RUN+="/usr/bin/bbvirt detach $env{ID_SERIAL_SHORT} --busnum $env{BUSNUM} --devnum $env{DEVNUM}"

LABEL="bb_end"