From patchwork Fri Dec 2 03:58:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9457767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA5146074E for ; Fri, 2 Dec 2016 03:59:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E76828518 for ; Fri, 2 Dec 2016 03:59:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 904E728522; Fri, 2 Dec 2016 03:59:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EF6528489 for ; Fri, 2 Dec 2016 03:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752930AbcLBD7t (ORCPT ); Thu, 1 Dec 2016 22:59:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:36530 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752480AbcLBD7s (ORCPT ); Thu, 1 Dec 2016 22:59:48 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 675BEAAA3; Fri, 2 Dec 2016 03:59:47 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Steve Dickson Date: Fri, 02 Dec 2016 14:58:29 +1100 Subject: [PATCH 10/15] conffile: strip "quotes" from values in conf file. Cc: linux-nfs@vger.kernel.org Message-ID: <148065110966.28046.11665582674746389410.stgit@noble> In-Reply-To: <148065078775.28046.5506130555300891075.stgit@noble> References: <148065078775.28046.5506130555300891075.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When "include = " is used to read and "environment" file such as /etc/sysconfig/nfs, there might be quotes around values. Stripe those off, just like a 'shell' reading the file would. Signed-off-by: NeilBrown --- support/nfs/conffile.c | 25 ++++++++++++++++--------- systemd/nfs.conf.man | 2 ++ 2 files changed, 18 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index 8de580bd6970..947bf9bad1e7 100644 --- a/support/nfs/conffile.c +++ b/support/nfs/conffile.c @@ -212,7 +212,7 @@ static void conf_parse_line(int trans, char *line, size_t sz) { char *val, *ptr; - size_t i, valsize; + size_t i; size_t j; static char *section = 0; static char *arg = 0; @@ -299,16 +299,23 @@ conf_parse_line(int trans, char *line, size_t sz) } line[strcspn (line, " \t=")] = '\0'; val = line + i + 1 + strspn (line + i + 1, " \t"); - valsize = 0; - while (val[valsize++]); - /* Skip trailing spaces and comments */ - for (j = 0; j < valsize; j++) { - if (val[j] == '#' || val[j] == ';' || isspace(val[j])) { - val[j] = '\0'; - break; + if (line[0] == '"') { + line ++; + j = strcspn(line, "\""); + line[j] = 0; + } else if (line[0] == '\'') { + line ++; + j = strcspn(line, "'"); + line[j] = 0; + } else + /* Skip trailing spaces and comments */ + for (j = 0; val[j]; j++) { + if (val[j] == '#' || val[j] == ';' || isspace(val[j])) { + val[j] = '\0'; + break; + } } - } if (strcasecmp(line, "include") == 0) conf_load(trans, val); else diff --git a/systemd/nfs.conf.man b/systemd/nfs.conf.man index 13459ea85744..8e2f034d0b9b 100644 --- a/systemd/nfs.conf.man +++ b/systemd/nfs.conf.man @@ -35,6 +35,8 @@ in the current section to .BR 4 . Leading and trailing spaces and tab are ignored, as are spaces and tabs surrounding the equals sign. +Single and double quotes surrounding the assigned value are also +removed. .PP Any line starting with .RB \*(lq # \*(rq