[pve-devel] [PATCH installer 6/7] auto-installer: add new `global.root_password_hashed` answer option
Christoph Heiss
c.heiss at proxmox.com
Fri May 24 11:08:02 CEST 2024
On Thu, May 23, 2024 at 02:19:34PM +0200, Christoph Heiss wrote:
> This allows user to specify the root password in a hashed format,
> generated using e.g. mkpasswd(1), instead of plaintext.
>
> Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
> ---
> proxmox-auto-installer/src/answer.rs | 3 ++-
> proxmox-auto-installer/src/utils.rs | 4 ++++
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/proxmox-auto-installer/src/answer.rs b/proxmox-auto-installer/src/answer.rs
> index aab7198..d691da1 100644
> --- a/proxmox-auto-installer/src/answer.rs
> +++ b/proxmox-auto-installer/src/answer.rs
> @@ -26,7 +26,8 @@ pub struct Global {
> pub keyboard: KeyboardLayout,
> pub mailto: String,
> pub timezone: String,
> - pub root_password: String,
> + pub root_password: Option<String>,
> + pub root_password_hashed: Option<String>,
> #[serde(default)]
> pub reboot_on_error: bool,
> #[serde(default)]
> diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs
> index f1425b0..2b9930d 100644
> --- a/proxmox-auto-installer/src/utils.rs
> +++ b/proxmox-auto-installer/src/utils.rs
> @@ -319,6 +319,10 @@ pub fn parse_answer(
>
> verify_locale_settings(answer, locales)?;
>
> + if answer.global.root_password.is_some() == answer.global.root_password_hashed.is_some() {
> + bail!("`root_password` and `root_password_hashed` cannot be set at the same time");
> + }
> +
> let mut config = InstallConfig {
> autoreboot: 1_usize,
> filesys: filesystem,
Seems a part of the diff went missing, probably while rebasing. There
should be also
@@ -342,7 +342,7 @@ pub fn parse_answer(
root_password: InstallRootPassword {
plain: answer.global.root_password.clone(),
- hashed: None,
+ hashed: answer.global.root_password_hashed.clone(),
},
mailto: answer.global.mailto.clone(),
root_ssh_keys: answer.global.root_ssh_keys.clone(),
I'll send a v2 soon, although I'll let it bake on the mailing list a bit
first, in case there is some (other) feedback.
> --
> 2.44.0
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
More information about the pve-devel
mailing list