[pve-devel] [PATCH v2 container 2/2] fix undef warning when apparmor changeprofile fails

Filip Schauer f.schauer at proxmox.com
Mon Mar 25 18:28:29 CET 2024


Fix a "Use of uninitialized value in numeric ne (!=)" warning when
syswrite returns undef when trying to change the apparmor profile.

Signed-off-by: Filip Schauer <f.schauer at proxmox.com>
---
 src/PVE/LXC.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 7db4833..88a9d6f 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1975,7 +1975,8 @@ sub mountpoint_hotplug :prototype($$$$$) {
 
 	# Now switch our apparmor profile before mounting:
 	my $data = 'changeprofile pve-container-mounthotplug';
-	if (syswrite($aa_fd, $data, length($data)) != length($data)) {
+	my $data_written = syswrite($aa_fd, $data, length($data));
+	if (!defined($data_written) || $data_written != length($data)) {
 	    die "failed to change apparmor profile: $!\n";
 	}
 	# Check errors on close as well:
-- 
2.39.2





More information about the pve-devel mailing list