SHA256
1
0
forked from pool/cloud-init

- Add cloud-init-log-file-mode.patch (bsc#1183939)

+ Change log file creation mode to 640
- Add cloud-init-no-pwd-in-log.patch (bsc#1184758)
  + Do not write the generated password to the log file
- Add cloud-init-purge-cahce-py-ver-change.patch

OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=184
This commit is contained in:
Robert Schweikert 2021-06-02 21:15:40 +00:00 committed by Git OBS Bridge
parent d6986f4135
commit b8c37f9e0f
5 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,11 @@
--- cloudinit/stages.py.orig
+++ cloudinit/stages.py
@@ -148,7 +148,7 @@ class Init(object):
util.ensure_dirs(self._initial_subdirs())
log_file = util.get_cfg_option_str(self.cfg, 'def_log_file')
if log_file:
- util.ensure_file(log_file)
+ util.ensure_file(log_file, mode=0o640)
perms = self.cfg.get('syslog_fix_perms')
if not perms:
perms = {}

View File

@ -0,0 +1,13 @@
--- cloudinit/config/cc_set_passwords.py.orig
+++ cloudinit/config/cc_set_passwords.py
@@ -213,7 +213,9 @@ def handle(_name, cfg, cloud, log, args)
if len(randlist):
blurb = ("Set the following 'random' passwords\n",
'\n'.join(randlist))
- sys.stderr.write("%s\n%s\n" % blurb)
+ util.multi_log(
+ "%s\n%s\n" % blurb, stderr=False
+ )
if expire:
expired_users = []

View File

@ -0,0 +1,35 @@
--- cloudinit/cmd/main.py.orig
+++ cloudinit/cmd/main.py
@@ -210,6 +210,24 @@ def attempt_cmdline_url(path, network=Tr
"wrote cloud-config data from %s='%s' to %s" %
(cmdline_name, url, path))
+def cache_pyver_maybe_purge_cache(init):
+ """Check if the Python version changed on us"""
+ pyver = '%d.%d' % (sys.version_info.major, sys.version_info.minor)
+ pyrefver = os.path.join(init.paths.get_cpath('data'), 'python-version')
+ if os.path.exists(pyrefver):
+ cached_pyver = open(pyrefver).read()
+ # The Python version has changed out from under us, anything that was
+ # pickled previously is likely useless due to API changes.
+ if cached_pyver != pyver:
+ LOG.debug('Python version change detected purging cache')
+ init.purge_cache(True)
+ else:
+ LOG.debug(
+ 'Could not determine Python version used to write cache, purging'
+ )
+ init.purge_cache(True)
+ util.write_file(pyrefver, pyver)
+
def main_init(name, args):
deps = [sources.DEP_FILESYSTEM, sources.DEP_NETWORK]
@@ -277,6 +295,7 @@ def main_init(name, args):
util.logexc(LOG, "Failed to initialize, likely bad things to come!")
# Stage 4
path_helper = init.paths
+ cache_pyver_maybe_purge_cache(init)
mode = sources.DSMODE_LOCAL if args.local else sources.DSMODE_NETWORK
if mode == sources.DSMODE_NETWORK:

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Jun 2 12:13:54 UTC 2021 - Robert Schweikert <rjschwei@suse.com>
- Add cloud-init-log-file-mode.patch (bsc#1183939)
+ Change log file creation mode to 640
- Add cloud-init-no-pwd-in-log.patch (bsc#1184758)
+ Do not write the generated password to the log file
- Add cloud-init-purge-cahce-py-ver-change.patch
-------------------------------------------------------------------
Wed Apr 7 17:35:46 UTC 2021 - Robert Schweikert <rjschwei@suse.com>

View File

@ -44,6 +44,12 @@ Patch61: cloud-init-sle12-compat.patch
Patch70: use_arroba_to_include_sudoers_directory-bsc_1181283.patch
# FIXME https://github.com/canonical/cloud-init/pull/831
Patch71: cloud-init-bonding-opts.patch
# FIXME https://github.com/canonical/cloud-init/pull/858
Patch72: cloud-init-log-file-mode.patch
# FIXME upstream commit b794d426b9
Patch73: cloud-init-no-pwd-in-log.patch
# FIXME https://github.com/canonical/cloud-init/pull/857
Patch74: cloud-init-purge-cache-py-ver-change.patch
BuildRequires: fdupes
BuildRequires: filesystem
# pkg-config is needed to find correct systemd unit dir
@ -147,6 +153,9 @@ Documentation and examples for cloud-init tools
%endif
%patch70 -p1
%patch71
%patch72
%patch73
%patch74
# patch in the full version to version.py
version_pys=$(find . -name version.py -type f)
[ -n "$version_pys" ] ||