runitme-rs: unify base64 encoding for direct-volume

Direct-volume needs to use the same base64 character set as
kata-runtime/direct-volume does.

Fixes: #8175

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
alex.lyn
2023-10-09 20:56:21 +08:00
parent 1280f85343
commit 73e81f5e39
2 changed files with 12 additions and 9 deletions

View File

@@ -480,14 +480,14 @@ impl<H> StorageHandlerManager<H> {
/// Join user provided volume path with kata direct-volume root path.
///
/// The `volume_path` is base64-encoded and then safely joined to the `prefix`
/// The `volume_path` is base64-url-encoded and then safely joined to the `prefix`
pub fn join_path(prefix: &str, volume_path: &str) -> Result<PathBuf> {
if volume_path.is_empty() {
return Err(anyhow!("volume path must not be empty"));
}
let b64_encoded_path = base64::encode(volume_path.as_bytes());
let b64_url_encoded_path = base64::encode_config(volume_path.as_bytes(), base64::URL_SAFE);
Ok(safe_path::scoped_join(prefix, b64_encoded_path)?)
Ok(safe_path::scoped_join(prefix, b64_url_encoded_path)?)
}
/// get DirectVolume mountInfo from mountinfo.json.