src/bin/proxmox-backup-client.rs: use file system path to reference keys
This commit is contained in:
parent
091540298e
commit
9b06db4563
|
@ -809,15 +809,8 @@ fn key_create(
|
||||||
_rpcenv: &mut dyn RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let path = tools::required_string_param(¶m, "path")?;
|
||||||
let repo: BackupRepository = repo_url.parse()?;
|
let path = PathBuf::from(path);
|
||||||
|
|
||||||
let base = BaseDirectories::with_prefix("proxmox-backup")?;
|
|
||||||
|
|
||||||
let repo = repo.to_string();
|
|
||||||
|
|
||||||
// usually $HOME/.config/proxmox-backup/xxx.enc_key
|
|
||||||
let path = base.place_config_file(&format!("{}.enc_key", repo))?;
|
|
||||||
|
|
||||||
// always read from tty
|
// always read from tty
|
||||||
if !crate::tools::tty::stdin_isatty() {
|
if !crate::tools::tty::stdin_isatty() {
|
||||||
|
@ -840,15 +833,8 @@ fn key_change_passphrase(
|
||||||
_rpcenv: &mut dyn RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let path = tools::required_string_param(¶m, "path")?;
|
||||||
let repo: BackupRepository = repo_url.parse()?;
|
let path = PathBuf::from(path);
|
||||||
|
|
||||||
let base = BaseDirectories::with_prefix("proxmox-backup")?;
|
|
||||||
|
|
||||||
let repo = repo.to_string();
|
|
||||||
|
|
||||||
// usually $HOME/.config/proxmox-backup/xxx.enc_key
|
|
||||||
let path = base.place_config_file(&format!("{}.enc_key", repo))?;
|
|
||||||
|
|
||||||
// we need a TTY to query the new password
|
// we need a TTY to query the new password
|
||||||
if !crate::tools::tty::stdin_isatty() {
|
if !crate::tools::tty::stdin_isatty() {
|
||||||
|
@ -880,19 +866,19 @@ fn key_mgmt_cli() -> CliCommandMap {
|
||||||
ApiMethod::new(
|
ApiMethod::new(
|
||||||
key_create,
|
key_create,
|
||||||
ObjectSchema::new("Create a new encryption key.")
|
ObjectSchema::new("Create a new encryption key.")
|
||||||
.required("repository", REPO_URL_SCHEMA.clone())
|
.required("path", StringSchema::new("File system path."))
|
||||||
))
|
))
|
||||||
.arg_param(vec!["repository"])
|
.arg_param(vec!["path"])
|
||||||
.completion_cb("repository", complete_repository);
|
.completion_cb("path", tools::complete_file_name);
|
||||||
|
|
||||||
let key_change_passphrase_cmd_def = CliCommand::new(
|
let key_change_passphrase_cmd_def = CliCommand::new(
|
||||||
ApiMethod::new(
|
ApiMethod::new(
|
||||||
key_change_passphrase,
|
key_change_passphrase,
|
||||||
ObjectSchema::new("Change the passphrase required to decrypt the key.")
|
ObjectSchema::new("Change the passphrase required to decrypt the key.")
|
||||||
.required("repository", REPO_URL_SCHEMA.clone())
|
.required("path", StringSchema::new("File system path."))
|
||||||
))
|
))
|
||||||
.arg_param(vec!["repository"])
|
.arg_param(vec!["path"])
|
||||||
.completion_cb("repository", complete_repository);
|
.completion_cb("path", tools::complete_file_name);
|
||||||
|
|
||||||
let cmd_def = CliCommandMap::new()
|
let cmd_def = CliCommandMap::new()
|
||||||
.insert("create".to_owned(), key_create_cmd_def.into())
|
.insert("create".to_owned(), key_create_cmd_def.into())
|
||||||
|
|
Loading…
Reference in New Issue