diff options
author | Scott Moser <smoser@ubuntu.com> | 2013-09-26 10:50:20 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2013-09-26 10:50:20 -0400 |
commit | 356f5f434d3712fbfddc09d614eedfdb6ebe63a4 (patch) | |
tree | d32b28b317794817f080e463ae7c1e08c8e885c0 /cloudinit | |
parent | b55a9606e9455056a4280b06ef3785964af6d3df (diff) | |
parent | 4063358ec2f20bcff4328fb659cecbed668a9a48 (diff) | |
download | vyos-cloud-init-356f5f434d3712fbfddc09d614eedfdb6ebe63a4.tar.gz vyos-cloud-init-356f5f434d3712fbfddc09d614eedfdb6ebe63a4.zip |
merge from trunk
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_final_message.py | 2 | ||||
-rw-r--r-- | cloudinit/config/cc_ssh_authkey_fingerprints.py | 2 | ||||
-rw-r--r-- | cloudinit/util.py | 24 |
3 files changed, 19 insertions, 9 deletions
diff --git a/cloudinit/config/cc_final_message.py b/cloudinit/config/cc_final_message.py index 6b864fda..e92cba4a 100644 --- a/cloudinit/config/cc_final_message.py +++ b/cloudinit/config/cc_final_message.py @@ -54,7 +54,7 @@ def handle(_name, cfg, cloud, log, args): 'datasource': str(cloud.datasource), } util.multi_log("%s\n" % (templater.render_string(msg_in, subs)), - console=False, stderr=True) + console=False, stderr=True, log=log) except Exception: util.logexc(log, "Failed to render final message template") diff --git a/cloudinit/config/cc_ssh_authkey_fingerprints.py b/cloudinit/config/cc_ssh_authkey_fingerprints.py index c38bcea2..be8083db 100644 --- a/cloudinit/config/cc_ssh_authkey_fingerprints.py +++ b/cloudinit/config/cc_ssh_authkey_fingerprints.py @@ -63,7 +63,7 @@ def _is_printable_key(entry): def _pprint_key_entries(user, key_fn, key_entries, hash_meth='md5', prefix='ci-info: '): if not key_entries: - message = ("%sno authorized ssh keys fingerprints found for user %s." + message = ("%sno authorized ssh keys fingerprints found for user %s.\n" % (prefix, user)) util.multi_log(message) return diff --git a/cloudinit/util.py b/cloudinit/util.py index d50d3e18..cd1cc1a4 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -161,13 +161,13 @@ class SeLinuxGuard(object): self.recursive = recursive def __enter__(self): - if self.selinux: + if self.selinux and self.selinux.is_selinux_enabled(): return True else: return False def __exit__(self, excp_type, excp_value, excp_traceback): - if self.selinux: + if self.selinux and self.selinux.is_selinux_enabled(): path = os.path.realpath(os.path.expanduser(self.path)) do_restore = False try: @@ -360,11 +360,21 @@ def multi_log(text, console=True, stderr=True, if stderr: sys.stderr.write(text) if console: - # Don't use the write_file since - # this might be 'sensitive' info (not debug worthy?) - with open('/dev/console', 'wb') as wfh: - wfh.write(text) - wfh.flush() + conpath = "/dev/console" + if os.path.exists(conpath): + with open(conpath, 'wb') as wfh: + wfh.write(text) + wfh.flush() + else: + # A container may lack /dev/console (arguably a container bug). If + # it does not exist, then write output to stdout. this will result + # in duplicate stderr and stdout messages if stderr was True. + # + # even though upstart or systemd might have set up output to go to + # /dev/console, the user may have configured elsewhere via + # cloud-config 'output'. If there is /dev/console, messages will + # still get there. + sys.stdout.write(text) if log: if text[-1] == "\n": log.log(log_level, text[:-1]) |