From 0a936c4c535383ee71a01a58bb6ecab0095984c9 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Sun, 19 May 2019 12:17:25 +0200 Subject: [PATCH] ceph_volume_client: decode d_name before using it d_name is received as byte array but the code intends to use it as a string. Therefore, convert it before using. Fixes: http://tracker.ceph.com/issues/39406 Signed-off-by: Rishabh Dave (cherry picked from commit 543f3d86cce472af5c01f468e3859d7547376fcf) --- src/pybind/ceph_volume_client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pybind/ceph_volume_client.py b/src/pybind/ceph_volume_client.py index 8699858141d04..754ad61f2f67f 100644 --- a/src/pybind/ceph_volume_client.py +++ b/src/pybind/ceph_volume_client.py @@ -306,7 +306,7 @@ class CephFSVolumeClient(object): # Identify auth IDs from auth meta filenames. The auth meta files # are named as, "$" regex = "^\$(.*){0}$".format(re.escape(META_FILE_EXT)) - match = re.search(regex, d.d_name) + match = re.search(regex, d.d_name.decode(encoding='utf-8')) if match: auth_ids.append(match.group(1)) @@ -754,11 +754,12 @@ class CephFSVolumeClient(object): dir_handle = self.fs.opendir(root_path) d = self.fs.readdir(dir_handle) while d: - if d.d_name not in [".", ".."]: + d_name = d.d_name.decode(encoding='utf-8') + if d_name not in [".", ".."]: # Do not use os.path.join because it is sensitive # to string encoding, we just pass through dnames # as byte arrays - d_full = "{0}/{1}".format(root_path, d.d_name) + d_full = u"{0}/{1}".format(root_path, d_name) if d.is_dir(): rmtree(d_full) else: -- 2.39.5