]> git.proxmox.com Git - pve-cluster.git/commitdiff
cluster: improve error handling when reading files
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 11 Oct 2017 12:24:56 +0000 (14:24 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 17 Oct 2017 12:01:22 +0000 (14:01 +0200)
When querying file contents via IPC we return undef if the
file does not exist, but also on any other error. This is
potentially problematic as the ipcc_send_rec() xs function
returns undef on actual errors as well, while setting $!
(errno).

It's better to die in cases other than ENOENT. Before this,
pvesr would assume an empty replication config and an empty
vm list if pmxcfs wasn't running, which could then clear out
the entire local replication state file.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
data/PVE/Cluster.pm

index ce03d234c8d04375e8ef18f2d23910c1429d8cd8..70ce250a0095dd2f40151d446e42c11fc80ff958 100644 (file)
@@ -2,7 +2,7 @@ package PVE::Cluster;
 
 use strict;
 use warnings;
-use POSIX qw(EEXIST);
+use POSIX qw(EEXIST ENOENT);
 use File::stat qw();
 use Socket;
 use Storable qw(dclone);
@@ -402,7 +402,10 @@ my $ipcc_get_config = sub {
     my $bindata = pack "Z*", $path;
     my $res = PVE::IPCC::ipcc_send_rec(6, $bindata);
     if (!defined($res)) {
-       return undef if ($! != 0);
+       if ($! != 0) {
+           return undef if $! == ENOENT;
+           die "$!\n";
+       }
        return '';
     }