Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP1:Update
salt.31024
bsc-1176024-fix-file-directory-user-and-group-o...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bsc-1176024-fix-file-directory-user-and-group-owners.patch of Package salt.31024
From 2ca37fe7d2a03ad86ed738f2636fe240b9f4467e Mon Sep 17 00:00:00 2001 From: Victor Zhestkov <35733135+vzhestkov@users.noreply.github.com> Date: Tue, 6 Oct 2020 12:36:41 +0300 Subject: [PATCH] bsc#1176024: Fix file/directory user and group ownership containing UTF-8 characters (#275) * Fix check_perm typos of file module * Fix UTF8 support for user/group ownership operations with file module and state * Fix UTF8 support for user/group ownership operations with file module and state Co-authored-by: Victor Zhestkov <vzhestkov@vz-thinkpad.vzhestkov.net> --- salt/modules/file.py | 20 ++++++++++---------- salt/states/file.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 69d7992f5a..4612d65511 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -245,7 +245,7 @@ def group_to_gid(group): try: if isinstance(group, int): return group - return grp.getgrnam(group).gr_gid + return grp.getgrnam(salt.utils.stringutils.to_str(group)).gr_gid except KeyError: return "" @@ -336,7 +336,7 @@ def user_to_uid(user): try: if isinstance(user, int): return user - return pwd.getpwnam(user).pw_uid + return pwd.getpwnam(salt.utils.stringutils.to_str(user)).pw_uid except KeyError: return "" @@ -5133,8 +5133,8 @@ def check_perms( salt.utils.platform.is_windows() and not user_to_uid(user) == cur["uid"] ) or ( not salt.utils.platform.is_windows() - and not user == cur["user"] - and not user == cur["uid"] + and not salt.utils.stringutils.to_str(user) == cur["user"] + and not salt.utils.stringutils.to_str(user) == cur["uid"] ): perms["cuser"] = user @@ -5143,8 +5143,8 @@ def check_perms( salt.utils.platform.is_windows() and not group_to_gid(group) == cur["gid"] ) or ( not salt.utils.platform.is_windows() - and not group == cur["group"] - and not group == cur["gid"] + and not salt.utils.stringutils.to_str(group) == cur["group"] + and not salt.utils.stringutils.to_str(group) == cur["gid"] ): perms["cgroup"] = group @@ -5188,8 +5188,8 @@ def check_perms( salt.utils.platform.is_windows() and not user_to_uid(user) == post["uid"] ) or ( not salt.utils.platform.is_windows() - and not user == post["user"] - and not user == post["uid"] + and not salt.utils.stringutils.to_str(user) == post["user"] + and not salt.utils.stringutils.to_str(user) == post["uid"] ): if __opts__["test"] is True: ret["changes"]["user"] = user @@ -5204,8 +5204,8 @@ def check_perms( salt.utils.platform.is_windows() and not group_to_gid(group) == post["gid"] ) or ( not salt.utils.platform.is_windows() - and not group == post["group"] - and not group == post["gid"] + and not salt.utils.stringutils.to_str(group) == post["group"] + and not salt.utils.stringutils.to_str(group) == post["gid"] ): if __opts__["test"] is True: ret["changes"]["group"] = group diff --git a/salt/states/file.py b/salt/states/file.py index 9f32151b8b..024e5e34ce 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -864,9 +864,17 @@ def _check_dir_meta(name, user, group, mode, follow_symlinks=False): if not stats: changes["directory"] = "new" return changes - if user is not None and user != stats["user"] and user != stats.get("uid"): + if ( + user is not None + and salt.utils.stringutils.to_str(user) != stats["user"] + and user != stats.get("uid") + ): changes["user"] = user - if group is not None and group != stats["group"] and group != stats.get("gid"): + if ( + group is not None + and salt.utils.stringutils.to_str(group) != stats["group"] + and group != stats.get("gid") + ): changes["group"] = group # Normalize the dir mode smode = salt.utils.files.normalize_mode(stats["mode"]) -- 2.39.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