Merge pull request #67 from Lekensteyn/updates
udev: Use uaccess instead of plugdev (pwr/Solaar#66)
This commit is contained in:
commit
818ece9f10
|
|
@ -0,0 +1,27 @@
|
|||
# Allows non-root users to have raw access the Logitech Unifying USB Receiver
|
||||
# device. For development purposes, allowing users to write to the receiver is
|
||||
# potentially dangerous (e.g. perform firmware updates).
|
||||
|
||||
# skip actual unified devices, only consider the receiver
|
||||
DRIVERS=="logitech-djdevice", GOTO="not_unify_recv"
|
||||
|
||||
# official Unifying receivers
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", GOTO="unify_dev"
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c532", GOTO="unify_dev"
|
||||
|
||||
# "Unifying Ready" Nano receiver
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52f", GOTO="unify_dev"
|
||||
|
||||
GOTO="not_unify_recv"
|
||||
|
||||
LABEL="unify_dev"
|
||||
# Allow any seated user to access the receiver.
|
||||
# uaccess: modern ACL-enabled udev
|
||||
# udev-acl: for Ubuntu 12.10 and older
|
||||
TAG+="uaccess", TAG+="udev-acl"
|
||||
|
||||
# Grant members of the "plugdev" group access to receiver (useful for SSH users)
|
||||
#MODE="0660", GROUP="plugdev"
|
||||
|
||||
LABEL="not_unify_recv"
|
||||
# vim: ft=udevrules
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# Initially copied from signal11/hidapi/udev, with modifications.
|
||||
|
||||
# This is a sample udev file for HIDAPI devices which changes the permissions
|
||||
# to 0660 and group to plugdev for a specified device on Linux systems.
|
||||
|
||||
# Make sure the plugdev group exists on your system and your user is a member
|
||||
# before applying these rules.
|
||||
|
||||
# HIDAPI/hidraw for Logitech Unifying Receiver
|
||||
ACTION=="add", KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", GROUP="plugdev", MODE="0660"
|
||||
ACTION=="add", KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c532", GROUP="plugdev", MODE="0660"
|
||||
|
||||
# HIDAPI/hidraw for Logitech Nano Receiver, "Unifying ready"
|
||||
ACTION=="add", KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52f", GROUP="plugdev", MODE="0660"
|
||||
|
||||
# HIDAPI/hidraw for VX Nano receiver
|
||||
#ACTION=="add", KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c51a", GROUP="plugdev", MODE="0660"
|
||||
#ACTION=="add", KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c526", GROUP="plugdev", MODE="0660"
|
||||
|
||||
# vim: ft=udevrules
|
||||
|
|
@ -10,19 +10,30 @@ if ! test -d "$RULES_D"; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
RULE=99-logitech-unifying-receiver.rules
|
||||
RULE=42-logitech-unify-permissions.rules
|
||||
|
||||
if test -n "$1"; then
|
||||
SOURCE="$1"
|
||||
else
|
||||
SOURCE="$(dirname "$Z")/$RULE"
|
||||
if ! id -G -n | grep -q -F plugdev; then
|
||||
GROUP="$(id -g -n)"
|
||||
echo "User '$USER' does not belong to the 'plugdev' group, will use group '$GROUP' in the udev rule."
|
||||
TEMP_RULE="${TMPDIR:-/tmp}/$$-$RULE"
|
||||
cp -f "$SOURCE" "$TEMP_RULE"
|
||||
REALUSER="${SUDO_USER-$USER}"
|
||||
if [ -z "$REALUSER" -o "$REALUSER" = "root" ]; then
|
||||
: # ignore unknown and root user
|
||||
else
|
||||
GROUP=plugdev
|
||||
TEMP_RULE="$(mktemp --tmpdir "ltudev.XXXXXXXX")"
|
||||
sed -e "/^#MODE.*\"plugdev\"/s/^#//" "$SOURCE" > "$TEMP_RULE"
|
||||
if ! id -G -n "$REALUSER" | grep -q -F plugdev; then
|
||||
GROUP="$(id -g -n "$REALUSER")"
|
||||
if getent group plugdev >/dev/null; then
|
||||
printf "User '%s' does not belong to the 'plugdev' group, " "$REALUSER"
|
||||
else
|
||||
printf "Group 'plugdev' does not exist, "
|
||||
fi
|
||||
echo "will use group '$GROUP' in the udev rule."
|
||||
sed -i -e "s/\"plugdev\"/\"$GROUP\"/" "$TEMP_RULE"
|
||||
fi
|
||||
SOURCE="$TEMP_RULE"
|
||||
sed -i -e "s/GROUP=\"plugdev\"/GROUP=\"$GROUP\"/" "$SOURCE"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -36,7 +47,6 @@ if test "$(id -u)" != "0"; then
|
|||
fi
|
||||
|
||||
echo "Installing $RULE."
|
||||
cp "$SOURCE" "$RULES_D/$RULE"
|
||||
chmod a+r "$RULES_D/$RULE"
|
||||
install -m 644 "$SOURCE" "$RULES_D/$RULE"
|
||||
|
||||
echo "Done. Now remove the Unfiying Receiver and plug it in again."
|
||||
|
|
|
|||
Loading…
Reference in New Issue