[lxc-devel] [lxc/master] Allow configuration file values to be quoted

stewartbrodie on Github lxc-bot at linuxcontainers.org
Tue May 10 13:09:12 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 805 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160510/6018a859/attachment.bin>
-------------- next part --------------
From bd878deec369f6fb119855f6ac738b754c978b99 Mon Sep 17 00:00:00 2001
From: Stewart Brodie <stewart at metahusky.net>
Date: Tue, 10 May 2016 13:57:00 +0100
Subject: [PATCH] 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 <stewart at metahusky.net>
---
 src/lxc/confile.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 2821871..14a76b2 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1964,6 +1964,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);


More information about the lxc-devel mailing list