]> git.proxmox.com Git - pve-container.git/commitdiff
fix devices file check in autodev hook
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 7 Oct 2016 07:38:14 +0000 (09:38 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 7 Oct 2016 07:39:55 +0000 (09:39 +0200)
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.

src/lxc-pve-autodev-hook

index 2e2f998398900f0d292a12cb1ca8c4023a124f44..d8f5012e4828e0f9d9242055f10cbd047686ae0b 100755 (executable)
@@ -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";
 }