Re: [LAU] ALSA device not found by some users... why?

From: Tim Black <timblack0@email-addr-hidden>
Date: Thu Feb 07 2008 - 20:34:42 EET

Thanks, Clemens. Right, initially /dev/snd/*, /dev/dsp*, and
/dev/audio* permissions were 600 root:root, and this is presumably set
by udev. In this state, mpd2 could not access the devices, but if when
I added mpd2 user to the root group it could, providing a somewhat
insecure kludgey solution to my problem. So I keep looking for another
solution...

Then I added the following lines to my
/etc/security/console.perms.d/50-default.perms:

<sound>=/dev/dsp* /dev/snd/* /dev/audio*
<console> 0666 <sound> 0600 root.audio

and now the permissions are 0666 root.audio by default. When I log in
as user tim, it appears that the permissions get changed to 0666
tim.audio. This should still be fine, bc my mpd2 user is in the audio
group, so *should* have read/write access. When I su mpd2, the
permissions listed are the same, but mpd2 can't access the devices. I
haven't tried actually logging in as mpd2 bc I didn't think it would
be any different. I will try that later, but this may all be a moot
point bc mpd2 is basically going to be a "server-only" user, with
SHELL=/sbin/nologin, so for all this, I've modified the user to use
bash just for testing purposes.

Interestingly, as mpd2, I get permission denied error when try to
access /dev/snd/pcmC0D0c, but as tim I get the expected error:

[mpd2@email-addr-hidden tim]$ ls -la /dev/snd
total 0
drwxr-xr-x 2 root root 460 2008-02-06 22:17 .
drwxr-xr-x 15 root root 4520 2008-02-06 22:17 ..
crw-rw-rw-+ 1 tim audio 116, 17 2008-02-06 22:17 controlC0
crw-rw-rw-+ 1 tim audio 116, 22 2008-02-06 22:17 controlC1
crw-rw-rw-+ 1 tim audio 116, 12 2008-02-06 22:17 controlC2
crw-rw-rw- 1 tim audio 116, 4 2008-02-06 22:17 controlC3
crw-rw-rw-+ 1 tim audio 116, 13 2008-02-06 22:17 midiC0D0
crw-rw-rw-+ 1 tim audio 116, 18 2008-02-06 22:17 midiC1D0
crw-rw-rw- 1 tim audio 116, 3 2008-02-06 22:17 midiC3D0
crw-rw-rw-+ 1 tim audio 116, 16 2008-02-06 22:17 pcmC0D0c
crw-rw-rw-+ 1 tim audio 116, 15 2008-02-06 22:17 pcmC0D0p
crw-rw-rw-+ 1 tim audio 116, 14 2008-02-06 22:17 pcmC0D1p
crw-rw-rw-+ 1 tim audio 116, 21 2008-02-06 22:17 pcmC1D0c
crw-rw-rw-+ 1 tim audio 116, 20 2008-02-06 22:17 pcmC1D0p
crw-rw-rw-+ 1 tim audio 116, 19 2008-02-06 22:17 pcmC1D1p
crw-rw-rw-+ 1 tim audio 116, 11 2008-02-06 22:17 pcmC2D0c
crw-rw-rw-+ 1 tim audio 116, 10 2008-02-06 22:17 pcmC2D0p
crw-rw-rw-+ 1 tim audio 116, 9 2008-02-06 22:17 pcmC2D1c
crw-rw-rw-+ 1 tim audio 116, 8 2008-02-06 22:17 pcmC2D2c
crw-rw-rw-+ 1 tim audio 116, 7 2008-02-06 22:17 pcmC2D3c
crw-rw-rw-+ 1 tim audio 116, 6 2008-02-06 22:17 pcmC2D4p
crw-rw-rw-+ 1 tim audio 116, 5 2008-02-06 22:17 seq
crw-rw-rw-+ 1 tim audio 116, 2 2008-02-06 22:17 timer
[mpd2@email-addr-hidden tim]$ cat /dev/snd/pcmC0D0c
cat: /dev/snd/pcmC0D0c: Permission denied [mpd2@email-addr-hidden tim]$ exit exit
[tim@email-addr-hidden ~]$ cat /dev/snd/pcmC0D0c
cat: /dev/snd/pcmC0D0c: File descriptor in bad state

An interesting observation is that when the sound devices were owned
by root:root, when I add mpd2 user to root group, mpd2 can access the
sound devices. But when I change the sound device to be owned by
root:audio, adding the mpd2 user to audio group doesn't allow mpd2 to
access the devices! This tells me that there's more to this than the
device permissions. Any ideas?

Tim

-----Original Message-----
From: linux-audio-user-bounces@email-addr-hidden on behalf of Clemens Ladisch
Sent: Thu 2/7/2008 12:18 AM
Cc: linux-audio-user@email-addr-hidden
Subject: Re: [LAU] ALSA device not found by some users... why?

Tim Black wrote:
> User mpd2 needs access to ALSA devices bc I'm running MPD (music
> player daemon) as this user. When this daemon tries to access ALSA
> device hw:0,0, it gets an "Error opening ALSA device: hw:0,0 No such
> device" error. (But if I run the daemon as 'tim' or root there are no
> such errors.)

When the device nodes in /dev/snd/ are created dynamically (with
udev), it's possible that their permissions are set by the udev rules
and do not come from the directory.

When you log in as mpd2, what are the permissions of the files in
/dev/snd/? Do you get the expected result when doing "cat
/dev/snd/pcmC0D0c"? (The expected result is "file descriptor in bad
state".)

Regards,
Clemens
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
Received on Fri Feb 8 00:15:03 2008

This archive was generated by hypermail 2.1.8 : Fri Feb 08 2008 - 00:15:03 EET