[Home]

Summary:ASTERISK-08289: Permission denied, opening /dev/snd/controlC0, even if the user, under which asterisk runs as, has access to it.
Reporter:Romik_g (romik)Labels:
Date Opened:2006-12-06 06:44:25.000-0600Date Closed:2011-06-07 14:07:27
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_alsa
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Permission denied, opening /dev/snd/controlC0, even if the user, under which asterisk runs as, has access to it.


****** STEPS TO REPRODUCE ******

[root@shouse ~]# ls -l /dev/snd/controlC0
crw-rw---- 1 root audio 116, 0 Dec  6 13:16 /dev/snd/controlC0
[root@shouse ~]# grep audio /etc/group
audio:x:81:asterisk
[root@shouse ~]#
++++++++++++++++++++++++++++++++++++++
Run asterisk with chan_alsa.so module loaded and under group and user 'asterisk' (I used 'strace -f -e trace=open,close,read,write asterisk -diITvvvvvvvvvv -G asterisk -U asterisk' for debugging).
On other console connect to asterisk (asterisk -r) and run followin commands:
++++++++++++++++++++++++++++++++++++++
shouse*CLI> module unload chan_alsa.so
shouse*CLI> module load chan_alsa.so
[Dec  6 15:30:32]   == Parsing '/etc/asterisk/alsa.conf': [Dec  6 15:30:32] Found
[Dec  6 15:30:32] ERROR[6881]: chan_alsa.c:367 alsa_card_init: snd_pcm_open failed: No such device
[Dec  6 15:30:32] ERROR[6881]: chan_alsa.c:367 alsa_card_init: snd_pcm_open failed: No such device
[Dec  6 15:30:32] ERROR[6881]: chan_alsa.c:483 soundcard_init: Problem opening alsa I/O devices
[Dec  6 15:30:32]   == No sound card detected -- console channel will be unavailable
[Dec  6 15:30:32]   == Turn off ALSA support by adding 'noload=chan_alsa.so' in /etc/asterisk/modules.conf
[Dec  6 15:30:32]  Loaded chan_alsa.so => (ALSA Console Channel Driver)
shouse*CLI> exit
++++++++++++++++++++++++++++++++++++++
On console with strace running you can notice that asterisk tries to open dev/snd/controlC0 twice but all without success.
++++++++++++++++++++++++++++++++++++++
[pid  6881] open("/dev/snd/controlC0", O_RDONLY) = -1 EACCES (Permission denied)
[pid  6881] open("/dev/aloadC0", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  6881] write(2, "ALSA lib pcm_hw.c:1357:(_snd_pcm"..., 42ALSA lib pcm_hw.c:1357:(_snd_pcm_hw_open) ) = 42
[pid  6881] write(2, "Invalid value for card", 22Invalid value for card) = 22
[pid  6881] write(2, "\n", 1
)           = 1
[pid  6881] write(4, "[Dec  6 15:30:32] ERROR[6881] ch"..., 79) = 79
[pid  6881] write(1, "[Dec  6 15:30:32] ERROR[6881]: c"..., 63[Dec  6 15:30:32] ERROR[6881]: chan_alsa.c:367 alsa_card_init: ) = 63
[pid  6881] write(25, "[Dec  6 15:30:32] ERROR[6881]: c"..., 64) = 64
[pid  6881] write(1, "snd_pcm_open failed: No such dev"..., 36snd_pcm_open failed: No such device
) = 36
[pid  6881] write(25, "snd_pcm_open failed: No such dev"..., 37) = 37
++++++++++++++++++++++++++++++++++++++
The same error produced if /dev/snd/controlC0 has root:asterisk (owner:group).
All the same concerns /dev/snd/pcmC0D0p file.

Everything goes OK, if asterisk is owner of those files...
Comments:By: Jason Parker (jparker) 2006-12-06 14:50:00.000-0600

How are you setting permissions on the device?  udev likes to change permissions on you.  Is the user the owner of the device?  Is it in the audio group?

By: Romik_g (romik) 2006-12-06 23:26:14.000-0600

Yes, as I've showed in "Steps To Reproduce":
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[root@shouse ~]# ls -l /dev/snd/controlC0
crw-rw---- 1 root audio 116, 0 Dec 6 13:16 /dev/snd/controlC0
[root@shouse ~]# grep audio /etc/group
audio:x:81:asterisk
[root@shouse ~]# grep audio /etc/gshadow
audio:::asterisk
[root@shouse ~]#
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Asterisk service is running with "-U asterisk -G asterisk" (i.e. under user and group 'asterisk') and system user asterisk added to 'audio' group.
Permissions to the devices are set to crw-rw---- root audio.

By: Romik_g (romik) 2006-12-06 23:27:27.000-0600

Yes, udev sets permissions to:
crw-rw---- root audio
according to its rules.

By: Tilghman Lesher (tilghman) 2006-12-06 23:47:56.000-0600

What are the directory permissions on /dev/snd ?

By: Romik_g (romik) 2006-12-06 23:54:40.000-0600

[root@shouse ~]# ls -l /dev/ | grep snd
drwxr-xr-x 2 root root          180 Dec  7 08:53 snd/
[root@shouse ~]# ls -l / | grep dev
drwxr-xr-x 18 root root   13720 Dec  7 08:53 dev/
[root@shouse ~]#

By: Romik_g (romik) 2006-12-07 01:47:44.000-0600

It all goes OK, if I do
[root@shouse ~]# chmod o+rw /dev/snd/controlC0
[root@shouse ~]# chmod o+rw /dev/snd/pcmC0D0*

++++++++++++++++++++++++++++++
[root@shouse ~]# ll /dev/snd/
total 0
crw-rw-rw- 1 root audio 116,  0 Dec  7 08:53 controlC0
crw-rw-rw- 1 root audio 116, 24 Dec  7 08:53 pcmC0D0c
crw-rw-rw- 1 root audio 116, 16 Dec  7 08:53 pcmC0D0p
crw-rw---- 1 root audio 116, 25 Dec  7 08:53 pcmC0D1c
crw-rw---- 1 root audio 116, 17 Dec  7 08:53 pcmC0D1p
crw-rw---- 1 root audio 116,  1 Dec  7 08:53 seq
crw-rw---- 1 root audio 116, 33 Dec  7 08:53 timer
[root@shouse ~]#
++++++++++++++++++++++++++++++

By: Jason Parker (jparker) 2006-12-07 10:14:11.000-0600

It sounds like you added the audio group to asterisk after the asterisk user was already 'logged in" (ie; after running asterisk).  If you run asterisk -r, and do "!groups", I am fairly certain that it won't list "audio".

By: Anthony LaMantia (alamantia) 2006-12-15 20:06:14.000-0600

Romik,
have you attempted to try what Qwell recomended?

By: Joshua C. Colp (jcolp) 2006-12-18 20:17:59.000-0600

There has been no response to either Qwell or alamantia. If this is still an issue (which it sounds like Qwell probably hit it right on the money) then please reopen and we'll look at it.