summaryrefslogtreecommitdiff
path: root/share/opie-login/pre-session
blob: 6bf9e4c5e4062ab94ee566632307547384d6b9b2 (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
53
54
55
56
#!/bin/sh

USER=$1

# NOTE about permissions in OpenZaurus
# 	The devices in question here by default
#	are accessible to everyone in the group in
#	question.  We wish to ensure that, as a policy
#	choice, a login to opie makes access to these
#	devices exclusive by 1) changing device ownership
#	to the user, and 2) removing group access.
#
#	A better implementation would probably be to store
#	existing device permissions at load time, and restore
#	them at exit, rather than making assumptions about
#	user/group ownership, or permissions.

permin ()
{
	if [ -e $1 ]
	then
		
	chown $USER $1
	chmod g-rw $1

	else
		return 1
	fi
}

permout ()
{
	[ -e $1 ]	&& chown root $1
	[ -e $1 ]	&& chmod g+rw $1
}

if [ -e /proc/hal/model ]; then

  # fix for misconfigured devfsd
  chmod +x /dev/sound /dev/touchscreen /dev/fb /dev/vc

  [ -e /dev/sound/dsp ]     && chown $USER /dev/sound/dsp
  [ -e /dev/sound/mixer ]   && chown $USER /dev/sound/mixer
  [ -e /dev/touchscreen/0 ] && chown $USER /dev/touchscreen/0
  [ -e /dev/fb/0 ]          && chown $USER /dev/fb/0
  [ -e /dev/vc/0 ]          && chown $USER /dev/vc/0

else

  for dev in /dev/dsp /dev/dsp1 /dev/mixer \
  	/dev/ts /dev/fb0 
  do
	permin( $dev )
  done

fi