From: Rishabh Dave Date: Sun, 19 May 2019 10:17:25 +0000 (+0200) Subject: ceph_volume_client: decode d_name before using it X-Git-Tag: v15.1.0~2479^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28196%2Fhead;p=ceph.git 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 --- diff --git a/src/pybind/ceph_volume_client.py b/src/pybind/ceph_volume_client.py index 8699858141d0..754ad61f2f67 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: