]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: print readable encrypted names
authorPatrick Donnelly <pdonnell@ibm.com>
Tue, 11 Mar 2025 14:26:23 +0000 (10:26 -0400)
committerChristopher Hoffman <choffman@redhat.com>
Wed, 5 Nov 2025 13:59:35 +0000 (13:59 +0000)
Replace non-printable characters with '.'.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/client/Client.cc
src/include/filepath.h

index d8cb7e1cf3242fcf2d9c099bf0d01186b37b74e4..94082318552caa4468adbc3a931905ab1ae23bce 100644 (file)
@@ -1316,7 +1316,7 @@ Dentry *Client::insert_dentry_inode(Dir *dir, const string& dname, LeaseStat *dl
 
 bool Client::_wrap_name(Inode& diri, std::string& dname, std::string& alternate_name)
 {
-  ldout(cct, 20) << __func__ << ": (" << dname << " len=" << dname.size() << ", " << alternate_name << ") on " << diri << dendl;
+  ldout(cct, 20) << __func__ << ": (" << binstrprint(dname) << " len=" << dname.size() << ", " << binstrprint(alternate_name) << ") on " << diri << dendl;
   ceph_assert(dname.size() > 0);
   alternate_name = "";
 
@@ -1338,7 +1338,7 @@ bool Client::_wrap_name(Inode& diri, std::string& dname, std::string& alternate_
         /* confirm valid utf-8 name */
         encoded = boost::locale::conv::to_utf<char>(dname, "UTF-8", boost::locale::conv::stop);
       } catch (const boost::locale::conv::conversion_error& e) {
-        ldout(cct, 2) << "`" << dname << "' is not valid utf-8: " << e.what() << dendl;
+        ldout(cct, 2) << "`" << binstrprint(dname) << "' is not valid utf-8: " << e.what() << dendl;
         return false;
       }
     } else if (!encoding.empty()) {
@@ -1377,7 +1377,7 @@ bool Client::_wrap_name(Inode& diri, std::string& dname, std::string& alternate_
     std::string folded;
     if (is_insensitive) {
       if (normalized.empty()) {
-        ldout(cct, 2) << __func__ << " normalization is required before case folding: " << dname << dendl;
+        ldout(cct, 2) << __func__ << " normalization is required before case folding: " << binstrprint(dname) << dendl;
         return false;
       }
       try {
@@ -1427,7 +1427,7 @@ bool Client::_wrap_name(Inode& diri, std::string& dname, std::string& alternate_
 
 std::string Client::_unwrap_name(Inode& diri, const std::string& dname, const std::string& alternate_name)
 {
-  ldout(cct, 20) << __func__ << ": (" << dname << ", " << alternate_name << ") on " << diri << dendl;
+  ldout(cct, 20) << __func__ << ": (" << binstrprint(dname) << ", " << binstrprint(alternate_name) << ") on " << diri << dendl;
   std::string newdname = dname;
   std::string newaltn = alternate_name;
 
@@ -1462,7 +1462,7 @@ std::string Client::_unwrap_name(Inode& diri, const std::string& dname, const st
     /* no reverse of normalization / encoding */
 
     if (is_insensitive) {
-      ldout(cct, 25) << __func__ << ":  = " << alternate_name << dendl;
+      ldout(cct, 25) << __func__ << ":  = " << binstrprint(alternate_name) << dendl;
       newdname = newaltn;
     }
   }
@@ -7858,7 +7858,7 @@ int Client::path_walk(InodeRef dirinode, const filepath& origpath,
     std::string trimmed_path = path.get_trimmed_path();
   }
 
-  ldout(cct, 10) << __func__ << ": cur=" << *diri << " path=" << trimmed_path << dendl;
+  ldout(cct, 10) << __func__ << ": cur=" << *diri << " path=" << binstrprint(trimmed_path) << dendl;
 
   if (path.depth() == 0) {
     /* diri/dname can also be used as a filepath; or target */
@@ -7871,8 +7871,8 @@ int Client::path_walk(InodeRef dirinode, const filepath& origpath,
   while (i < path.depth() && diri) {
     int caps = 0;
     dname = path[i];
-    ldout(cct, 10) << " " << i << " " << *diri << " " << dname << dendl;
-    ldout(cct, 20) << "  (path is " << trimmed_path << ")" << dendl;
+    ldout(cct, 10) << " " << i << " " << *diri << " " << binstrprint(dname) << dendl;
+    ldout(cct, 20) << "  (path is " << binstrprint(trimmed_path) << ")" << dendl;
     InodeRef next;
     if (!diri.get()->is_dir()) {
       ldout(cct, 20) << diri.get() << " is not a dir inode, name " << dname.c_str() << dendl;
@@ -7941,6 +7941,7 @@ int Client::path_walk(InodeRef dirinode, const filepath& origpath,
           ret = -EPERM;
           goto out;
         }
+        ldout(cct, 25) << "decrypted symlink is: " << binstrprint(symlink) << dendl;
       } else {
         symlink = next->symlink;
       }
@@ -16025,6 +16026,7 @@ int Client::_symlink(Inode *dir, const char *name, const char *target,
       delete req;
       return r;
     }
+    ldout(cct, 25) << "encrypted symlink is: " << binstrprint(enc_target) << dendl;
     req->set_string2(enc_target.c_str());
   } else {
     req->set_string2(target);
index 232361d1217a84c634758f29ed33115c5aa5d24d..83cd15384ba3073c5315ee13eb52a48301f43726 100644 (file)
@@ -165,6 +165,7 @@ class filepath {
     // walk into snapdir?
     return depth() > 0 && bits[0].length() == 0;
   }
+
 };
 
 WRITE_CLASS_ENCODER(filepath)