From: NeilBrown <neilb@suse.de>
To: Steve Dickson <steved@redhat.com>
Cc: Justin Mitchell <jumitche@redhat.com>,
Benjamin Coddington <bcodding@redhat.com>,
linux-nfs@vger.kernel.org
Subject: [PATCH 5/7] mount: options in config file shouldn't over-ride command-line options.
Date: Wed, 16 Dec 2020 15:43:03 +1100 [thread overview]
Message-ID: <160809378308.7232.5025347167008614005.stgit@noble> (raw)
In-Reply-To: <160809318571.7232.10427700322834760606.stgit@noble>
When reading from the config file, we already ignore options that exist
on the command line, or that were already found earlier in the config
file. However this only works for exact matches of options.
e.g. if "noac" is on the command line and "ac=true" is in the config file,
then "ac" will be added, and this will be used.
Add tests for the "no" prefix, and also for "fg" vs "bg", so that if
"fg" is set on the command line, a "bg" or "background" setting in the
config file does not over-ride it.
Note that this *doesn't* handle the different protocol version
specifiers. That will come later.
Signed-off-by: NeilBrown <neilb@suse.de>
---
utils/mount/configfile.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index 8c68ff2c1323..40378ab247fc 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -204,6 +204,27 @@ conf_parse_mntopts(char *section, char *arg, struct mount_options *options)
field = mountopts_alias(node->field, &argtype);
if (po_contains(options, field) == PO_FOUND)
continue;
+ /* Some options can be inverted by a "no" prefix.
+ * Check for these.
+ * "no" prefixes are unlikely in the config file as
+ * "option=false" is preferred, but still possible.
+ */
+ if (strncmp(field, "no", 2) == 0 &&
+ po_contains(options, field+2) == PO_FOUND)
+ continue;
+ if (strlen(field) < BUFSIZ-3) {
+ strcat(strcpy(buf, "no"), field);
+ if (po_contains(options, buf) == PO_FOUND)
+ continue;
+ }
+
+ /* If fg or bg already present, ignore bg or fg */
+ if (strcmp(field, "fg") == 0 &&
+ po_contains(options, "bg") == PO_FOUND)
+ continue;
+ if (strcmp(field, "bg") == 0 &&
+ po_contains(options, "fg") == PO_FOUND)
+ continue;
buf[0] = '\0';
value = conf_get_section(section, arg, node->field);
next prev parent reply other threads:[~2020-12-16 4:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 4:43 [PATCH 0/7 nfs-utils] Assorted improvements to handling nfsmount.conf NeilBrown
2020-12-16 4:43 ` [PATCH 7/7] mount: update nfsmount.conf man page NeilBrown
2020-12-16 4:43 ` [PATCH 2/7] mount: report error if multiple version specifiers are given NeilBrown
2020-12-16 4:43 ` NeilBrown [this message]
2020-12-16 4:43 ` [PATCH 4/7] mount: convert configfile.c to use parse_opt.c NeilBrown
2020-12-16 4:43 ` [PATCH 3/7] Revert "mount.nfs: merge in vers= and nfsvers= options" NeilBrown
2020-12-16 4:43 ` [PATCH 1/7] mount: configfile: remove whitesspace from end of lines NeilBrown
2020-12-16 4:43 ` [PATCH 6/7] mount: don't add config-file protcol version options when already present NeilBrown
2020-12-17 15:11 ` [PATCH 0/7 nfs-utils] Assorted improvements to handling nfsmount.conf Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=160809378308.7232.5025347167008614005.stgit@noble \
--to=neilb@suse.de \
--cc=bcodding@redhat.com \
--cc=jumitche@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox