summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-01-27 10:27:54 -0500
committerScott Moser <smoser@ubuntu.com>2011-01-27 10:27:54 -0500
commitfdc7a9c7bd4fe47ab1ac93971d9d40f064938462 (patch)
treeba53a7c71db64ebfef3a7a7d6338193aafe8380b
parent6ea51dcea03e72a444c2d706778832dcece69e80 (diff)
downloadvyos-cloud-init-fdc7a9c7bd4fe47ab1ac93971d9d40f064938462.tar.gz
vyos-cloud-init-fdc7a9c7bd4fe47ab1ac93971d9d40f064938462.zip
take correct action if def_log_file and syslog_fix_perms are empty
-rw-r--r--cloudinit/__init__.py9
-rw-r--r--doc/examples/cloud-config.txt18
2 files changed, 22 insertions, 5 deletions
diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py
index acedf77e..cbdf2271 100644
--- a/cloudinit/__init__.py
+++ b/cloudinit/__init__.py
@@ -482,13 +482,12 @@ def initfs():
util.ensure_dirs(dlist)
cfg = util.get_base_cfg(system_config,cfg_builtin,parsed_cfgs)
- log_file = None
- if 'def_log_file' in cfg:
- log_file = cfg['def_log_file']
+ log_file = util.get_cfg_option_str(cfg, 'def_log_file', None)
+ perms = util.get_cfg_option_str(cfg, 'syslog_fix_perms', None)
+ if log_file:
fp = open(log_file,"ab")
fp.close()
- if log_file and 'syslog_fix_perms' in cfg:
- perms = cfg['syslog_fix_perms']
+ if log_file and perms:
(u,g) = perms.split(':',1)
if u == "-1" or u == "None": u = None
if g == "-1" or g == "None": g = None
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt
index 5000d6d7..443fee2e 100644
--- a/doc/examples/cloud-config.txt
+++ b/doc/examples/cloud-config.txt
@@ -328,3 +328,21 @@ phone_home:
# timezone: set the timezone for this instance
# the value of 'timezone' must exist in /usr/share/zoneinfo
timezone: US/Eastern
+
+# def_log_file and syslog_fix_perms work together
+# if
+# - logging is set to go to a log file 'L' both with and without syslog
+# - and 'L' does not exist
+# - and syslog is configured to write to 'L'
+# then 'L' will be initially created with root:root ownership (during
+# cloud-init), and then at cloud-config time (when syslog is available)
+# the syslog daemon will be unable to write to the file.
+#
+# to remedy this situation, 'def_log_file' can be set to a filename
+# and syslog_fix_perms to a string containing "<user>:<group>"
+#
+# the default values are '/var/log/cloud-init.log' and 'syslog:adm'
+# the value of 'def_log_file' should match what is configured in logging
+# if either is empty, then no change of ownership will be done
+def_log_file: /var/log/my-logging-file.log
+syslog_fix_perms: syslog:root