|
|
2b0ae0 |
From de22eafc9046b8ea6fddda7440df5a05f5a40607 Mon Sep 17 00:00:00 2001
|
|
|
2b0ae0 |
From: Eduardo Otubo <otubo@redhat.com>
|
|
|
2b0ae0 |
Date: Mon, 5 Oct 2020 13:49:53 +0200
|
|
|
18322d |
Subject: limit permissions on def_log_file
|
|
|
18322d |
|
|
|
18322d |
This sets a default mode of 0600 on def_log_file, and makes this
|
|
|
18322d |
configurable via the def_log_file_mode option in cloud.cfg.
|
|
|
18322d |
|
|
|
18322d |
LP: #1541196
|
|
|
18322d |
Resolves: rhbz#1424612
|
|
|
18322d |
X-approved-upstream: true
|
|
|
2b0ae0 |
|
|
|
2b0ae0 |
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
|
|
|
18322d |
---
|
|
|
18322d |
cloudinit/settings.py | 1 +
|
|
|
18322d |
cloudinit/stages.py | 3 ++-
|
|
|
18322d |
doc/examples/cloud-config.txt | 4 ++++
|
|
|
18322d |
3 files changed, 7 insertions(+), 1 deletion(-)
|
|
|
18322d |
|
|
|
18322d |
diff --git a/cloudinit/settings.py b/cloudinit/settings.py
|
|
|
8a7340 |
index 3a04a58..439eee0 100644
|
|
|
18322d |
--- a/cloudinit/settings.py
|
|
|
18322d |
+++ b/cloudinit/settings.py
|
|
|
8a7340 |
@@ -45,6 +45,7 @@ CFG_BUILTIN = {
|
|
|
18322d |
'None',
|
|
|
18322d |
],
|
|
|
18322d |
'def_log_file': '/var/log/cloud-init.log',
|
|
|
18322d |
+ 'def_log_file_mode': 0o600,
|
|
|
18322d |
'log_cfgs': [],
|
|
|
18322d |
'mount_default_fields': [None, None, 'auto', 'defaults,nofail', '0', '2'],
|
|
|
18322d |
'ssh_deletekeys': False,
|
|
|
18322d |
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
|
|
|
2b0ae0 |
index 765f4aa..d769375 100644
|
|
|
18322d |
--- a/cloudinit/stages.py
|
|
|
18322d |
+++ b/cloudinit/stages.py
|
|
|
2b0ae0 |
@@ -147,8 +147,9 @@ class Init(object):
|
|
|
18322d |
def _initialize_filesystem(self):
|
|
|
18322d |
util.ensure_dirs(self._initial_subdirs())
|
|
|
18322d |
log_file = util.get_cfg_option_str(self.cfg, 'def_log_file')
|
|
|
18322d |
+ log_file_mode = util.get_cfg_option_int(self.cfg, 'def_log_file_mode')
|
|
|
18322d |
if log_file:
|
|
|
18322d |
- util.ensure_file(log_file)
|
|
|
18322d |
+ util.ensure_file(log_file, mode=log_file_mode)
|
|
|
18322d |
perms = self.cfg.get('syslog_fix_perms')
|
|
|
18322d |
if not perms:
|
|
|
18322d |
perms = {}
|
|
|
18322d |
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt
|
|
|
2b0ae0 |
index f3ae5e6..b5b1fdd 100644
|
|
|
18322d |
--- a/doc/examples/cloud-config.txt
|
|
|
18322d |
+++ b/doc/examples/cloud-config.txt
|
|
|
2b0ae0 |
@@ -414,10 +414,14 @@ timezone: US/Eastern
|
|
|
18322d |
# if syslog_fix_perms is a list, it will iterate through and use the
|
|
|
18322d |
# first pair that does not raise error.
|
|
|
18322d |
#
|
|
|
18322d |
+# 'def_log_file' will be created with mode 'def_log_file_mode', which
|
|
|
18322d |
+# is specified as a numeric value and defaults to 0600.
|
|
|
18322d |
+#
|
|
|
18322d |
# the default values are '/var/log/cloud-init.log' and 'syslog:adm'
|
|
|
18322d |
# the value of 'def_log_file' should match what is configured in logging
|
|
|
18322d |
# if either is empty, then no change of ownership will be done
|
|
|
18322d |
def_log_file: /var/log/my-logging-file.log
|
|
|
18322d |
+def_log_file_mode: 0600
|
|
|
18322d |
syslog_fix_perms: syslog:root
|
|
|
18322d |
|
|
|
18322d |
# you can set passwords for a user or multiple users
|
|
|
18322d |
--
|
|
|
8a7340 |
1.8.3.1
|
|
|
18322d |
|