When using nfsconf tool to set values, allow it to uncomment a setting it finds in the relevant section if it would otherwise have had to create a new one. Signed-off-by: Justin Mitchell <jumitche@xxxxxxxxxx> --- support/nfs/conffile.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index 3845b94..713f81b 100644 --- a/support/nfs/conffile.c +++ b/support/nfs/conffile.c @@ -1830,6 +1830,8 @@ conf_write(const char *filename, const char *section, const char *arg, /* this is the section we care about */ if (where != NULL && is_section(where->text, section, arg)) { + struct outbuffer *section_start = where; + /* is there an existing assignment */ while ((where = TAILQ_NEXT(where, link)) != NULL) { if (is_tag(where->text, tag)) { @@ -1838,6 +1840,26 @@ conf_write(const char *filename, const char *section, const char *arg, } } + /* no active assignment, but is there a commented one */ + if (!found) { + where = section_start; + while ((where = TAILQ_NEXT(where, link)) != NULL) { + if (is_comment(where->text)) { + char *cline = where->text; + while (isspace(*cline)) cline++; + + if (*cline != '#') continue; + cline++; + + if (is_tag(cline, tag)) { + found = true; + break; + } + } + } + } + + /* replace the located tag with an updated one */ if (found) { struct outbuffer *prev = TAILQ_PREV(where, tailhead, link); bool again = false; -- 1.8.3.1