提交 dae7054b 编写于 作者: J Jamie Strandboge 提交者: Daniel Veillard

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
上级 a8a560dd
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册