From: Cédric Bosdonnat Date: Wed, 24 Jun 2015 07:56:04 +0000 (+0200) Subject: virt-aa-helper: fix rules for paths with trailing slash X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e44bcae9f014946d66fad1164080a4e251197f19;p=libvirt.git virt-aa-helper: fix rules for paths with trailing slash Rules generated for a path like '/' were having '//' which isn't correct for apparmor. Make virt-aa-helper smarter to avoid these. --- diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 4440552a35..18454c8525 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -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");