]> git.proxmox.com Git - pve-common.git/commitdiff
is_mounted: use realpath on the mountpoint
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 7 Sep 2015 10:09:27 +0000 (12:09 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 7 Sep 2015 11:02:17 +0000 (13:02 +0200)
This will avoid problmes with symlinks as well as paths
containing ./, ../ or trailing slashes.

src/PVE/ProcFSTools.pm

index 467069430c6a7baa927a4975ae3e9159925f3abe..368ae73a1674b93018d1df9505604c7746f07811 100644 (file)
@@ -6,6 +6,7 @@ use POSIX;
 use Time::HiRes qw (gettimeofday);
 use IO::File;
 use PVE::Tools;
 use Time::HiRes qw (gettimeofday);
 use IO::File;
 use PVE::Tools;
+use Cwd;
 
 my $clock_ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK);
 
 
 my $clock_ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK);
 
@@ -291,6 +292,8 @@ sub read_proc_mounts {
 sub is_mounted {
     my ($mountpoint) = @_;
 
 sub is_mounted {
     my ($mountpoint) = @_;
 
+    $mountpoint = Cwd::realpath($mountpoint);
+
     my $mountdata = read_proc_mounts();
 
     if ($mountdata =~ m/\s$mountpoint\s/) {
     my $mountdata = read_proc_mounts();
 
     if ($mountdata =~ m/\s$mountpoint\s/) {