From: Christopher Hoffman Date: Wed, 23 Apr 2025 16:33:46 +0000 (+0000) Subject: client: Simplify getting decrypted fname X-Git-Tag: testing/wip-vshankar-testing-20260120.085915-debug^2~13^2~53 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=367fc7ef1fe9f0eb1fa1b238513d9541fbbb0d43;p=ceph-ci.git client: Simplify getting decrypted fname 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 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 04a3f4f24cc..ac359181fb9 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; } }