Commit Graph

77 Commits

Author SHA1 Message Date
Christoph Heiss
ec5096be3d common: options: use more sensible fallback values for network options
When no DHCP server is configured on the network and/or no DHCP lease
is received, the auto-installer falls back to Ipv4Addr::UNSPECIFIED -
which resolves to `0.0.0.0/0` - for the interface address, gateway and
DNS server. This is then written to /etc/network/interfaces and could
cause further issues after the installation.

At the same time, this also means that no interface name will be set,
which causes the low-level installer to write out an invalid
/etc/network/interfaces entry.

Reported-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Link: https://lore.proxmox.com/20250407154810.1565150-1-c.heiss@proxmox.com
2025-04-07 18:00:20 +02:00
Christoph Heiss
b9c06cb119 common: options: allow user-supplied domain for network options
Add an optional parameter to allow specifying a domain, which will take
precedence over both the DHCP-supplied domain (if any) and the hardcoded
default domain.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 17:54:19 +02:00
Christoph Heiss
a51f65e731 tui, common: move network option tests to correct crate
The `NetworkOptions` struct was moved here in

  5362c05cd ("common: copy common code from tui-installer")

and

  86c48f76f ("tui: switch to common crate")

but the tests were forgotten at the original place.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 17:17:35 +02:00
Christoph Heiss
7193d34159 tui: use default ZFS ARC maximum size from runtime enviroment
Now that the value is pre-calculated in the low-level installer and
written to `run-env.json`, use it from there instead of calculating it
separately - thus having a single source of truth.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 10:35:59 +02:00
Christoph Heiss
a1575df428 tree-wide: rust: run cargo fmt
The 2024 style guide changed some things, which causes quite some churn. Most of
boils down to the changed import order, now choosing types before function
items - which is the other way round then before.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-02-28 16:04:40 +01:00
Christoph Heiss
c305be5e91 tree-wide: rust: update to 2024 edition
Updates (and unifies) the edition across the workspace to 2024.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-02-28 16:04:40 +01:00
Daniel Kral
55f3bc5c9d auto: allow a binary executable as the first boot executable
As the initial use case for the first boot feature request [0] was for
running shell scripts, the auto installer retrieved the binary as a
`String`. Unfortunately, this tries to interpret binary data as UTF-8
and will transform 'invalid' characters to replacement characters [1].

This causes the auto-installer to create an invalid binary when fetching
from an URL, and error with a `stream did not contain valid UTF-8` error
when fetching from the ISO image.

To allow binary executables to be used as a first boot executable, this
commit changes the fetching from being read as a `String` to being read
as a `Vec<u8>` to not interfere with the content of the executable.

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=5579
[1] https://doc.rust-lang.org/src/alloc/string.rs.html#635

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
2025-02-24 16:20:45 +01:00
Christoph Heiss
2be676622e auto: add negative tests for root password option
Extends our test runner for the parse-answer tests to also run some
tests which are expected to fail, with a pre-determined error message
given in the accompanying json.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-02-24 12:02:09 +01:00
Christoph Heiss
7d72ce20b7 tui: raise minimum root password length to 8 characters
.. in accordance with current NIST recommendations [0].

It's 2024; so reasonable to expect an 8-character-password at the
minimum.

[0] https://pages.nist.gov/800-63-4/sp800-63b.html#passwordver

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-02-24 12:02:09 +01:00
Christoph Heiss
7f8d2f3d80 common: convert InstallRootPassword into an enum
It's more appropriate to use an enum for that type of data, since the
users must set exactly one of both variants. Note that while one could
theoretically have the case where struct members get set to `None`
before this patch, in practice this was already caught by the
`verify_email_and_root_password_settings` function. So the change
makes this invariant more obvious and also a bit more ergonomic to
handle.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
 [TL: describe why this change has no semantic user visible effect]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-02-24 12:01:49 +01:00
Christoph Heiss
97c12b5493 tree-wide: add workspace-level cargo package version
Means that all CLIs will now have the correct version compiled-in.

This is at least very much relevant for
`proxmox-auto-install-assistant`, which we distribute separately as a
normal binary/package.

Currently, `proxmox-auto-install-assistant --version` always reports
'0.1.0', thus users have to effectively fall back to their system
package manager (if installed via such) to identify the correct version.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-01-28 15:31:00 +01:00
Christoph Heiss
17f3ff2268 add preliminary pdm support
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-16 20:39:33 +01:00
Christoph Heiss
3da534fd65 common: setup: include path in error message if file could not be read
Makes it a bit easier to figure out what went wrong in the error case.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-12-10 18:00:24 +01:00
Christoph Heiss
dc46056376 common: setup: read locale info as shipped by the installer directly
Now that we have a pre-generated `locale-info.json` available, skip
generating one on-the-fly and just read that one.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-12-10 18:00:24 +01:00
Christoph Heiss
d6bf633a29 tree-wide: run cargo fmt
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-12-03 18:16:05 +01:00
Christoph Heiss
684bbaa2b9 tree-wide: fix rustdoc warnings
Mostly URLs, which need to be surrounded by < > to be properly
formatted.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-12-03 18:16:05 +01:00
Christoph Heiss
5241b6c45f low-level: stdio: fix: make progress text properly optional
.. such that receivers can differentiate between these two cases more
clearly.

Sometimes, the `progress` sub does not get passed a text (on purpose!),
just updating the progress ratio. This would cause log messages to be
written out which could indicate missing text and look rather weird.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-25 23:21:51 +01:00
Christoph Heiss
d564919315 auto, tui: move low-level installer message struct to common crate
.. effectively de-duplicating the struct, which currently is defined in
both the auto-installer and the tui-installer separately.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-25 23:21:51 +01:00
Daniel Kral
ffba386099 common: make btrfs disk options uppercase for consistency
As XFS and ZFS are spelled in uppercase letters in the installer UI and
BTRFS is usually written in this way too, make the BTRFS string
uppercase too for consistency wrt to the other options.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-20 19:48:31 +01:00
Daniel Kral
33d53b9712 common: allow lowercase and uppercase btrfs raid levels
Allows the BTRFS RAID levels to be either lowercase or uppercase when
deserializing them from string values, i.e. currently only the config
value of `btrfs.raid` in auto-installer answer files.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-20 19:48:31 +01:00
Daniel Kral
a9e5f37abf common: allow lowercase and uppercase zfs raid levels
Allows the ZFS RAID levels to be either lowercase or uppercase when
deserializing them from string values, i.e. currently only the config
value of `zfs.raid` in auto-installer answer files.

This partly fixes a regression, where deserializing the `zfs.raid`
property in answer files were only possible with uppercase values for
the ZFS RAID Z-levels, opposed to only lowercase as in previous
versions. This breaks the user API, as users cannot use the same answer
files as before for ZFS RAID Z-levels (the prepare-iso command fails).

Fixes: 510b0c008f ("common: simplifying filesystem type serializing & Display trait impl")
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-20 19:48:31 +01:00
Christoph Heiss
975e939615 common: fix deserialization of install config
We serialize it as an integer for perl compatibility, so we need to also
deserialize it as such .. the latter is used in proxmox-chroot.

Otherwise, an auto-installation will fail at the end, when a
post-installation webhook is configured, while trying to run the
proxmox-chroot tool.

Reported-by: Timothy Nicholson <t.nicholson@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-19 14:18:32 +01:00
Christoph Heiss
965abf2dc2 fix #5579: auto-install-assistant: enable baking in first-boot script
Adds a new parameter `--on-first-boot` to the `prepare-iso` command, to
specify a file to bake into the ISO.

To later use it with the auto-installer, the following must be set in
the answer file:

  [first-boot]
  source = "from-iso"

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-18 22:29:23 +01:00
Christoph Heiss
7698b8240a fix #5579: setup: introduce 'first_boot' low-level installer options
.. to enable the setup of the 'proxmox-first-boot' service, as well as
optionally setting the ordering.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-18 22:29:23 +01:00
Christoph Heiss
d4bedebf1c common: add function for issuing HTTP GET requests
Factors out the user-agent building into a separate function and then
re-uses that for get().

This has the side-effect that now for all requests issued by post() a
timeout of 60s is applied. Previously, this was only done when an
explicit fingerprint was given. Minute change and shouldn't effect
anything.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-14 21:16:34 +01:00
Christoph Heiss
687aa6772b tree-wide: run rustfmt, fix clippy warnings
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-14 20:52:18 +01:00
Christoph Heiss
e3ecca02d9 tree-wide: add serde derive where actually needed
Fixes building each crate on their own.

In a full build (e.g. `make deb`), everything pulls in serde with the
`derive` feature anyway and thus does not exihibit any build failures.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-12 14:51:11 +01:00
Christoph Heiss
4be9eb381f fix #5536: post-hook: add utility for sending notifications after auto-install
This utility can be called with the low-level install config after a
successful installation to send a notification via a HTTP POST request,
if the user has configured an endpoint for that in the answer file.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-11 18:20:19 +01:00
Christoph Heiss
78a6354c71 auto-installer: move SystemDMI struct to common crate
This functionality will be reused by the post-hook, which sends this
data as part of its information set.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-11 18:20:19 +01:00
Christoph Heiss
7a8d69c1e5 tree-wide: convert some more crates to use workspace dependencies
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-11 18:20:19 +01:00
Christoph Heiss
600c10aca0 fetch-answer: move http-related code to gated module in installer-common
This enable reusage of this code in other crates. Needed esp. by the
upcoming post-installation notification hook functionality.

No functional changes overall.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-11 18:20:19 +01:00
Christoph Heiss
a42a9db209 tui: expose arc size setting for zfs bootdisks for all products
For non-PVE products, simply use the ZFS defaults (aka. 50%) and leave
unset, if the user never touches that setting.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:50:48 +01:00
Christoph Heiss
80b6a2de5f fix #5250: install: config: add new btrfs_opts with compress config option
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:41:55 +01:00
Christoph Heiss
e143655b08 common: setup: serialize target_hd as string explicitly
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:35:47 +01:00
Christoph Heiss
510b0c008f common: simplify filesystem type serializing & Display trait impl
Implements the proper de-/serializer directly on the type and then
use serde_plain::derive_display_from_serialize where applicable, instead
of separate serializer functions somewhere else.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:34:39 +01:00
Christoph Heiss
a0edc9f08a common: setup: deserialize secure_boot property from runtime env
Needed for the post-hook functionality, which sends this information as
part of its information set.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:26:30 +01:00
Christoph Heiss
2ff8ccb6c2 common: split out installer setup files loading functionality
This allows re-using this piece of code in e.g. the post hook, instead
of having to open-code it there.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:26:30 +01:00
Christoph Heiss
6cabb2f1d0 tree-wide: fix some typos
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:26:11 +01:00
Christoph Heiss
6d9929b532 tui: use email regex from HTML specification for validation
That regex should be a lot more accurate in what it allows - if it's
good enough for the HTML spec, it should be for us too.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:17:07 +01:00
Christoph Heiss
3e40eefada installer-common: throw setup error if no network interfaces were found
We do that check already in the GUI, so add it for TUI (and by
extension, the auto-installer) too.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
2024-10-30 09:57:13 +01:00
Christoph Heiss
bdca138e0e {auto, tui}-installer: adapt to new root_password plain/hashed setup option
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Theodor Fumics <theodor.fumics@gmx.net>
2024-07-22 18:40:34 +02:00
Christoph Heiss
e1e3ac0520 common: move PasswordOptions type to tui crate
It's only used internally there anyway, so make it slightly less
confusing.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Theodor Fumics <theodor.fumics@gmx.net>
2024-07-22 18:40:34 +02:00
Christoph Heiss
0e1d973b3d install: config: rename option lvm_auto_rename -> existing_storage_auto_rename
As this is an internal option for the low-level installer anyway, no
real functional changes here.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Aaron Lauterer <a.lauterer@proxmox.com>
Tested-by: Aaron Lauterer <a.lauterer@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-16 17:51:41 +02:00
Christoph Heiss
f39ce7ba56 tree-wide: collect hardcoded installer runtime directory strings into constant
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-07-15 12:17:47 +02:00
Christoph Heiss
9a5b563dfe auto-installer: move ssh keys setup to low-level installer
.. thereby, also fixing a accidental shell injection.

Since run_cmd{,s}() is nowhere else used anymore, they can be removed
too.

Also mostly reverts commit

  5878dc4ae "auto-installer: handle auto-reboot info messages directly"

in the process too.

Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-04-23 17:24:24 +02:00
Wolfgang Bumiller
de977e74cd remaining clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-23 10:08:20 +02:00
Wolfgang Bumiller
810c860dba cargo clippy --fix
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-23 10:02:39 +02:00
Wolfgang Bumiller
15ba8a15ab simplify some code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-23 10:02:39 +02:00
Christoph Heiss
ec880798ba auto-installer: use new lvm_auto_rename option to avoid prompt
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-04-22 14:51:16 +02:00
Thomas Lamprecht
c3c92825ac common: add mocked variants for setup and ISO related info structs
and add necessary derives for debug and serialize so that we can use
this for the auto-installer HTTP payload that gets send to the client
to be able to determine a dynamic answer file.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00