diff --git a/libvirt/src/security/security_apparmor.c b/libvirt/src/security/security_apparmor.c index 3025284..02b7e46 100644 --- a/libvirt/src/security/security_apparmor.c +++ b/libvirt/src/security/security_apparmor.c @@ -91,7 +91,7 @@ profile_status(const char *str, const int check_enforcing) } } - if (virFileReadAll(APPARMOR_PROFILES_PATH, MAX_FILE_LEN, &content) < 0) { + if (virFileReadAll(APPARMOR_PROFILES_PATH, MAX_FILE_LEN, &content) <= 0) { virReportSystemError(errno, _("Failed to read AppArmor profiles list " "\'%s\'"), APPARMOR_PROFILES_PATH); diff --git a/libvirt/src/security/virt-aa-helper.c b/libvirt/src/security/virt-aa-helper.c index 9afc8db..ae9a09a 100644 --- a/libvirt/src/security/virt-aa-helper.c +++ b/libvirt/src/security/virt-aa-helper.c @@ -306,6 +306,8 @@ update_include_file(const char *include_file, const char *included_files, } if (safewrite(fd, pcontent, plen) < 0) { /* don't write the '\0' */ + /* try to ensure the content reached the disk to avoid problems on power loss */ + fsync(fd); VIR_FORCE_CLOSE(fd); vah_error(NULL, 0, _("failed to write to profile")); goto cleanup;