aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Strandboge <jamie@canonical.com>2009-11-13 15:22:20 +0100
committerDaniel Veillard <veillard@redhat.com>2009-11-13 15:32:55 +0100
commitdae7054b7697d30f2b88cd5dff3dfb954323d40b (patch)
tree896e09753e2ebd48961bfc18a79baae93f42dbc3
parentAppArmor updates of examples (diff)
downloadlibvirt-dae7054b7697d30f2b88cd5dff3dfb954323d40b.tar.gz
libvirt-dae7054b7697d30f2b88cd5dff3dfb954323d40b.tar.bz2
libvirt-dae7054b7697d30f2b88cd5dff3dfb954323d40b.zip
AppArmor require absolute paths
Fixes https://launchpad.net/bugs/460271 * src/security/virt-aa-helper.c: require absolute path for dynamic added files. This is required by AppArmor and conveniently prevents adding tcp consoles to the profile
-rw-r--r--src/security/virt-aa-helper.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 116aef5c6..498979873 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -517,6 +517,10 @@ valid_path(const char *path, const bool readonly)
if (strchr(path, '"') != NULL)
return 1;
+ /* Require an absolute path */
+ if (STRNEQLEN(path, "/", 1))
+ return 1;
+
if (!virFileExists(path))
vah_warning("path does not exist, skipping file type checks");
else {
@@ -718,6 +722,16 @@ vah_add_file(virBufferPtr buf, const char *path, const char *perms)
if (path == NULL)
return rc;
+ /* Skip files without an absolute path. Not having one confuses the
+ * apparmor parser and this also ensures things like tcp consoles don't
+ * get added to the profile.
+ */
+ if (STRNEQLEN(path, "/", 1)) {
+ vah_warning(path);
+ vah_warning(" skipped non-absolute path");
+ return 0;
+ }
+
if (virFileExists(path)) {
if ((tmp = realpath(path, NULL)) == NULL) {
vah_error(NULL, 0, path);