Skip to content

Commit 4edc6e2

Browse files
udev lock to application username
1 parent 09bd841 commit 4edc6e2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

device-permissions.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ echo "Cleanup..."
33
sudo rm -f /etc/udev/rules.d/99-corsair-*.rules
44

55
echo "Setting udev device permissions..."
6+
APP_USERNAME="openlinkhub"
67
lsusb -d 1b1c: | while read -r line; do
78
ids=$(echo "$line" | awk '{print $6}')
89
vendor_id=$(echo "$ids" | cut -d':' -f1)
@@ -19,11 +20,11 @@ done
1920

2021
if [ "$match" = true ]; then
2122
cat > /etc/udev/rules.d/99-corsair-"$device_id".rules <<- EOM
22-
SUBSYSTEMS=="usb", ATTRS{idVendor}=="$vendor_id", ATTRS{idProduct}=="$device_id", MODE="0666"
23+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="$vendor_id", ATTRS{idProduct}=="$device_id", MODE="0600", OWNER="$APP_USERNAME"
2324
EOM
2425
else
2526
cat > /etc/udev/rules.d/99-corsair-"$device_id".rules <<- EOM
26-
KERNEL=="hidraw*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="$vendor_id", ATTRS{idProduct}=="$device_id", MODE="0666"
27+
KERNEL=="hidraw*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="$vendor_id", ATTRS{idProduct}=="$device_id", MODE="0600", OWNER="$APP_USERNAME"
2728
EOM
2829
fi
2930
done

src/devices/devices.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ type Product struct {
101101
}
102102

103103
var (
104-
expectedPermission = 0666
104+
expectedPermission = 0600
105105
vendorId uint16 = 6940 // Corsair
106106
interfaceId = 0
107107
devices = make(map[string]*Device, 0)

0 commit comments

Comments
 (0)