[pve-devel] [PATCH container] mount: deal with failing realpath

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Jul 7 12:35:36 CEST 2016


Fix an undefined value error when realpath() fails on the
device we got from the storage.
One case where this can easily happen is when using RBD and
deactivating the 'krbd' option as the path is then not a
valid device node.
Otherwise a more generic error is still better than warnings
about undefined values accompanied by failing mount
commands.
---
 src/PVE/LXC.pm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index caadce1..9bf1423 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1209,7 +1209,15 @@ sub mountpoint_mount {
 	    # device-mapper devices is special-cased to use the /dev/mapper symlinks.
 	    # Our autodev hook expects the /dev/dm-* device currently
 	    # and will create the /dev/mapper symlink accordingly
-	    ($path) = (Cwd::realpath($path) =~ /^(.*)$/s); # realpath() taints
+	    $path = Cwd::realpath($path);
+	    if (!$path) {
+		# if the path does not exist we get undef from realpath
+		# this happen when deactivating krbd on an rbd storage:
+		die "containers on rbd storage without krbd are not supported\n"
+		    if $scfg->{type} eq 'rbd' && !$scfg->{krbd};
+		die "failed to get device path\n";
+	    }
+	    ($path) = ($path =~ /^(.*)$/s); #untaint
 	    my $domount = sub {
 		my ($path) = @_;
 		if ($mount_path) {
-- 
2.1.4





More information about the pve-devel mailing list