From: Takashi Iwai Subject: Anyone using alsactl preinit / postinit scripts? Date: Thu, 14 Jun 2012 14:10:20 +0200 Message-ID: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 3149124460 for ; Thu, 14 Jun 2012 14:10:24 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 8BE23910A1 for ; Thu, 14 Jun 2012 14:10:21 +0200 (CEST) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org Hi, is anyone already using preinit / postinit scripts of alsactl init? I'm thinking of appliny the patch below, but before that, I'd like to make sure that *.conf is the appropriate extension. thanks, Takashi --- From: Takashi Iwai Subject: [PATCH] alsactl: Read only *.conf files when a directory is passed via INCLUDE When alsactl init is invoked and a directory path is passed to INCLUDE command in the config file, read only *.conf files in that directory. This will avoid reading backup files or invalid files that have been created accidentally. Signed-off-by: Takashi Iwai --- alsactl/init_parse.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c index 51b515c..83d12ba 100644 --- a/alsactl/init_parse.c +++ b/alsactl/init_parse.c @@ -1502,12 +1502,16 @@ static int parse_line(struct space *space, char *line, size_t linesize) if (dir) { count = strlen(string); while ((dirent = readdir(dir)) != NULL) { - if (strcmp(dirent->d_name, ".") == 0 || - strcmp(dirent->d_name, "..") == 0) + const char *name = dirent->d_name; + const char *ext; + if (*name == '.') + continue; + ext = strrchr(name, ','); + if (!ext || strcmp(ext, ".conf")) continue; string[count] = '\0'; strlcat(string, "/", sizeof(string)); - strlcat(string, dirent->d_name, sizeof(string)); + strlcat(string, name, sizeof(string)); space->go_to = NULL; space->rootdir = new_root_dir(string); if (space->rootdir) { -- 1.7.10.3