diff options
author | Jaroslav Kysela <perex@perex.cz> | 2012-05-09 08:45:47 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2012-05-09 08:45:47 +0200 |
commit | f7eb87ddc7787e981e6055c9e6f770fc0cd2359a (patch) | |
tree | 0db410f2e53fc5471bd33484d3cdcb5d8a663d1a | |
parent | 05d3bed5cd2fc5ee494766af735f4edd0106167d (diff) | |
download | alsa-utils-f7eb87ddc7787e981e6055c9e6f770fc0cd2359a.tar.gz |
alsactl: Do not access other cards than specified for init
When the global state does not exist, alsactl tries to
initialize all soundcards. It is not good when alsactl
is called multiple times from udev. Also, selinux can deny
access to non-existent devices.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r-- | alsactl/state.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/alsactl/state.c b/alsactl/state.c index a8b5bd3..fec000d 100644 --- a/alsactl/state.c +++ b/alsactl/state.c @@ -1646,13 +1646,23 @@ int load_state(const char *file, const char *initfile, const char *cardname, error("Cannot open %s for reading: %s", file, snd_strerror(err)); finalerr = err; - card = -1; + if (cardname) { + card = snd_card_get_index(cardname); + if (card < 0) { + error("Cannot find soundcard '%s'...", cardname); + return -ENODEV; + } + goto single; + } else { + card = -1; + } /* find each installed soundcards */ - while (1) { + while (!cardname) { if (snd_card_next(&card) < 0) break; if (card < 0) break; +single: first = 0; if (!do_init) break; |