Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > 1c87159ab3f86cbd9e4a4187789a15aa > files > 7

sane-1.0.13-6mdk.src.rpm

#!/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