[pve-devel] [PATCH pve-common] is_mounted: use realpath on the mountpoint

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Sep 7 12:09:27 CEST 2015


This will avoid problmes with symlinks as well as paths
containing ./, ../ or trailing slashes.
---
 src/PVE/ProcFSTools.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm
index 4670694..368ae73 100644
--- a/src/PVE/ProcFSTools.pm
+++ b/src/PVE/ProcFSTools.pm
@@ -6,6 +6,7 @@ use POSIX;
 use Time::HiRes qw (gettimeofday);
 use IO::File;
 use PVE::Tools;
+use Cwd;
 
 my $clock_ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK);
 
@@ -291,6 +292,8 @@ sub read_proc_mounts {
 sub is_mounted {
     my ($mountpoint) = @_;
 
+    $mountpoint = Cwd::realpath($mountpoint);
+
     my $mountdata = read_proc_mounts();
 
     if ($mountdata =~ m/\s$mountpoint\s/) {
-- 
2.1.4





More information about the pve-devel mailing list