summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-22 18:17:29 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-22 18:17:29 -0700
commite18191a05b417b6f6aa9374ee288e79712320dee (patch)
tree033a7dea26ec3f57ebbcda83cc833967a47d8e81
parenta716d8a6a82231d71c80e43e4c7734513de8ba2b (diff)
downloadvyos-cloud-init-e18191a05b417b6f6aa9374ee288e79712320dee.tar.gz
vyos-cloud-init-e18191a05b417b6f6aa9374ee288e79712320dee.zip
1. Adjust for the cases of 'yes', 'no', 'true', 'false' by
leaving those unquoted 2. Add more comments as to why we are leaving single quoted strings alone.
-rw-r--r--cloudinit/distros/rhel.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py
index 2c5bcab9..87d5b7a8 100644
--- a/cloudinit/distros/rhel.py
+++ b/cloudinit/distros/rhel.py
@@ -43,7 +43,6 @@ NETWORK_FN_TPL = '/etc/sysconfig/network-scripts/ifcfg-%s'
# bash scripts...
from configobj import ConfigObj
-
# See: http://tiny.cc/oezbgw
D_QUOTE_CHARS = {
"\"": "\\\"",
@@ -217,19 +216,26 @@ class QuotingConfigObj(ConfigObj):
def _quote_posix(self, text):
if not text:
- return '""'
+ return ''
for (k, v) in D_QUOTE_CHARS.iteritems():
text = text.replace(k, v)
return '"%s"' % (text)
+ def _quote_special(self, text):
+ if text.lower() in ['yes', 'no', 'true', 'false']:
+ return text
+ else:
+ return self._quote_posix(text)
+
def _write_line(self, indent_string, entry, this_entry, comment):
# Ensure it is formatted fine for
# how these sysconfig scripts are used
val = self._decode_element(self._quote(this_entry))
+ # Single quoted strings should
+ # always work.
if not val.startswith("'"):
- # Not already quoted, double quote
- # it for safety
- val = self._quote_posix(val)
+ # Perform any special quoting
+ val = self._quote_special(val)
key = self._decode_element(self._quote(entry, multiline=False))
cmnt = self._decode_element(comment)
return '%s%s%s%s%s' % (indent_string,