summaryrefslogtreecommitdiff
path: root/etc/dev.d/default/pam_console.dev
blob: 4c69ea3576d828c64ba17b6e49a684deaaea930d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh

# Fedora solution to set the ownership/permissions of s device to the local
# logged in user. Uses the program pam_console_setowner to match the names of
# the device node and the symlinks against a device list and applies the
# configured ownership and permission to the node.

[ "$ACTION" != "add" ] && exit 0

# we do not have console users in rc.sysinit
[ -n "$IN_INITLOG" ] && exit 0

if [ -x /sbin/pam_console_setowner -a -f /var/run/console/console.lock \
	-a -e "$DEVNAME" ]; then

	if [ -x /usr/bin/logger ]; then
	    LOGGER=/usr/bin/logger
	elif [ -x /bin/logger ]; then
	    LOGGER=/bin/logger
	else
	    unset LOGGER
	fi
	#
	# for diagnostics
	#
	if [ -t 1 -o -z "$LOGGER" ]; then
	    mesg () {
	        echo "$@"
	    }
	else
	    mesg () {
	        $LOGGER -t $(basename $0)"[$$]" "$@"
	    }
	fi

	debug_mesg () {
	    test "$udev_log" = "" -o "$udev_log" = "no" && return
	    mesg "$@"
	}

	if [ -f /etc/udev/udev.conf ]; then
        	. /etc/udev/udev.conf
	fi

	SYMLINKS=""
	for i in $(/usr/bin/udevinfo -q symlink -p "$DEVPATH"); do
		[ $? -gt 0 ] && break
		SYMLINKS="$SYMLINKS ${udev_root%%/}/$i"
	done
	debug_mesg "Restoring console permissions for $DEVNAME $SYMLINKS"
	/sbin/pam_console_setowner "$DEVNAME" $SYMLINKS
fi