3 # /etc/hotplug/usb/consoleUserPerms
5 # Sets up newly plugged in USB device so that the user who owns
6 # the console according to pam_console can access it from user space
8 # Note that for this script to work, you'll need all of the following:
9 # a) a line in the file /etc/hotplug/usb.usermap or another usermap file
10 # in /etc/hotplug/usb/ that corresponds to the device you are using.
11 # b) a setup using pam_console creates the respective lock files
12 # containing the name of the respective user. You can check for that
13 # by executing "echo `cat /var/{run,lock}/console.lock`" and
14 # verifying the appropriate user is mentioned somewhere there.
15 # c) a Linux kernel supporting hotplug and usbdevfs
16 # d) the hotplug package (http://linux-hotplug.sourceforge.net/)
18 # In the usermap file, the first field "usb module" should be named
19 # "consoleUserPerms" to invoke this script.
22 if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
24 # New code, using lock files instead of copying /dev/console permissions
25 # This also works with non-kdm logins (e.g. on a virtual terminal)
26 # Idea and code from Nalin Dahyabhai <nalin@redhat.com>
27 if [ -f /var
/run
/console.lock
]
29 CONSOLEOWNER
=`cat /var/run/console.lock`
30 elif [ -f /var
/lock
/console.lock
]
32 CONSOLEOWNER
=`cat /var/lock/console.lock`
36 if [ -n "$CONSOLEOWNER" ]
38 chmod 0000 "${DEVICE}"
39 chown
"$CONSOLEOWNER" "${DEVICE}"
40 chmod 0600 "${DEVICE}"