[pve-devel] [PATCH installer 3/3] auto-installer: raise minimum root password length to 8 characters

Stefan Hanreich s.hanreich at proxmox.com
Mon Oct 7 11:55:19 CEST 2024


On 10/7/24 11:52, Christoph Heiss wrote:
> Thanks for the review!
> 
> On Mon, Oct 07, 2024 at 11:49:02AM GMT, Stefan Hanreich wrote:
>> On 10/7/24 11:22, Christoph Heiss wrote:
> [..]
>>> @@ -309,6 +310,10 @@ fn verify_root_password_settings(answer: &Answer) -> Result<()> {
>>>      } else if answer.global.root_password.is_none() && answer.global.root_password_hashed.is_none()
>>>      {
>>>          bail!("One of `global.root_password` or `global.root_password_hashed` must be set");
>>> +    } else if answer.global.root_password.is_some()
>>> +        && answer.global.root_password.as_ref().map(|s| s.len()) < Some(ROOT_PASSWORD_MIN_LENGTH)
>>> +    {
>>> +        bail!("`global.root_password` must be at least {ROOT_PASSWORD_MIN_LENGTH} characters long");
>>>      } else {
>>>          Ok(())
>>>      }
>>
>> maybe match is better at this point?
>>
>> Something like
>>
>> match (answer.global.root_password, answer.global.root_password_hashed) {
>>   [..]
>>   (Some(password), _) if password.len() < ROOT_PASSWORD_MIN_LENGTH,
>>   [..]
>> }
>>
> 
> I'll rework it a bit, match definitely seems like the better fit here!

I also thought about suggesting an Enum here like

enum AnswerPassword {
  Raw(...)
  Hashed(...)
}

But that's probably a bit more involved and idk how it would work with
the answer file format, so hard for me to tell if feasible with the
current state of things




More information about the pve-devel mailing list