]> xenbits.xensource.com Git - libvirt.git/commitdiff
virt-aa-helper: fix rules for paths with trailing slash
authorCédric Bosdonnat <cbosdonnat@suse.com>
Wed, 24 Jun 2015 07:56:04 +0000 (09:56 +0200)
committerCédric Bosdonnat <cbosdonnat@suse.com>
Fri, 10 Jul 2015 09:30:36 +0000 (11:30 +0200)
Rules generated for a path like '/' were having '//' which isn't
correct for apparmor. Make virt-aa-helper smarter to avoid these.

src/security/virt-aa-helper.c

index 4440552a35784b3ede805fc24bc482623c12568d..18454c8525c3c7c0be07e2560656b3f6388376ce 100644 (file)
@@ -795,6 +795,9 @@ vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool recursi
         goto cleanup;
     }
 
+    if (tmp[strlen(tmp) - 1] == '/')
+        tmp[strlen(tmp) - 1] = '\0';
+
     virBufferAsprintf(buf, "  \"%s%s\" %s,\n", tmp, recursive ? "/**" : "", perms);
     if (readonly) {
         virBufferAddLit(buf, "  # don't audit writes to readonly files\n");