chiark / gitweb /
remove example rules and put the dev.d stuff into the run_directory folder
[elogind.git] / extras / run_directory / dev.d / default / pam_console.dev
1 #!/bin/sh
2
3 # Fedora solution to set the ownership/permissions of s device to the local
4 # logged in user. Uses the program pam_console_setowner to match the names of
5 # the device node and the symlinks against a device list and applies the
6 # configured ownership and permission to the node.
7
8 [ "$ACTION" != "add" ] && exit 0
9
10 # we do not have console users in rc.sysinit
11 [ -n "$IN_INITLOG" ] && exit 0
12
13 if [ -x /sbin/pam_console_setowner -a -f /var/run/console/console.lock \
14         -a -e "$DEVNAME" ]; then
15
16         if [ -x /usr/bin/logger ]; then
17             LOGGER=/usr/bin/logger
18         elif [ -x /bin/logger ]; then
19             LOGGER=/bin/logger
20         else
21             unset LOGGER
22         fi
23         #
24         # for diagnostics
25         #
26         if [ -t 1 -o -z "$LOGGER" ]; then
27             mesg () {
28                 echo "$@"
29             }
30         else
31             mesg () {
32                 $LOGGER -t $(basename $0)"[$$]" "$@"
33             }
34         fi
35
36         debug_mesg () {
37             test "$udev_log" = "" -o "$udev_log" = "no" && return
38             mesg "$@"
39         }
40
41         if [ -f /etc/udev/udev.conf ]; then
42                 . /etc/udev/udev.conf
43         fi
44
45         SYMLINKS=""
46         for i in $(/usr/bin/udevinfo -q symlink -p "$DEVPATH"); do
47                 [ $? -gt 0 ] && break
48                 SYMLINKS="$SYMLINKS ${udev_root%%/}/$i"
49         done
50         debug_mesg "Restoring console permissions for $DEVNAME $SYMLINKS"
51         /sbin/pam_console_setowner "$DEVNAME" $SYMLINKS
52 fi