[PATCH container v2 1/7] namespaces: relax prototype of run_in_userns

Filip Schauer
2026-03-30T14:11:16Z

Allow passing a coderef stored in a private variable as the $code
argument. This fixes the following compile-time error:

Type of arg 1 to PVE::LXC::Namespaces::run_in_userns must be block or
sub {} (not private variable) at PVE/LXC/Create.pm line 736

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
src/PVE/LXC/Namespaces.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Namespaces.pm b/src/PVE/LXC/Namespaces.pm
index aa62659..3b86262 100644
--- a/src/PVE/LXC/Namespaces.pm
+++ b/src/PVE/LXC/Namespaces.pm
@@ -25,7 +25,7 @@ my sub set_id_map($$) {
PVE::Tools::run_command(['newuidmap', $pid, @uid_args]) if scalar(@uid_args);
}

-sub run_in_userns(&;$) {
+sub run_in_userns($;$) {
my ($code, $id_map) = @_;
socketpair(my $sp, my $sc, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
or die "socketpair: $!\n";
--
2.47.3