]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: Simplify getting decrypted fname
authorChristopher Hoffman <choffman@redhat.com>
Wed, 23 Apr 2025 16:33:46 +0000 (16:33 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Wed, 5 Nov 2025 13:59:35 +0000 (13:59 +0000)
During unwrap name, get_decrypted_fname parameters accepts
dname/b64 name and altname. If altname holds a value, this means
that a plaintext name will be built from altname. In this
case, dname/b64 name is irrelevant. In the case of empty altname,
build name from b64 name.

Fixes: https://tracker.ceph.com/issues/70995
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/Client.cc

index 04a3f4f24ccd8fb6c099609c09aaae52defb91b2..ac359181fb91cacaabf5e4ab6f933899b731c621 100644 (file)
@@ -1433,23 +1433,15 @@ std::string Client::_unwrap_name(Inode& diri, const std::string& dname, const st
 
   auto fscrypt_denc = fscrypt->get_fname_denc(diri.fscrypt_ctx, &diri.fscrypt_key_validator, true);
   if (fscrypt_denc) {
-    if (newaltn.empty()) {
-      std::string plaintext;
-      int r = fscrypt_denc->get_decrypted_fname(newdname, "", &plaintext);
-      if (r < 0) {
-        ldout(cct, 0) << __FILE__ << ":" << __LINE__ << ": failed to decrypt filename (r=" << r << ")" << dendl;
-        return "???";
-      }
-      newdname = std::move(plaintext);
-    } else {
-      /* the dname is irrelevant, the altname has what we want to present to the application */
-      std::string plaintext;
-      int r = fscrypt_denc->get_decrypted_fname(newaltn, "", &plaintext);
-      if (r < 0) {
-        ldout(cct, 0) << __FILE__ << ":" << __LINE__ << ": failed to decrypt filename (r=" << r << ")" << dendl;
-        return "???";
-      }
-      newdname = std::move(plaintext);
+    std::string plaintext;
+    int r = fscrypt_denc->get_decrypted_fname(newdname, newaltn, &plaintext);
+    if (r < 0) {
+      ldout(cct, 0) << __FILE__ << ":" << __LINE__ << ": failed to decrypt filename (r=" << r << ")" << dendl;
+      return "???";
+    }
+
+    newdname = std::move(plaintext);
+    if (!newaltn.empty()) {
       newaltn = newdname;
     }
   }