|
|
c401cc |
From c047ae52f61a3dee588968a11141c2200f1f2e44 Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <c047ae52f61a3dee588968a11141c2200f1f2e44.1386348946.git.jdenemar@redhat.com>
|
|
|
c401cc |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
c401cc |
Date: Mon, 2 Dec 2013 13:39:12 +0000
|
|
|
c401cc |
Subject: [PATCH] Fix bug in identifying sub-mounts
|
|
|
c401cc |
|
|
|
c401cc |
For
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1035403
|
|
|
c401cc |
|
|
|
c401cc |
The code for extracting sub-mounts would just do a STRPREFIX
|
|
|
c401cc |
check on the mount. This was flawed because if there were
|
|
|
c401cc |
the following mounts
|
|
|
c401cc |
|
|
|
c401cc |
/etc/aliases
|
|
|
c401cc |
/etc/aliases.db
|
|
|
c401cc |
|
|
|
c401cc |
and '/etc/aliases' was asked for, it would return both even
|
|
|
c401cc |
though the latter isn't a sub-mount.
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
c401cc |
(cherry picked from commit 84fd470d3d8c8e27abca8b2f3fc601c7cd58eadb)
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/util/virfile.c | 4 +++-
|
|
|
c401cc |
tests/virfiledata/mounts2.txt | 33 +++++++++++++++++++++++++++++++++
|
|
|
c401cc |
tests/virfiletest.c | 8 ++++++++
|
|
|
c401cc |
3 files changed, 44 insertions(+), 1 deletion(-)
|
|
|
c401cc |
create mode 100644 tests/virfiledata/mounts2.txt
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/util/virfile.c b/src/util/virfile.c
|
|
|
c401cc |
index e2a5f7a..9b3a4ad 100644
|
|
|
c401cc |
--- a/src/util/virfile.c
|
|
|
c401cc |
+++ b/src/util/virfile.c
|
|
|
c401cc |
@@ -1520,7 +1520,9 @@ virFileGetMountSubtreeImpl(const char *mtabpath,
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
while (getmntent_r(procmnt, &mntent, mntbuf, sizeof(mntbuf)) != NULL) {
|
|
|
c401cc |
- if (!STRPREFIX(mntent.mnt_dir, prefix))
|
|
|
c401cc |
+ if (!(STREQ(mntent.mnt_dir, prefix) ||
|
|
|
c401cc |
+ (STRPREFIX(mntent.mnt_dir, prefix) &&
|
|
|
c401cc |
+ mntent.mnt_dir[strlen(prefix)] == '/')))
|
|
|
c401cc |
continue;
|
|
|
c401cc |
|
|
|
c401cc |
if (VIR_EXPAND_N(mounts, nmounts, nmounts ? 1 : 2) < 0)
|
|
|
c401cc |
diff --git a/tests/virfiledata/mounts2.txt b/tests/virfiledata/mounts2.txt
|
|
|
c401cc |
new file mode 100644
|
|
|
c401cc |
index 0000000..8b47dde
|
|
|
c401cc |
--- /dev/null
|
|
|
c401cc |
+++ b/tests/virfiledata/mounts2.txt
|
|
|
c401cc |
@@ -0,0 +1,33 @@
|
|
|
c401cc |
+rootfs / rootfs rw 0 0
|
|
|
c401cc |
+proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
|
|
|
c401cc |
+sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
|
|
|
c401cc |
+devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=8057768k,nr_inodes=2014442,mode=755 0 0
|
|
|
c401cc |
+securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
|
|
|
c401cc |
+selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
|
|
|
c401cc |
+tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
|
|
|
c401cc |
+devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
|
|
|
c401cc |
+tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
|
|
|
c401cc |
+tmpfs /sys/fs/cgroup tmpfs rw,seclabel,nosuid,nodev,noexec,mode=755 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
|
|
|
c401cc |
+pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/net_cls cgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
|
|
|
c401cc |
+cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
|
|
|
c401cc |
+/dev/mapper/fedora-root / ext4 rw,seclabel,relatime,data=ordered 0 0
|
|
|
c401cc |
+systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=33,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
|
|
|
c401cc |
+configfs /sys/kernel/config configfs rw,relatime 0 0
|
|
|
c401cc |
+debugfs /sys/kernel/debug debugfs rw,relatime 0 0
|
|
|
c401cc |
+mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0
|
|
|
c401cc |
+tmpfs /tmp tmpfs rw,seclabel 0 0
|
|
|
c401cc |
+hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime 0 0
|
|
|
c401cc |
+binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
|
|
|
c401cc |
+/dev/sda1 /boot ext4 rw,seclabel,relatime,stripe=4,data=ordered 0 0
|
|
|
c401cc |
+fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
|
|
|
c401cc |
+gvfsd-fuse /run/user/501/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=501,group_id=501 0 0
|
|
|
c401cc |
+/dev/mapper/fedora-root /etc/aliases.db ext4 rw,seclabel,relatime,data=ordered 0 0
|
|
|
c401cc |
+/dev/mapper/fedora-root /etc/aliases ext4 rw,seclabel,relatime,data=ordered 0 0
|
|
|
c401cc |
diff --git a/tests/virfiletest.c b/tests/virfiletest.c
|
|
|
c401cc |
index fd6761d..273147e 100644
|
|
|
c401cc |
--- a/tests/virfiletest.c
|
|
|
c401cc |
+++ b/tests/virfiletest.c
|
|
|
c401cc |
@@ -104,6 +104,12 @@ mymain(void)
|
|
|
c401cc |
static const char *wantmounts1rev[] = {
|
|
|
c401cc |
"/proc/sys/fs/binfmt_misc", "/proc/sys/fs/binfmt_misc", "/proc"
|
|
|
c401cc |
};
|
|
|
c401cc |
+ static const char *wantmounts2a[] = {
|
|
|
c401cc |
+ "/etc/aliases"
|
|
|
c401cc |
+ };
|
|
|
c401cc |
+ static const char *wantmounts2b[] = {
|
|
|
c401cc |
+ "/etc/aliases.db"
|
|
|
c401cc |
+ };
|
|
|
c401cc |
|
|
|
c401cc |
# define DO_TEST_MOUNT_SUBTREE(name, path, prefix, mounts, rev) \
|
|
|
c401cc |
do { \
|
|
|
c401cc |
@@ -116,6 +122,8 @@ mymain(void)
|
|
|
c401cc |
|
|
|
c401cc |
DO_TEST_MOUNT_SUBTREE("/proc normal", MTAB_PATH1, "/proc", wantmounts1, false);
|
|
|
c401cc |
DO_TEST_MOUNT_SUBTREE("/proc reverse", MTAB_PATH1, "/proc", wantmounts1rev, true);
|
|
|
c401cc |
+ DO_TEST_MOUNT_SUBTREE("/etc/aliases", MTAB_PATH2, "/etc/aliases", wantmounts2a, false);
|
|
|
c401cc |
+ DO_TEST_MOUNT_SUBTREE("/etc/aliases.db", MTAB_PATH2, "/etc/aliases.db", wantmounts2b, false);
|
|
|
c401cc |
#endif /* ! defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R */
|
|
|
c401cc |
|
|
|
c401cc |
return ret != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
|
c401cc |
--
|
|
|
c401cc |
1.8.4.5
|
|
|
c401cc |
|