diff options
author | gcarq <egger.m@protonmail.com> | 2023-09-01 18:46:23 +0200 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2023-09-01 15:13:27 -0400 |
commit | 1d3b22621d332331da6e48ae653e983406f44e5f (patch) | |
tree | 5c8bd114954eaa5a03faa976db378d25bd507576 | |
parent | Update NEWS (diff) | |
download | portage-1d3b22621d332331da6e48ae653e983406f44e5f.tar.gz portage-1d3b22621d332331da6e48ae653e983406f44e5f.tar.bz2 portage-1d3b22621d332331da6e48ae653e983406f44e5f.zip |
emerge: ensure paths are UTF-8 encoded in _needs_move()
Bug: https://bugs.gentoo.org/913103
Closes: https://github.com/gentoo/portage/pull/1086
Signed-off-by: Michael Egger <egger.m@protonmail.com>
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | lib/portage/dbapi/vartree.py | 7 | ||||
-rw-r--r-- | lib/portage/util/movefile.py | 5 |
3 files changed, 10 insertions, 4 deletions
@@ -8,6 +8,8 @@ Features: Bug fixes: * Prevent gpg from removing /dev/null when unlocking signing key (bug #912808). +* emerge: ensure paths are UTF-8 encoded in _needs_move() (bug #913103). + portage-3.0.51 (2023-08-20) -------------- diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py index dac350880..7d1bba712 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -6273,12 +6273,15 @@ class dblink: if mydmode is None or not stat.S_ISREG(mydmode) or mymode != mydmode: return True + src_bytes = _unicode_encode(mysrc, encoding=_encodings["fs"], errors="strict") + dest_bytes = _unicode_encode(mydest, encoding=_encodings["fs"], errors="strict") + if "xattr" in self.settings.features: excluded_xattrs = self.settings.get("PORTAGE_XATTR_EXCLUDE", "") - if not _cmpxattr(mysrc, mydest, exclude=excluded_xattrs): + if not _cmpxattr(src_bytes, dest_bytes, exclude=excluded_xattrs): return True - return not filecmp.cmp(mysrc, mydest, shallow=False) + return not filecmp.cmp(src_bytes, dest_bytes, shallow=False) def merge( diff --git a/lib/portage/util/movefile.py b/lib/portage/util/movefile.py index e2f19ba92..75100a3ac 100644 --- a/lib/portage/util/movefile.py +++ b/lib/portage/util/movefile.py @@ -105,10 +105,11 @@ def _copyxattr(src, dest, exclude=None): ) -def _cmpxattr(src, dest, exclude=None): +def _cmpxattr(src: bytes, dest: bytes, exclude=None) -> bool: """ Compares extended attributes between |src| and |dest| and returns True - if they are equal or xattrs are not supported, False otherwise + if they are equal or xattrs are not supported, False otherwise. + Assumes all given paths are UTF-8 encoded. """ try: src_attrs = xattr.list(src) |