diff options
author | NeilBrown <neilb@suse.com> | 2016-12-06 13:16:11 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2016-12-20 13:29:04 -0500 |
commit | 6f6fb2fb99cc4408bcde26828d7cea0b1389de83 (patch) | |
tree | 277cb0e926904a5d362e88fa4fcf5c8f287c65b7 /support | |
parent | be38fd8b8011c6bd6a83ec391f881507c1b047ae (diff) | |
download | nfs-utils-6f6fb2fb99cc4408bcde26828d7cea0b1389de83.tar.gz nfs-utils-6f6fb2fb99cc4408bcde26828d7cea0b1389de83.tar.xz nfs-utils-6f6fb2fb99cc4408bcde26828d7cea0b1389de83.zip |
conffile: strip "quotes" from values in conf file.
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 <neilb@suse.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support')
-rw-r--r-- | support/nfs/conffile.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index 8de580b..947bf9b 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 |