Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp804717ybn; Tue, 24 Sep 2019 09:45:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8f6UxPh4RXwvkGlm7KoV+p6MuzI6x4HVkmf3zVhr4nHLAyIwJnpv88dl3P0aDlGVcgVXk X-Received: by 2002:a1c:c506:: with SMTP id v6mr1068143wmf.160.1569343555257; Tue, 24 Sep 2019 09:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569343555; cv=none; d=google.com; s=arc-20160816; b=r1foOIbsvrDv9y6FZSAGElg62yUywFnoRW6QLmd8yVcIFRVjWJmIUy7VywXXpwKKb4 hoqswwBrE7CNo5vFfSKaEMmekETjMRynvQ4M1Da3bfxHCa6+Gq/DoHtFD7hhQGlfyjtn f+6mCwJpV/Vhx6aMUa0nAUNaaPsTqXmw6EEx8R578LhdRJ/bMBe3lUNfE5hP1wYA+rdR ue/3kXxxQeHJDlWjsMUqen/E7hOYH6ZjobreA+fP34fUBCss3LvjqbaCfK4IvSJz1bY+ IBSFTfgjZyytDahtrROb1F905ktX1DJ3oqKkHDv3zCkp0IBLLenzsR/OFW7qHXTUg4ET 7lyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from; bh=+BnWV/tTGbs1sr3ZX+/WVdGkgwC5OMvJbCBIMuiTAYw=; b=tMENPMfTfq6jLR+ZJ06v43yAHm18xfqd9r/LuK7SZhWGsu4JuLGGT9ixuSkYC2MkGG AiXJ1RJG9FjWZJEvSjoTUGxIyKnz177SO22j0LLs7khABX5FfgX47LyDiLi2nUOglQA5 Mp4Sb6J65CefeYgVAle+xLkYVUvHECLnClh3EIQbdjpn9ls0O4KiB6xRifWckn4kF3p/ jBa4pPjrYuDRzJzJlArZTP+XyocYUEn+5sXzlU3LF3xQ7QGYDi6RKk5RIOM3rNQyyeoY PSvDWX3WNUfZjGHfSpGHUkgmk0QCOpP8b2T83D5u6f2OOFiw8t4vhNvoXKrgkF+JkXg5 PBaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w30si1535789edd.137.2019.09.24.09.45.22; Tue, 24 Sep 2019 09:45:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406625AbfIWE1k (ORCPT + 99 others); Mon, 23 Sep 2019 00:27:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:47328 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405826AbfIWE1j (ORCPT ); Mon, 23 Sep 2019 00:27:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3B6ABAFA4; Mon, 23 Sep 2019 04:27:38 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Mon, 23 Sep 2019 14:26:58 +1000 Subject: [PATCH 2/3] conffile: allow optional include files. Cc: linux-nfs@vger.kernel.org Message-ID: <156921281807.27519.17127755754207047423.stgit@noble.brown> In-Reply-To: <156921267783.27519.2402857390317412450.stgit@noble.brown> References: <156921267783.27519.2402857390317412450.stgit@noble.brown> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If nfs.conf contains, for example include = /etc/nfs.conf.local and /etc/nfs.conf.local doesn't exist, then a warning is given. Sometimes it is useful to have an optional include file which is included if present, but for which an absence doesn't give a warning. Systemd has a convention that a hyphen at the start of an include file name marks it as optional, so add this convention to nfs-utils. So include = -/etc/nfs.conf.local will not give a warning if the file doesn't exist. Signed-off-by: NeilBrown --- support/nfs/conffile.c | 13 ++++++++++--- systemd/nfs.conf.man | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index 6ba8a35ce7c6..d55bfe10120a 100644 --- a/support/nfs/conffile.c +++ b/support/nfs/conffile.c @@ -412,11 +412,18 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char ** if (strcasecmp(line, "include")==0) { /* load and parse subordinate config files */ + _Bool optional = false; + + if (val && *val == '-') { + optional = true; + val++; + } + relpath = relative_path(filename, val); if (relpath == NULL) { - xlog_warn("config error at %s:%d: " - "error loading included config", - filename, lineno); + if (!optional) + xlog_warn("config error at %s:%d: error loading included config", + filename, lineno); return; } diff --git a/systemd/nfs.conf.man b/systemd/nfs.conf.man index d375bcc1d5a7..3f1c7261991d 100644 --- a/systemd/nfs.conf.man +++ b/systemd/nfs.conf.man @@ -65,6 +65,9 @@ section headers, then new sections will be created just as if the included file appeared in place of the .B include line. +If the file name starts with a hyphen then that is stripped off +before the file is opened, and if file doesn't exist no warning is +given. Normally a non-existent include file generates a warning. .PP Lookup of section and value names is case-insensitive.