]> git.proxmox.com Git - pve-container.git/commitdiff
Setup: fix bad /dev bindmount
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 2 Nov 2015 10:17:24 +0000 (11:17 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 2 Nov 2015 10:25:59 +0000 (11:25 +0100)
Hotplug changes will create a Setup instance with a rootdir
of /proc/$pid/root. Bindmounts on directories inside there
are broken.

Also the exitstatus of Setup::protected_call used the wrong
process' $?.

debian/changelog
src/PVE/LXC/Setup.pm

index 1158080256da4fe6a9406b5b0e5550066d31b540..1c686d9ac79f9ecb4721724af1cb9730f6c81caa 100644 (file)
@@ -2,6 +2,8 @@ pve-container (1.0-20) unstable; urgency=medium
 
   * fix bug #799: resize running CT with no loopdev.
 
+  * Setup: fix bad /dev bindmount
+
  -- Proxmox Support Team <support@proxmox.com>  Mon, 02 Nov 2015 11:16:25 +0100
 
 pve-container (1.0-19) unstable; urgency=medium
index abf696df7d595595c1b513ffe70cdd0bf879c9df..5ebda976d020c522df1a6c49f5b6557d29d1784d 100644 (file)
@@ -71,12 +71,15 @@ sub protected_call {
     my $child = fork();
     die "fork failed: $!\n" if !defined($child);
 
+    # can't bind to /proc/$pid/root/dev, it'll bind to the host's /dev
+    my $mountdev = ($rootdir !~ m@^/proc@);
+
     if (!$child) {
        # avoid recursive forks
        $self->{in_chroot} = 1;
        $self->{plugin}->{in_chroot} = 1;
        eval {
-           PVE::Tools::run_command(['mount', '--bind', '/dev', "$rootdir/dev"]);
+           PVE::Tools::run_command(['mount', '--bind', '/dev', "$rootdir/dev"]) if $mountdev;
            chroot($rootdir) or die "failed to change root to: $rootdir: $!\n";
            chdir('/') or die "failed to change to root directory\n";
            $sub->();
@@ -88,9 +91,12 @@ sub protected_call {
        POSIX::_exit(0);
     }
     while (waitpid($child, 0) != $child) {}
-    eval { PVE::Tools::run_command(['umount', "$rootdir/dev"]); };
-    warn $@ if $@;
-    return $? == 0;
+    my $status = $? == 0;
+    if ($mountdev) {
+       eval { PVE::Tools::run_command(['umount', "$rootdir/dev"]); };
+       warn $@ if $@;
+    }
+    return $status;
 }
 
 sub template_fixup {