]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_volume_client: decode d_name before using it 28609/head
authorRishabh Dave <ridave@redhat.com>
Sun, 19 May 2019 10:17:25 +0000 (12:17 +0200)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 17 Jun 2019 20:03:21 +0000 (13:03 -0700)
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 <ridave@redhat.com>
(cherry picked from commit 543f3d86cce472af5c01f468e3859d7547376fcf)

src/pybind/ceph_volume_client.py

index 8699858141d04a022603a96f3b464d8d731e649f..754ad61f2f67fb2a5ed738dbba2cee75e0265aaa 100644 (file)
@@ -306,7 +306,7 @@ class CephFSVolumeClient(object):
             # Identify auth IDs from auth meta filenames. The auth meta files
             # are named as, "$<auth_id><meta filename extension>"
             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: