[pve-devel] [PATCH container] fix devices file check in autodev hook
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Oct 7 09:38:14 CEST 2016
open sets the FD even if the file does not exist, but
returns false itself.
the previous check failed for the ENOENT case and caused
reading a closed file handle because the if was never
entered.
---
note: not really problematic, but causes potentially
misleading log spam if containers are started for debug
logging or via the systemd unit.
src/lxc-pve-autodev-hook | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc-pve-autodev-hook b/src/lxc-pve-autodev-hook
index 2e2f998..d8f5012 100755
--- a/src/lxc-pve-autodev-hook
+++ b/src/lxc-pve-autodev-hook
@@ -22,9 +22,9 @@ if ($vmid ne $ARGV[0]) {
}
my $devlist_file = "/var/lib/lxc/$vmid/devices";
+my $fd;
-open my $fd, '<', $devlist_file;
-if (!$fd) {
+if (! open $fd, '<', $devlist_file) {
exit 0 if $!{ENOENT}; # If the list is empty the file might not exist.
die "failed to open device list: $!\n";
}
--
2.1.4
More information about the pve-devel
mailing list