#!/bin/bash # This file was installed by the sane-backends package. # # This script changes the permissions and ownership of a USB device under # /proc/bus/usb to grant access to this device to users in the usb group # and the first user that logged in. # # Ownership is set to $USER.usb, where $USER is the first user that logged # in (through pam_console). If there is no user logged in, the ownership # will get set to root.usb. Permissions are set to 0660. # # Arguments : # ----------- # ACTION=[add|remove] # DEVICE=/proc/bus/usb/BBB/DDD # TYPE=usb if [ "$ACTION" = "add" -a "$TYPE" = "usb" ] && [ -f "${DEVICE}" ]; then if [ -f /var/run/console.lock ]; then USER=`cat /var/run/console.lock` else USER=root fi # sanity check if [ -z $USER ]; then USER=root fi chown $USER:usb "$DEVICE" chmod 0660 "$DEVICE" fi