client: use default encryption key if it is available
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
9696f5193b
commit
887018bb79
@ -754,7 +754,10 @@ async fn create_backup(
|
|||||||
verify_chunk_size(size)?;
|
verify_chunk_size(size)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let keyfile = param["keyfile"].as_str().map(PathBuf::from);
|
let keyfile = match param["keyfile"].as_str() {
|
||||||
|
Some(path) => Some(PathBuf::from(path)),
|
||||||
|
None => key::optional_default_key_path()?,
|
||||||
|
};
|
||||||
|
|
||||||
let backup_id = param["backup-id"].as_str().unwrap_or(&proxmox::tools::nodename());
|
let backup_id = param["backup-id"].as_str().unwrap_or(&proxmox::tools::nodename());
|
||||||
|
|
||||||
@ -1149,7 +1152,10 @@ async fn restore(param: Value) -> Result<Value, Error> {
|
|||||||
let target = tools::required_string_param(¶m, "target")?;
|
let target = tools::required_string_param(¶m, "target")?;
|
||||||
let target = if target == "-" { None } else { Some(target) };
|
let target = if target == "-" { None } else { Some(target) };
|
||||||
|
|
||||||
let keyfile = param["keyfile"].as_str().map(PathBuf::from);
|
let keyfile = match param["keyfile"].as_str() {
|
||||||
|
Some(path) => Some(PathBuf::from(path)),
|
||||||
|
None => key::optional_default_key_path()?,
|
||||||
|
};
|
||||||
|
|
||||||
let crypt_config = match keyfile {
|
let crypt_config = match keyfile {
|
||||||
None => None,
|
None => None,
|
||||||
@ -1293,7 +1299,10 @@ async fn upload_log(param: Value) -> Result<Value, Error> {
|
|||||||
|
|
||||||
let mut client = connect(repo.host(), repo.user())?;
|
let mut client = connect(repo.host(), repo.user())?;
|
||||||
|
|
||||||
let keyfile = param["keyfile"].as_str().map(PathBuf::from);
|
let keyfile = match param["keyfile"].as_str() {
|
||||||
|
Some(path) => Some(PathBuf::from(path)),
|
||||||
|
None => key::optional_default_key_path()?,
|
||||||
|
};
|
||||||
|
|
||||||
let crypt_config = match keyfile {
|
let crypt_config = match keyfile {
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -53,6 +53,16 @@ pub fn get_encryption_key_password() -> Result<Vec<u8>, Error> {
|
|||||||
bail!("no password input mechanism available");
|
bail!("no password input mechanism available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convenience helper to get the default key file path only if it exists.
|
||||||
|
pub fn optional_default_key_path() -> Result<Option<PathBuf>, Error> {
|
||||||
|
let path = default_encryption_key_path()?;
|
||||||
|
Ok(if path.exists() {
|
||||||
|
Some(path)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
default: "scrypt",
|
default: "scrypt",
|
||||||
)]
|
)]
|
||||||
|
Loading…
Reference in New Issue
Block a user