|
|
9dab26 |
From f15946568fe731dc9bf477f3f06c9c4e0f74f7c1 Mon Sep 17 00:00:00 2001
|
|
|
222d62 |
From: Lars Kellogg-Stedman <lars@redhat.com>
|
|
|
222d62 |
Date: Fri, 7 Apr 2017 18:50:54 -0400
|
|
|
222d62 |
Subject: limit permissions on def_log_file
|
|
|
222d62 |
|
|
|
222d62 |
This sets a default mode of 0600 on def_log_file, and makes this
|
|
|
222d62 |
configurable via the def_log_file_mode option in cloud.cfg.
|
|
|
222d62 |
|
|
|
222d62 |
LP: #1541196
|
|
|
222d62 |
Resolves: rhbz#1424612
|
|
|
222d62 |
X-approved-upstream: true
|
|
|
222d62 |
---
|
|
|
222d62 |
cloudinit/settings.py | 1 +
|
|
|
222d62 |
cloudinit/stages.py | 3 ++-
|
|
|
222d62 |
doc/examples/cloud-config.txt | 4 ++++
|
|
|
222d62 |
3 files changed, 7 insertions(+), 1 deletion(-)
|
|
|
222d62 |
|
|
|
222d62 |
diff --git a/cloudinit/settings.py b/cloudinit/settings.py
|
|
|
9dab26 |
index 3a04a58..439eee0 100644
|
|
|
222d62 |
--- a/cloudinit/settings.py
|
|
|
222d62 |
+++ b/cloudinit/settings.py
|
|
|
9dab26 |
@@ -45,6 +45,7 @@ CFG_BUILTIN = {
|
|
|
222d62 |
'None',
|
|
|
222d62 |
],
|
|
|
222d62 |
'def_log_file': '/var/log/cloud-init.log',
|
|
|
222d62 |
+ 'def_log_file_mode': 0o600,
|
|
|
222d62 |
'log_cfgs': [],
|
|
|
222d62 |
'mount_default_fields': [None, None, 'auto', 'defaults,nofail', '0', '2'],
|
|
|
222d62 |
'ssh_deletekeys': False,
|
|
|
222d62 |
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
|
|
|
9dab26 |
index 71f3a49..68b83af 100644
|
|
|
222d62 |
--- a/cloudinit/stages.py
|
|
|
222d62 |
+++ b/cloudinit/stages.py
|
|
|
9dab26 |
@@ -149,8 +149,9 @@ class Init(object):
|
|
|
222d62 |
def _initialize_filesystem(self):
|
|
|
222d62 |
util.ensure_dirs(self._initial_subdirs())
|
|
|
222d62 |
log_file = util.get_cfg_option_str(self.cfg, 'def_log_file')
|
|
|
222d62 |
+ log_file_mode = util.get_cfg_option_int(self.cfg, 'def_log_file_mode')
|
|
|
222d62 |
if log_file:
|
|
|
222d62 |
- util.ensure_file(log_file)
|
|
|
222d62 |
+ util.ensure_file(log_file, mode=log_file_mode)
|
|
|
222d62 |
perms = self.cfg.get('syslog_fix_perms')
|
|
|
222d62 |
if not perms:
|
|
|
222d62 |
perms = {}
|
|
|
222d62 |
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt
|
|
|
9dab26 |
index eb84dcf..0e82b83 100644
|
|
|
222d62 |
--- a/doc/examples/cloud-config.txt
|
|
|
222d62 |
+++ b/doc/examples/cloud-config.txt
|
|
|
0a07cd |
@@ -413,10 +413,14 @@ timezone: US/Eastern
|
|
|
222d62 |
# if syslog_fix_perms is a list, it will iterate through and use the
|
|
|
222d62 |
# first pair that does not raise error.
|
|
|
222d62 |
#
|
|
|
222d62 |
+# 'def_log_file' will be created with mode 'def_log_file_mode', which
|
|
|
222d62 |
+# is specified as a numeric value and defaults to 0600.
|
|
|
222d62 |
+#
|
|
|
222d62 |
# the default values are '/var/log/cloud-init.log' and 'syslog:adm'
|
|
|
222d62 |
# the value of 'def_log_file' should match what is configured in logging
|
|
|
222d62 |
# if either is empty, then no change of ownership will be done
|
|
|
222d62 |
def_log_file: /var/log/my-logging-file.log
|
|
|
222d62 |
+def_log_file_mode: 0600
|
|
|
222d62 |
syslog_fix_perms: syslog:root
|
|
|
222d62 |
|
|
|
222d62 |
# you can set passwords for a user or multiple users
|
|
|
222d62 |
--
|
|
|
9dab26 |
1.8.3.1
|
|
|
222d62 |
|