[pbs-devel] [PATCH proxmox-backup 1/2] fix #3853: api: add force option to tape key change-passphrase
Dominik Csapak
d.csapak at proxmox.com
Tue Feb 8 16:26:18 CET 2022
On 2/7/22 17:14, Stefan Sterz wrote:
> On 2/7/22 16:57, Stefan Sterz wrote:
>> On 2/7/22 15:58, Thomas Lamprecht wrote:
>>> On 07.02.22 13:48, Stefan Sterz wrote:
[snip]
>>>> + // sanity checks for "password xor --force"
>>>> + if force && password.is_some() {
>>>> + bail!("password is not allowed when using force")
>>>> + }
>>>> +
>>>> + if !force && password.is_none() {
>>>> + bail!("missing parameter: password")
>>>> + }
>>> Above two if's could be written slightly shorter while IMO even improving readability
>>>
>>> match (force, password) {
>>> (true, Some(_)) => bail!("password is not allowed when using force"),
>>> (false, None) => bail!("missing parameter: password"),
>>> _ => (), // OK
>>> }
>> This does not work, because here password is moved into the match expression. The borrow checker
>> will complain about it being used later on when trying to decrypt the key configuration. You could
>> clone password here, but this solution strikes me as rather "inelegant".
did not look at the rest of the patch really, but i think thats wrong..
couldn't you simply use the reference instead? then the value
will not be moved?
match (force, &password) {
...
}
?
More information about the pbs-devel
mailing list