Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
systemsmanagement:Uyuni:Master:Debian11-Uyuni-Client-Tools
venv-salt-minion
fix-salt.utils.stringutils.to_str-calls-to-make...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-salt.utils.stringutils.to_str-calls-to-make-it-w.patch of Package venv-salt-minion
From 435d9fbee299b06e1c58cdc0574b6a1975841879 Mon Sep 17 00:00:00 2001 From: Victor Zhestkov <vzhestkov@suse.com> Date: Wed, 25 Nov 2020 15:09:41 +0300 Subject: [PATCH] Fix salt.utils.stringutils.to_str calls to make it working with numeric uid/gid --- salt/modules/file.py | 16 ++++++++++------ salt/states/file.py | 11 +++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index b830b390d3..b9744393d7 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -4970,6 +4970,12 @@ def check_perms( is_dir = os.path.isdir(name) is_link = os.path.islink(name) + def __safe_to_str(s): + try: + return salt.utils.stringutils.to_str(s) + except: + return salt.utils.stringutils.to_str(str(s)) + # user/group changes if needed, then check if it worked if user: if isinstance(user, int): @@ -4979,7 +4985,7 @@ def check_perms( and user_to_uid(user) != user_to_uid(perms["luser"]) ) or ( not salt.utils.platform.is_windows() - and salt.utils.stringutils.to_str(user) != perms["luser"] + and __safe_to_str(user) != perms["luser"] ): perms["cuser"] = user @@ -4991,7 +4997,7 @@ def check_perms( and group_to_gid(group) != group_to_gid(perms["lgroup"]) ) or ( not salt.utils.platform.is_windows() - and salt.utils.stringutils.to_str(group) != perms["lgroup"] + and __safe_to_str(group) != perms["lgroup"] ): perms["cgroup"] = group @@ -5023,8 +5029,7 @@ def check_perms( and user != "" ) or ( not salt.utils.platform.is_windows() - and salt.utils.stringutils.to_str(user) - != get_user(name, follow_symlinks=follow_symlinks) + and __safe_to_str(user) != get_user(name, follow_symlinks=follow_symlinks) and user != "" ): if __opts__["test"] is True: @@ -5045,8 +5050,7 @@ def check_perms( and group != "" ) or ( not salt.utils.platform.is_windows() - and salt.utils.stringutils.to_str(group) - != get_group(name, follow_symlinks=follow_symlinks) + and __safe_to_str(group) != get_group(name, follow_symlinks=follow_symlinks) and group != "" ): if __opts__["test"] is True: diff --git a/salt/states/file.py b/salt/states/file.py index 89c70eb454..fd8ffde757 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -989,15 +989,22 @@ def _check_dir_meta(name, user, group, mode, follow_symlinks=False): if not stats: changes["directory"] = "new" return changes + + def __safe_to_str(s): + try: + return salt.utils.stringutils.to_str(s) + except: + return salt.utils.stringutils.to_str(str(s)) + if ( user is not None - and salt.utils.stringutils.to_str(user) != stats["user"] + and __safe_to_str(user) != stats["user"] and user != stats.get("uid") ): changes["user"] = user if ( group is not None - and salt.utils.stringutils.to_str(group) != stats["group"] + and __safe_to_str(group) != stats["group"] and group != stats.get("gid") ): changes["group"] = group -- 2.29.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor