Commit Graph

1052 Commits

Author SHA1 Message Date
Christoph Heiss
a054ca6760 test: add tests for UI^2 stdio protocol
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-24 18:00:17 +01:00
Thomas Lamprecht
70f4ffeff5 stdio connected UI: drop perl prototype definitions
The prototypes where completely circumvented by calling those two
methods by reference via &, and that probably happened as the send_msg
one was just wrong, it forced scalar context for the second parameter,
while that was a list (or well hash, but the difference there can be
blurry).

Anyhow, prototypes are not always of help, and can be a PITA with
side-effects too, and especially for such small modules it has not
that much use to declare them for privately-scoped methods, so just
drop them and fix the calling style.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-24 18:00:17 +01:00
Christoph Heiss
8fcdc5b266 tui, ui: switch over to JSON-based protocol
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 17:34:36 +01:00
Thomas Lamprecht
573e3f41fb fqdn comparison: make more efficient
Compare lazily to always avoid to vector collections and if one of the
first parts mismatch some lower_case calls.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-23 17:29:53 +01:00
Thomas Lamprecht
9466865843 fqdn comparison: expand test scope
Add some negative tests to ensure a `return true` (exaggerated)
refactoring won't pass the suite, and add one test where a and b is
the same, just to be sure.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-23 17:29:53 +01:00
Christoph Heiss
f6bea065f7 fix #5230: sys: net: properly escape FQDN regex
Due to interpolation, the \. sequence must be double-escaped.
Previously, this would result in a non-escaped dot, thus matching much
more liberally than it should.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
 [ TL: fix bug # reference in code comments ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-23 17:28:54 +01:00
Christoph Heiss
1a5665378b sys: net: do not allow overlong FQDNs as per RFCs and Debian spec
Debian limits labels to 63 characters each and the total length to 253
characters [0].

[0] https://manpages.debian.org/stable/manpages/hostname.7.en.html

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 16:40:04 +01:00
Christoph Heiss
93892c0188 proxinstall: avoid open-coding FQDN sanity check
.. by moving it into its own subroutine. Makes the whole thing quite a
bit neater and easier to maintain.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 16:40:04 +01:00
Christoph Heiss
5ee2afa71e common: fqdn: implement case-insensitive comparison as per RFC 952
Multiple DNS-related RFCs (notably RFC 952, RFC 1035 and RFC 4343)
reinforce that FQDN must not be case-sensitive.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 16:38:45 +01:00
Christoph Heiss
d932ec49fa common: fqdn: do not allow overlong FQDNs as per Debian spec
Debian limits labels to 63 characters each and the total length to 253
characters [0].

While at it, reference all the RFCs that apply when parsing FQDNs.

[0] https://manpages.debian.org/stable/manpages/hostname.7.en.html

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 16:38:45 +01:00
Thomas Lamprecht
c8b7a3d36e sys: wait a second after sending TERM signal before going for KILL
Graceful process termination can need a bit of time, so wait one
second between sending the (catchable) TERM signal and the
(uncatchable) KILL one.

Makes the code shorter as a side benefit.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-23 15:49:42 +01:00
Christoph Heiss
8a1a7187ae fix #4872: run env: use run_command() for country detection
This fixes a rather longstanding issue [0][1] with the country
detection, in that it might get completely stuck and thus hangs the
installation.

This is due how Perl, signals and line reading interacts.

A minimal reproducer, how the installer currently works, looks like
this:
```
    #!/usr/bin/env perl

    use strict;
    use warnings;

    open (my $fh, '-|', 'sleep', '1000') or die;

    my $prev = alarm(2);
    eval {
	local $SIG{ALRM} = sub { die "timed out!\n" };

	my $line;
	while (defined ($line = <$fh>)) {
	    print "line: $line";
	}
    };

    alarm($prev);
    close($fh);
```

One might expect that this times out after 2 seconds, as specified in
`alarm(2)`. The thruth is that `$line = <$fh>` apparently prevents the
signal to go through. This then causes the installer to hang there
indefinitely, if `traceroute` never progresses - which seems to happen
on lots of (weird) networks, as evidently can be seen in the forum [1].

Proxmox::Sys::Command::run_command() handles of these weird cases, takes
care of the nitty-gritty details and - most importantly - interacts
properly with SIGALRM, so just use that instead.

This _should_ really fix that issue, but reproducing it 1:1 as part of
the installation process is _very_ hard, basically pure luck. But
rewriting the reproducer using run_command (in the exact same way that
this patch rewrites detect_country_tracing_to()) fixes the issue there,
so it's the best we can probably do.

NB: This causes that the traceroute command is now printed to the log
(as run_command() logs that by default), which we could also hide e.g.
through another parameter if wanted.

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=4872
[1] https://forum.proxmox.com/threads/proxmox-installation-trying-to-detect-country.134301/

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 14:19:56 +01:00
Christoph Heiss
f48febfa72 sys: command: add option to not print process output to stdout
If $noprint is set, the output of the command won't be printed to stdout
of the parent process.

Fully backwards-compatible again, only takes effect if the new argument
is actually specified.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 14:19:56 +01:00
Christoph Heiss
23c5fbe67a sys: command: allow terminating the process early from log subroutine
If the logging subroutine $func returns CMD_FINISHED after processing a
line, the running subprocess is killed early.
This mechanism can be used when e.g. only a certain part of the output
of a (long-running) command is needed, avoiding the extra time it would
take the command to finish properly.

This is done in a entirely backwards-compatible way, i.e. existing
usages don't need any modification.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 14:19:56 +01:00
Christoph Heiss
7a95f3873f sys: command: handle EINTR in run_command()
Previously, the I/O loop would continue endlessly until the subprocess
exited.
This explicit handling allows run_command() to be used with e.g.
alarm().

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 14:19:56 +01:00
Christoph Heiss
152bbef439 sys: command: factor out kill() + waitpid() from run_command()
This moves the kill() + waitpid() combo into a separate subroutine,
avoiding open-coding that sequence. wait_for_process() also handles
properly unkillable process (e.g. in D-state) and avoids completely
locking up the installer in such cases. See [0].

For the latter case, a timeout exists (with a default of 5 seconds) in
which to wait for the process to exit after sending an optional
TERM/KILL signal.

Also while at it, add a few basic tests for run_command().

[0] https://lists.proxmox.com/pipermail/pve-devel/2024-February/061697.html

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 14:19:56 +01:00
Christoph Heiss
479b052450 low-level: initialize UI backend for 'dump-env' subcommand too
Some detection routines might try to log things and call some
Proxmox::Ui functions all the way down, so just initialize it with the
stdio backend to avoid errors.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 14:19:56 +01:00
Maximiliano Sandoval
d445c4c59d gui: remove trailing spaces and colons
For consistency sake, all colons and trailing spaces in labels that were
followed with an entry were removed, this matches other panels such as
the password and country/timezone panels.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-23 14:12:57 +01:00
Maximiliano Sandoval
cebd8aee27 gui: expand ip address Gtk3::Entry
This accounts for the different layout set in the previous commit
9102da7 ("gui: use basic grid in the network panel")

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-23 14:12:52 +01:00
Maximiliano Sandoval
9102da7989 gui: use basic grid in the network panel
Using boxes causes the labels to not align correctly in certain
circumstances. In the following commits we replace the use of boxes with
grids and set the margins and spacing directly on the respective grid.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-23 14:12:21 +01:00
Maximiliano Sandoval
0cc6d5ff4f gui: change margins in create_basic_grid
Previously the grids were inserted in a succession of boxes each with
its own set of margins and spacing. We define the margins now
exclusively in the grid and account for previous values.

Note that we match the top and bottom margins of the 'Target Harddisk'
panel which does not need to use a grid.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-23 14:12:21 +01:00
Maximiliano Sandoval
1fbce9ba55 gui: use basic grid in country/timezone panel
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-23 14:12:21 +01:00
Maximiliano Sandoval
55c2294948 gui: use basic grid in password panel
The extra 10px margin on the email row was added to account for the
removed line:

    $vbox->pack_start($hbox3, 0, 0, 15);

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-23 14:12:21 +01:00
Maximiliano Sandoval
bc59382d18 gui: move create_basic_grid subroutine definition up
This will be used in future commits to create grids so we need it to be defined.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-23 10:55:56 +01:00
Aaron Lauterer
1458d7a203 buildsys: handle installing multiple executables to /usr/bin
Otherwise the build will fail once we define more than one USR_BIN
file.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2024-02-06 15:27:11 +01:00
Christoph Heiss
faaaab30e6 ui: stdio: log error if display_html() is called on stdio backend
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-06 14:23:01 +01:00
Christoph Heiss
b8504bbe5c low-level: align wording of finish message
The other case uses "Installation finished [..]", thus use the same
wording here too.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-06 14:22:52 +01:00
Christoph Heiss
2716d68f77 proxinstall, common: remove "off" as zfs checksum option
See also the thread at [0] for the initial discussion/idea.

Disabling checksums is considered an "extraordinarily bad idea" [1] (for
pretty obvious reason) and nobody should really ever use it.

Thus remove the option completely; just so that users cannot simply
disable checksum "for performance reasons" without knowing about the
implications of this.

As pointed out by Thomas, it can still be set to "off" after the
installation using the `zfs` tool, if really wanted.

[0] https://lists.proxmox.com/pipermail/pve-devel/2023-December/061188.html
[1] https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Checksums.html#disabling-checksums

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-06 14:22:24 +01:00
Christoph Heiss
49d08ff904 proxinstall, common: remove deprecated fletcher2 as zfs checksum algorithm
Fletcher-2 has long been deprecated and should not be used anymore
[0][1], so we probably should not offer it anymore too. It's been
deprecated since at least over 3 years, beyond that it's hard to find
an exact date.

[0]: https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Checksums.html#checksum-algorithms
[1]: https://people.freebsd.org/~asomers/fletcher.pdf

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-06 13:06:03 +01:00
Thomas Lamprecht
52c995e2c7 bump version to 8.1.7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-23 11:11:27 +01:00
Thomas Lamprecht
6c6291d2f4 source interfaces.d snippets by default
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-23 11:11:01 +01:00
Thomas Lamprecht
819ded5e8f bump version to 8.1.6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-22 13:30:13 +01:00
Fabian Grünbichler
5a361d2af4 grub: install all efi binaries in fallback/default dir
else this fails with secureboot, where the entry point must be shim and not
grub.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-11-22 13:29:30 +01:00
Thomas Lamprecht
fd45abf8bc bump version to 8.1.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-21 14:22:35 +01:00
Fabian Grünbichler
404597fb04 ZFS: detect and handle secure boot
and switch the ESP to grub if it is enabled.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-11-21 14:20:02 +01:00
Stoiko Ivanov
445b95223e zfs: create dataset var-lib-vz for /var/lib/vz
Creating rpool/var/lib/vz and all intermediate datasets causes a
service-failure of `var.mount` upon shutdown.

creating the dataset for /var/lib/vz directly at the rpool and setting
its mountpoint property seems the most robust way to address this.

The alternative approach of setting `canmount=off` on the `var`
dataset seems a bit dangerous (users setting a zfs property and
suddenly hiding their /var contents).

The only small downside to this approach is that the setting of the
mountpoint happens quite a bit after extracting the data - but this
would probably be better addressed with a refactoring of the
lowlevel-installer code (setting the zfs-pool up under /target and
getting rid of a few special cases)

Fixes: dd19d40cea
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-11-21 14:19:54 +01:00
Stoiko Ivanov
6b01ac545b serial installer: add serial config for grub to target system
Matching if a serial will be needed for grub is based on the target
commandline - the speed is also read from there. The unit is based
on the ttyS device - although I'd assume that this might not always
match up.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-11-21 13:12:54 +01:00
Christoph Heiss
984be2a526 common: enforce even number of disks for ZFS RAID-10
An uneven number of disks otherwise causes a panic due to an
out-of-bounds array access in the loop below.

Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-21 13:11:50 +01:00
Christoph Heiss
18fa0cf8fa tui: add missing argument for low-level installer test-session
This broke running the TUI installer in debug mode, does not effect
release builds in any way.

Fixes: 4b4dfa1 ("low level: testmode: take path to disk image instead of using /dev/null")
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-21 13:11:50 +01:00
Christoph Heiss
e9e6cfea3a tui: preserve autoreboot checkbox state when switching views
Instead of reading the checkbox when continuing to the next screen, save
its toggle status to the installer state instead on change.

Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-21 13:11:50 +01:00
Christoph Heiss
4d77586296 tui: do not center EULA text
Brings it in line with the GUI installer.

Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-21 13:11:50 +01:00
Thomas Lamprecht
949f192eb7 bump version to 8.1.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 19:35:23 +01:00
Stoiko Ivanov
8f0e9ab0f9 tui: fix interface sort order
Currently, when multiple NICs are present in a system the TUI
sometimes selects the wrong interface (not the one that has the
default gateway/dhcp lease)

I assume this is due to HashMap's values yielding an iterator in
arbitrary order

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
 [ TL: avoid intermediate vector, reuse the SelectView's iter()]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 19:31:26 +01:00
Stefan Sterz
851a1e98b2 tui: bootdisk zfs config: add a maximum value to the copies option
according to `man zfsprops` the copies option can only be 1, 2, or 3.
limit the field to 3 just like we do for the GTK based UI, as setting
higher options can't work anyway.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
 [ TL: fleece in note that we already limit this in the GTK UI ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 17:40:30 +01:00
Christoph Heiss
28a55aea9a tui: install progress: use ok/cancel as button text for installer prompt
The GTK installer/UI module in the low-level installer does the same.
Messages used with this are worded for this, using yes/no instead can be
quite confusing (e.g.
Proxmox::Install::ask_existing_vg_rename_or_abort())

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-17 17:08:29 +01:00
Christoph Heiss
7295fd7db0 ui: stdio: replace newlines with whitespaces in prompt messages
The line-based protocol currently used cannot handle this properly, so
introduce this as a stop-gap measure - otherwise messages might be cut
off.

This makes it work for now, and the text is wrapped correctely for the
screen width in the TUI anyway - which is the only user of this so far.

Will be reworked properly later on.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
 [ TL: add fix-me comment ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 17:08:29 +01:00
Christoph Heiss
89c1351612 tui: fix changing between non-LVM and LVM filesystem in bootdisk chooser
Happens due to a force-unwrap() under the false assumption that the
disk for LVM configurations always exists when switching to a LVM
filesystem.
This fails spectacularly with a panic when switching from e.g. Btrfs to
ext4 in the filesystem chooser.

Fixes: eda9fa0 ("fix #4856: tui: bootdisk: use correct defaults in advanced dialog")
Reported-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-17 13:18:35 +01:00
Thomas Lamprecht
1f7d8d0970 bump version to 8.1.3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 07:40:15 +01:00
Thomas Lamprecht
0fcfff4fe6 gtk: show the unit for disk related options
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 07:36:37 +01:00
Thomas Lamprecht
0bdb7ddbf5 gtk: labeled widget grid: allow adding optional suffix label
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 07:35:42 +01:00