Commit Graph

1595 Commits

Author SHA1 Message Date
Thomas Lamprecht
85d46b4103 bump version to 8.3.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07 21:29:57 +02:00
Fabian Grünbichler
d9e544ff71 encrypt_pw: check return value matches expected format
since this manually constructs the input string for `crypt`, which looks
different depending on used prefix/hashing algorithm, ensure that it was
understood by crypt and that it returned a proper hashed password line.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-07 21:24:30 +02:00
Fabian Grünbichler
6cbbb1863d encrypt_pw: allow yescrypt in addition to sha256
this has been the default for Debian since Bullseye[0].

besides password setting for the PAM/PVE/PMG realms, this is also used
to hash cloud-init passwords for Linux VMs, where only a subset of
prefixes is currently allowed.

'j9T' is the default cost factor for yescrypt.

0: https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html#pam-default-password

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-07 21:24:30 +02:00
Thomas Lamprecht
81aee5bd53 procfs: also return MemAvailable when parsing meminfo
To promote using this over the rather useless, or well very different,
MemFree.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07 21:14:25 +02:00
Dietmar Maurer
219fe335b6 procfs: use MemAvailable from kernel to compute used memory
The old code was wrong and overestimated the memory used because it
did not take into account things like "SReclaimable", a part of slab
(in-kernel memory allocator) describing things like caches that can be
reclaimed, plus the memory for "Active(file)" and "Inactive(file)",
and other internal kernel things that even though small for each one,
can add up quickly.

Most of these metrics are exposed and could be included in the
calculation, but this will simply become obsolete in the future as the
kernel changes how it does things and how it calculates such available
memory, as it has done many times in the past.

To solve this problem for the long term, the MemAvailable field was
added to /proc/meminfo as of kernel 3.14. It describes "the amount of
memory available for a new workload without pushing the system into
swap". While it is only an estimate, it is as good as it gets, and
since it comes from the kernel, we can always assume that it is
correct for the currently booted kernel.

So, switch over to this metric for calculating the used memory by
subtracting MemAvailable from MemTotal.

Also adds a simple test case for the parser.

This commit is based on a patch from Dietmar [1].

[0]: https://git.kernel.org/torvalds/c/34e431b0ae398fc54ea69ff85ec700722c9da773
[1]: https://lore.proxmox.com/all/20250314093319.106385-1-dietmar@proxmox.com/

Originally-by: Dietmar Maurer <dietmar@proxmox.com>
 [TL: rewrite commit message from scratch referencing actual kernel
  source of things, add comment to code]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07 21:13:05 +02:00
Friedrich Weber
b24661939c tools: upid decode: do not allow slashes in UPIDs
The current regex allows slashes as part of the fields $dtype, $id, and
$user. If the given UPID matches the regex, the UPID is used to
construct the task log filename. Hence, slashes in the UPID allow a
limited form of path traversal and will write the task log to a
directory other than /var/log/pve/tasks/subdir/X. While slashes are not
expected to appear in these fields under normal circumstances, add a
safeguard against such conditions and disallow slashes in the three
fields. UPIDs with slashes will then fail with "unable to parse worker
upid [...]".

Patch best viewed with

        git show -p --word-diff-regex=.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
2025-04-04 15:51:22 +02:00
Thomas Lamprecht
f5b2eacd1b bump version to 8.3.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-02 20:01:27 +02:00
Fiona Ebner
9e0c66b2fd syscall: expose fallocate syscall
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-03-31 16:34:27 +02:00
Christoph Heiss
e22d191db9 debian: drop outdated postinst script
In the same spirit as [0], drop the old postinst script, since major
upgrades from 6.x to 8.x are not supported/possible, in any case.

Originally added in commit

  c5c5812e ("add postinst hook to fix /etc/aliases whitespace error")

[0] https://lore.proxmox.com/pve-devel/20250312125906.57953-1-f.ebner@proxmox.com/

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-03-27 17:39:40 +01:00
Wolfgang Bumiller
6c450ce52d systemd: cleanup variable declarations
Move `$signal_info` down to where we declare the rest of the variables
shared with the callback.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-07 09:24:33 +01:00
Maximiliano Sandoval
8e7d1b7ce5 systemd: disconnect signals
Dbus has a limit of 512 connections by default and signals should be
disconnected as soon as they are not needed anymore.

This should alleviate https://bugzilla.proxmox.com/show_bug.cgi?id=5876.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-07 09:23:09 +01:00
Dominik Csapak
0fcaeb39ec sysfs tools: add 'nvidia' -> 'mdev' workaround to pci_device_info
We added it to the lspci one in commit dc023d6 ("SysFSTools: handle
new nvidia syfsapi as mdev"), but we'll also need it when querying a
single device.

code is the same as in the lspci sub

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [TL: reference commit explicitly]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06 14:01:08 +01:00
Filip Schauer
ad169fbd08 tools: explain reason for the explicit PerlIO load
Explain the reason for the explicit `use PerlIO::scalar;` statement
introduced in c4945bf ("tools: load PerlIO explicitly to avoid odd
failures")

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2025-02-03 12:12:12 +01:00
Thomas Lamprecht
5d5b3abe6d bump version to 8.2.9
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 15:44:52 +01:00
Dominik Csapak
b0061fd1b6 tools: download file: add a verification sub as option
so that a caller can do additional verification on the downloaded or
extracted file

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-18 15:39:50 +01:00
Dominik Csapak
d8582cd045 tools: download file: refactor rename call
by reusing the tmp_download variable for the decompression case too.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-18 15:39:50 +01:00
Fiona Ebner
903d285751 test: have lock file test use run_fork() helper
There are differences for error handling in the old and new helper, in
particular when the child is signaled. But the test here does not
explicitly check for specific error conditions or messages and is
therefore still correct with the new helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-14 20:44:53 +01:00
Fiona Ebner
fb96ee89f2 tools: run fork: allow running code in parent after fork
Add an option parameter to the run_fork() run_fork_with_timeout()
functions, where an 'afterfork' subroutine that is run in the parent
process after the fork can be specified. It is made subject to the
timeout too, because the fork already started running at that point
and an error in the 'afterfork' subroutine will take priority over an
error in the child.

In preparation to add a helper to run a Perl subroutine in a user
namespace, which, in turn, will be used for running the container
backup subroutine for external providers inside a user namespace. That
allows them to see the filesystem to back-up from the containers
perspective and also improves security because of isolation.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-14 20:44:53 +01:00
Fiona Ebner
de6ffbdebf test: lock file: get rid of END block that made test always pass
The exit code of the test would be the exit code of the 'rm' system
call, no matter if the test itself failed or not. Use an eval block
instead of the END block and propagate the error correctly.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-14 20:44:53 +01:00
Thomas Lamprecht
5264089d68 bump version to 8.2.8
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-12 17:06:19 +01:00
Thomas Lamprecht
a0b18daa98 network: switch all code-refs over to modern calling style
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-12 17:06:10 +01:00
Alexandre Derumier via pve-devel
05d016df35 tap_plug: add support for bridge port isolation
This allows one to block traffic between all ports on the bridge with
isolation (so between the VMs), while still allow incoming traffic
from uplink.

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-12 17:05:20 +01:00
Thomas Lamprecht
d22ff1b644 Revert "section config: make subroutine delete_from_config private"
This reverts commit 820949f46f to fix a
regression in pve-network, which uses this method.

Reported-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-12 16:10:04 +01:00
Thomas Lamprecht
76cebe7846 bump version to 8.2.7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-11 20:29:24 +01:00
Max Carrara
819c44f7f0 pbs client: code style s/foreach/for
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 20:01:51 +01:00
Max Carrara
b79643cb45 pbs client: use spaces around list braces and parens around ternaries
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 20:01:51 +01:00
Max Carrara
bd8408bcec pbs client: pull variable out of long post-if definedness check
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 19:56:01 +01:00
Max Carrara
14926269ec pbs client: use post-if definedness checks instead of '//=' operator
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 19:55:56 +01:00
Max Carrara
5ebed9365a pbs client: use parentheses when calling most inbuilts
.. except for really common cases like `die`, `warn`, `keys`.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 19:55:47 +01:00
Max Carrara
da7799af9a pbs client: rename 'sdir' parameter of constructor to 'secret_dir'
.. so that it's less ambiguous for what the parameter stands for at a
glance.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 19:55:35 +01:00
Fiona Ebner
176d4bcb63 REST environment: warn helpers: also log messages to syslog
for better visibility. When not in a task, warnings from these helpers
are only logged to STDERR, which is particularly unhelpful in case of
daemons. This is the main motivation behind this change.

For tasks, warnings from these helpers are already more visible on the
UI side, but when looking at the syslog, one can only see the warning
count from the task right now, not the actual messages. This is
another reason in favor of the change.

Reported-by: Friedrich Weber <f.weber@proxmox.com>
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-11 19:38:10 +01:00
Daniel Kral
d0dd3f25dc net: add name checks when creating bridge and veth interfaces
Adds checks when creating interfaces with `veth_create`, which is used
when creating the veth interface for Linux firewall bridges, and
`iface_create`, which is used when creating Linux / OVS firewall bridges
and VLAN bridges.

There are no functional changes in `veth_create` except the added check.

Without these checks, the following cases:

- When creating more than 10 Linux firewall bridges on a VM with 9
  digits, e.g. 'fwbr999999999i10' is too long for an interface name
- When creating a VLAN bridge on a bridge that has already a long name,
  e.g. the bridge 'abcdefghjklm' will try to create 'abcdefghijklmv249'

will fail with a rather unhelpful error message from the kernel:

> Error: Attribute failed policy validation.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-11 19:35:29 +01:00
Daniel Kral
d67d5b26c3 fix #5454: net: check names for vlan bridge slave interfaces
Adds a check for the name of VLAN bridge slave interfaces, which are
created on non VLAN-aware bridges. These checks mimics what is done when
parsing an interface name in iproute2 [0], which includes a name size
check, an empty string check and checking for invalid characters.

Without this check, creating a VLAN bridge slave interface, where the
length of the string "<iface>.<vlanid>" will be greater than or equal to
16 characters, resulted in the following error message from `ip` itself:

> Error: argument "<iface>.<vlanid>" is wrong: "name" not a valid ifname

[0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/utils.c?h=v6.1.0#n825

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-11 19:35:29 +01:00
Aaron Lauterer
0219596da2 fix #3893: network: add vlan id and range parameter definitions
This is one step to make it possible to define the VLAN IDs and ranges
for bridges.

It is expected to be used in combination with the `-list` magic
property. Therefore it defines and checks the validity of a single list
item that could just be a single VLAN tag ID or a range.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2024-11-11 19:23:19 +01:00
Aaron Lauterer
a8b8920d54 inotify: interfaces: check if bridge_vids is truthy instead of defined
The old check for defined would also be true if it contained an empty
string. By checking its truthyness, an empty string will be falsy and
therefore the default value will be used.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2024-11-11 19:23:19 +01:00
Max Carrara
34dec45c43 section config: fix spelling of variable
s/modifyable/modifiable

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 14:41:05 +01:00
Max Carrara
820949f46f section config: make subroutine delete_from_config private
because it's just an internal helper method and isn't used anywhere
outside of the package.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 14:41:05 +01:00
Max Carrara
090497ec08 section config: update code style
Replace `foreach` with `for` and use postfix deref instead of block
(circumfix) dereference (`$foo->%*` instead of `%$foo`).

Furthermore, make `format_config_line` a private sub instead of
unnecessarily declaring it as an anonymous subroutine, which avoids
the `&$sub_ref(...)` syntax altogether.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 14:01:02 +01:00
Max Carrara
142fb2b245 section config: document package and its methods with POD
Apart from the obvious benefits that documentation has, this also
allows LSPs to provide docstrings e.g. via 'textDocument/hover' [0].

Tested with Perl Navigator [1].

[0]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_hover
[1]: https://github.com/bscan/PerlNavigator

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-11-11 14:01:02 +01:00
Thomas Lamprecht
15075a54e9 sysfs tools: avoid using POSIX for just EEXIST error code
We can just save both $! and %! and use the latter to check for
specific errors. This is not really pretty but perl does the same
internally, so...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-11 13:52:43 +01:00
Dominik Csapak
3b6ce501ad sysfstools: fix regression on binding to vfio-pci
when starting a vm with passthrough, we have to bind all normal pci
devices to vfio-pci. This happens by

* unbinding from current driver
* telling vfio-pci the 'vendorid modelid' combo so it knows this device
  class can use the driver (by writing to 'new_id')
* actually binding the device to vfio-pci

if there are multiple devices of the same 'vendorid modelid' class on
the host (and passed through), only the first write to 'new_id' is
successful, all subsequent ones return EEXIST.

This could happen e.g. for setups with multiple GPUs that have the same
audio chip.

To fix this, ignore the EEXIST error for this write to new_id, by adding
a new parameter to file_write for this.

If we need to ignore other errors in the future, we can still make this
more generic.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-11-11 13:38:45 +01:00
Dominik Csapak
e8ab2427d6 sysfstools: file_write: extend with logging
the actual error and path is useful to know when trying to debug or
figure out what did not work, so warn here if there was an error.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-11-11 13:38:42 +01:00
Fiona Ebner
bbca06d995 inotify: avoid cyclic use statement
Commit e68ebda ("fix #545: interfaces: allow arbitrary bridge names in
network config") introduced a cyclic usage between
PVE::RESTEnvironment and PVE::INotify, making code like the following
fail:

> perl -e "use PVE::RESTEnvironment qw(log_warn);"

Note, including the PVE::INotify module first would still work, i.e.:

> perl -e "use PVE::INotify; use PVE::RESTEnvironment qw(log_warn);"

The rest of the PVE::INotify module alredy uses syslog(), which could
be used here as well to get rid of the cyclic usage. Wolfgang argued
that the whole point of commit e68ebda was to remove coupling between
the name and the type of the interface. If there still is some code
about a name starting with 'vmbr' being classified wrong, that should
rather be fixed. Because of the very commit, the frontend already
doesn't show e.g. a non-bridge with name 'vmbr7' in bridge selectors.

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fixes: e68ebda ("fix #545: interfaces: allow arbitrary bridge names in network config")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-11 13:37:01 +01:00
Thomas Lamprecht
61073db2bc certificate: factor out obtaining the expiration timestamp
This can be useful to have, e.g., when requiring different behaviors
the nearer an expiry gets.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-11 09:51:59 +01:00
Tiomet Pelston
8915b9669c fix #5623: ovs other_config set to 0 not saved in network config
When configuring an OVS network device via web interface,
any OVS option set to value=0 is ignored upon saving. This happens
because value=0 is evaluated as false in $parse_ovs_option.

Signed-off-by: Tiomet Pelston <tiometpelston@gmail.com>
Reviewed-By: Aaron Lauterer <a.lauterer@proxmox.com>
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
2024-10-30 09:51:34 +01:00
Thomas Lamprecht
0b1b9f05ca bump version to 8.2.6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-24 18:37:49 +02:00
Dominik Csapak
2d658bfeca SysFSTools: lscpi: move mdev and iommugroup check outside of verbose
they should not be expensive (only reading/file checking in sysfs; the
parsed vendor/id names are not required) so we should include them
always.

We need at least the mdev part later at a point where we're not
interested in the rest of the verbose mode.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
2024-10-24 18:33:51 +02:00
Dominik Csapak
dc023d60c5 SysFSTools: handle new nvidia syfsapi as mdev
with kernel 6.8 NVIDIAs vGPU driver has a different api than the
previous 'mediated devices'. Adapt our sysfcode to also recognize this
for the 'mdev' paths and add another 'nvidia' property so we can detect
this.

Also parse the new api when they exist instead of the mediated devices.

The biggest difference to the existing mdev api for our use is that the
devices don't report all generally available devices, only the
createable ones. So if a user wants to configure a VM, the selection is
restricted by what may currently run on the GPU (depending ont the exact
settings, e.g. mixed mode gpus where different models can be mixed on a
single GPU; not the default though)

We could overcome this, when we'd parse the general info from the
'nvidia-smi' tool, though I'm currently unsure if that interface is
stable and intended to be parsed (there is no json output or similar
AFAIK)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
2024-10-24 18:33:46 +02:00
Dominik Csapak
eff59571be sysfstools: file_write: properly catch errors
since `print` is doing buffered IO, we don't always get an error there,
even if the underlying write does not work.

To properly catch that, do an unbuffered `syswrite` which circumvents
all buffers and writes directly to the file handle.

We aren't actually interested in the specific error here, but only if
the write was successful or not.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
2024-10-24 18:31:04 +02:00
Thomas Lamprecht
5b0106ebee bump version to 8.2.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-19 16:47:23 +02:00