File fix-state-files-with-unicode-bsc-1074227.patch of Package salt
From c603efb2db2ea9a972dfcc8120d26b21583bbd5b Mon Sep 17 00:00:00 2001
From: Mihai Dinca <mdinca@suse.de>
Date: Thu, 1 Feb 2018 10:32:36 +0100
Subject: [PATCH] Fix state files with unicode (bsc#1074227)
---
salt/fileserver/roots.py | 2 +-
salt/modules/file.py | 4 ++--
salt/state.py | 2 ++
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/salt/fileserver/roots.py b/salt/fileserver/roots.py
index 3f203afce3..fb64d2f089 100644
--- a/salt/fileserver/roots.py
+++ b/salt/fileserver/roots.py
@@ -335,7 +335,7 @@ def _file_lists(load, form):
return path.replace('\\', '/') if os.path.sep == '\\' else path
for item in items:
- abs_path = os.path.join(parent_dir, item)
+ abs_path = os.path.join(parent_dir, item.decode('utf8'))
log.trace('roots: Processing %s', abs_path)
is_link = os.path.islink(abs_path)
log.trace(
diff --git a/salt/modules/file.py b/salt/modules/file.py
index 1dcde9bd24..144c57d634 100644
--- a/salt/modules/file.py
+++ b/salt/modules/file.py
@@ -4729,7 +4729,7 @@ def manage_file(name,
contents = os.linesep.join(
_splitlines_preserving_trailing_newline(contents))
with salt.utils.fopen(tmp, 'w') as tmp_:
- tmp_.write(str(contents))
+ tmp_.write(contents.encode('utf-8'))
# Compare contents of files to know if we need to replace
with salt.utils.fopen(tmp, 'r') as src:
@@ -4915,7 +4915,7 @@ def manage_file(name,
contents = os.linesep.join(
_splitlines_preserving_trailing_newline(contents))
with salt.utils.fopen(tmp, 'w') as tmp_:
- tmp_.write(str(contents))
+ tmp_.write(contents.encode('utf-8'))
# Copy into place
salt.utils.files.copyfile(tmp,
name,
diff --git a/salt/state.py b/salt/state.py
index 42d7e3be19..fd00b8d0a3 100644
--- a/salt/state.py
+++ b/salt/state.py
@@ -1290,6 +1290,8 @@ class State(object):
continue
if isinstance(arg, dict):
for key, val in six.iteritems(arg):
+ if isinstance(val, unicode):
+ val = val.encode('utf8')
if key == 'names':
names.update(val)
elif key == 'state':
--
2.13.6