From fbfd70a51a94724ad4712465ddd7a90cf7b8a0d2 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 6 Aug 2013 15:55:25 +0200 Subject: usbmon-setperms: add helper for usbmon permissions For unprivileged use of usbmon. --- usbmon-setperms | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 usbmon-setperms (limited to 'usbmon-setperms') diff --git a/usbmon-setperms b/usbmon-setperms new file mode 100755 index 0000000..d2cc893 --- /dev/null +++ b/usbmon-setperms @@ -0,0 +1,28 @@ +#!/bin/sh +# helper for allowing the developer to read usbmon as non-root. + +if [ "$USER" = "root" ]; then + echo "Please run as regular user or set USER" + exit 1 +fi + +if [ ! -e /dev/usbmon0 ]; then + echo "Attempting to modprobe usbmon..." + sudo modprobe -v usbmon + if [ ! -e /dev/usbmon0 ]; then + echo "Cannot locate 'usbmon' kernel module" + exit 1 + fi +fi + +usbmons=$(lsusb -d046d: | cut -c7 | sed 's,^,/dev/usbmon,') + +echo Found devices: $usbmons + +if [ -n "$usbmons" ]; then + echo "Attempting to change permissions..." + sudo chgrp -v $USER $usbmons + sudo chmod -v g+rw $usbmons +else + echo "No devices found" +fi -- cgit v1.2.1