Typo
[linux_from_scratch_hints.git] / OLD / dsp_devfsd.txt
blob013e011e2c72a36eae10b0d8aba8acbd2f4df5a9
1 TITLE:          dsp+devfsd
2 LFS VERSION:    all
3 AUTHOR:         Joris Vankerschaver <Joris.Vankerschaver@rug.ac.be>
6 SYNOPSIS:
7         When using a regular /dev directory, all 
8         one needs to do to allow non root users access
9         to sound is to set permissions on the audio
10         devices.  Devfsd, however, creates devices 
11         on the fly and so we need a way of telling 
12         devfsd when and how to create these devices.
14         This hint describes how to set up devfsd to 
15         automatically 
16         1) set permissions on /dev/dsp appropriately
17            to allow non root users access to /dev/dsp.
18         2) load the relevant modules (if any) when
19            an application tries to open /dev/dsp.
21         This hint does not cover setting up esd or any
22         other sound daemon.  It might, though, if someone
23         wants to write an update :)
25         You need: devfsd and a kernel compiled with
26         sound support (either module or compiled in).
28 THANKS TO:
29         Robert Bracewell, for pointing out an inaccuracy in 
30         step 1. 
32 HINT:
33 1) Add a group 'audio' and a user 'audio':
34         groupadd audio
35         useradd -g audio audio
37 2) Add every user that requires audio access to the 
38    audio group.  Open /etc/group and just add the
39    login names (separated by commas) to the line
40    that starts with 'audio'
42 3) Load /etc/devfsd.conf in your favourite editor 
43    and append the following line:
45    REGISTER sound/.*    PERMISSIONS     audio.audio rw-rw----
47    When using the default namespace, devfs keeps all the
48    audio related files under /dev/sound.  The above command
49    will cause devfsd to change the permissions on /dev/sound/*
50    from root.root and rw------- to audio.audio, rw-rw----.
51    To maintain compatibility, devfs creates a symlink from 
52    /dev/dsp to /dev/sound/dsp (That is, if you haven't messed
53    with the options in /etc/devfsd.conf.  But then you don't
54    need this hint :)).   
56    This line instructs devfsd to change the permissions on
57    every file in the /dev/sound/ directory, every time a
58    driver registers these devices (that is, every time the sound
59    module or the kernel is loaded).
61    Note: the line says 'sound/.*' and NOT '/dev/sound/.*'!  
62    Devfs will not issue a warning if you make a mistake there and
63    you will spend many hours hunting bugs (that aren't).
65 4) If you have compiled sound support into the kernel, you're done.
66    Just send a SIGHUP signal to devfsd (killall -HUP devfsd) and 
67    you are ready to play.
69    If you're like me and you have compiled sound support as a
70    module, the trouble begins.  Apparently, the lookup of /dev/dsp
71    isn't enough to trigger the module autoloader.  So you need
72    to have the relevant modules already in place to have devfsd
73    automatically create all the necessary devices and links.
75    First of all, you need to know what your soundcard module is called.
76    If you don't know, go check in 
77    /lib/modules/2.4.[minor]/kernel/drivers/sound.  In my case, this
78    module is called 'sb.o'.  It's very important that you pick the 
79    actual module itself, and not some support module.  If you're
80    not sure, modprobe 'em all and then inspect the output of 
81    lsmod to check for a sound module that doesn't depend on the others.
83 5) Create a shell script with approximately the following contents:
84    
85    --BEGIN--
86    #!/bin/sh
88    sound_mod=[YOUR MOD NAME HERE]
90    pres=`lsmod | grep "^$sound_mod\ " | tr -d '[:space:]'`
91    if [ -z $pres ]; then
92            modprobe $sound_mod
93    fi
94    --END--
96    I called this script 'safe_sb_load' and put it in /usr/sbin.
97    Of course, you might think of something better.
99    Don't forget to make this script executable 
100    (chmod +x /usr/sbin/safe_sb_load)
102    Note: the name of the module is the name as listed by lsmod.  So
103    in my case, it's 'sb', and NOT 'sb.o', NOT '/lib/modules/.../sb.o',
104    etc.  This is also very important.
106 6) Add the following line to /etc/devfsd.conf:
108    LOOKUP       dsp             EXECUTE         safe_sb_load
110    This, of course, assumes that safe_sb_load is in a default path.
112    As a matter of fact, step 5 is somewhat redundant, since we 
113    might have put in 'EXECUTE modprobe sb' instead of redirecting
114    it to safe_sb_load.  With a script however, you can do some
115    error checking (as we do in step 5), or add other commands
116    (logging, loading of other programs).  Do as you wish.
118 7) Restart devfsd.  If all goes well, you will now have sound
119    without suid-root scripts and without unsafe permissions in
120    your /dev directory.
122 Finally) You can improve upon this scenary in many ways.  For
123    example, you might want to create two groups in step one,
124    one with read/write access and one with read access only.
126    Happy tweaking!