[pve-devel] applied: [PATCH container 3/5] protected_call: remove left-over rootdir/dev mkdir

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Sep 9 21:12:21 CEST 2020


commit 797e12e8a5df246d8afc53b045e632977cdf0088 got rid of our "just
bind-mount the root /dev to the CT temporarily for some stuff" for
good a while ago (2015), but creating the /dev directory in the CT
root was kept, from what I can tell, by mistake.

This can be a problem if, whyever, the CT rootfs is not mounted, as
we then break a future mount as we create this /dev directory inside
what would be the CTs rootfs mount point. It is then not empty
anymore and a normal mount cannot happen, failing with "directory is
not empty"

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Setup.pm | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index d424aaa..fb0be37 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -134,11 +134,6 @@ sub protected_call {
     # avoid recursion:
     return $sub->() if $self->{in_chroot};
 
-    my $rootdir = $self->{rootdir};
-    if (!-d "$rootdir/dev" && !mkdir("$rootdir/dev")) {
-	die "failed to create temporary /dev directory: $!\n";
-    }
-
     pipe(my $res_in, my $res_out) or die "pipe failed: $!\n";
 
     my $child = fork();
@@ -149,6 +144,7 @@ sub protected_call {
 	# avoid recursive forks
 	$self->{in_chroot} = 1;
 	eval {
+	    my $rootdir = $self->{rootdir};
 	    chroot($rootdir) or die "failed to change root to: $rootdir: $!\n";
 	    chdir('/') or die "failed to change to root directory\n";
 	    my $res = $sub->();
-- 
2.20.1






More information about the pve-devel mailing list