]> git.proxmox.com Git - pve-container.git/commitdiff
fix undef warning when apparmor changeprofile fails
authorFilip Schauer <f.schauer@proxmox.com>
Tue, 9 Apr 2024 09:26:23 +0000 (11:26 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 9 Apr 2024 09:35:37 +0000 (11:35 +0200)
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@proxmox.com>
src/PVE/LXC.pm

index 7db48335200d9a9e319ddaddf8d09f6376fdac89..88a9d6f17fbdde89a1cf80a0e261ec6e58e4d64e 100644 (file)
@@ -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: