[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: question about sound



On Wed, Aug 17, 2022 at 08:10:37PM +0100, mick.crane wrote:
> I'm just requesting some comprehensible, simple to understand, overview of
> how the sound softwares are working.

Too many layers and possibilities to give a comprehensive listing.
Let's pick ONE.  Plain ALSA, without Pulseaudio or anything else on
top of it.

ALSA is implemented in the kernel, and the visible connection points
to it are character device files:

unicorn:~$ ls -l /dev/snd/
total 0
drwxr-xr-x  2 root root       60 Aug 16 07:35 by-id/
drwxr-xr-x  2 root root       80 Aug 16 07:35 by-path/
crw-rw----+ 1 root audio 116, 12 Aug 16 07:35 controlC0
crw-rw----+ 1 root audio 116, 14 Aug 16 07:35 controlC1
crw-rw----+ 1 root audio 116, 10 Aug 16 07:35 hwC0D0
crw-rw----+ 1 root audio 116, 11 Aug 16 07:35 hwC0D2
crw-rw----+ 1 root audio 116,  3 Aug 16 07:35 pcmC0D0c
crw-rw----+ 1 root audio 116,  2 Aug 16 07:37 pcmC0D0p
crw-rw----+ 1 root audio 116,  9 Aug 16 07:35 pcmC0D10p
crw-rw----+ 1 root audio 116,  4 Aug 16 07:35 pcmC0D2c
crw-rw----+ 1 root audio 116,  5 Aug 16 07:35 pcmC0D3p
crw-rw----+ 1 root audio 116,  6 Aug 16 07:35 pcmC0D7p
crw-rw----+ 1 root audio 116,  7 Aug 16 07:35 pcmC0D8p
crw-rw----+ 1 root audio 116,  8 Aug 16 07:35 pcmC0D9p
crw-rw----+ 1 root audio 116, 13 Aug 16 07:35 pcmC1D0c
crw-rw----+ 1 root audio 116,  1 Aug 16 07:35 seq
crw-rw----+ 1 root audio 116, 33 Aug 16 07:35 timer

As you can see, members of group 'audio' can write to these things, and
can therefore cause the computer to emit sounds, or to stop emitting them.

But that's not how it normally works in modern Debian.

Do you see the '+' signs after the permissions?  Those indicate that
there's more going on than can be shown in the standard Unix permission
bits.  In this case, there's an ACL.  We can see it with getfacl(1)
(from the 'acl' package):

unicorn:~$ getfacl /dev/snd/pcmC0D0p
getfacl: Removing leading '/' from absolute path names
# file: dev/snd/pcmC0D0p
# owner: root
# group: audio
user::rw-
user:greg:rw-
group::rw-
mask::rw-
other::---


The 'user:greg:rw-' part indicates that my login name has been added to
the Access Control List for this file.  I can do stuff with it, even
if I'm not in the 'audio' group.  (I happen to be in that group, but
that's not important here.)

So... why am I in this ACL on this file?  Because when I logged in,
something added me to a bunch of ACLs on my behalf.  It's all part of the
complex login procedure on modern Debian systems.  I can't tell you off
the top of my head which program or service does it, but something does.

When I logout, presumably this ACL entry will be removed, and I would
no longer have access to those files, if I weren't in the 'audio' group.

If another user logs in, they'll get a similar ACL entry on the audio
device files, and they'll be able to play sounds also -- until they
logout, at which time their sound-making privileges are revoked.
They don't need to be added to the 'audio' group, and in fact, they
shouldn't be.  That's reserved for special users, like the one who
installed Debian (UID 1000).  On my system, that user is 'greg'.


Reply to: