From: Stewart Brodie Date: Tue, 10 May 2016 12:57:00 +0000 (+0100) Subject: Allow configuration file values to be quoted X-Git-Tag: lxc-1.0.9~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bde403107e397ba7885d56ecdde485a76ab27dd;p=thirdparty%2Flxc.git Allow configuration file values to be quoted If the value starts and ends with matching quote characters, those characters are stripped automatically. Quote characters are the single quote (') or double quote ("). The quote removal is done after the whitespace trimming. This is needed particularly in order that lxc.environment values may have trailing spaces. However, the quote removal is done for all values in the parse_line function, as it has non-const access to the value. Signed-off-by: Stewart Brodie --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index fed792d1b..31efd77dc 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -1707,6 +1707,14 @@ static int parse_line(char *buffer, void *data) value += lxc_char_left_gc(value, strlen(value)); value[lxc_char_right_gc(value, strlen(value))] = '\0'; + if (*value == '\'' || *value == '\"') { + size_t len = strlen(value); + if (len > 1 && value[len-1] == *value) { + value[len-1] = '\0'; + value++; + } + } + config = lxc_getconfig(key); if (!config) { ERROR("unknown key %s", key);