api/ticket: move getting cluster name into an eval
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 26 Nov 2018 13:54:02 +0000 (14:54 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 26 Nov 2018 14:49:53 +0000 (15:49 +0100)
to avoid a failed login if a broken corosync config is setup

Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/AccessControl.pm

index 93f384a..7e6ad39 100644 (file)
@@ -281,11 +281,14 @@ __PACKAGE__->register_method ({
 
        if (PVE::Corosync::check_conf_exists(1)) {
            if ($rpcenv->check($username, '/', ['Sys.Audit'], 1)) {
-               my $conf = cfs_read_file('corosync.conf');
-               my $totem = PVE::Corosync::totem_config($conf);
-               if ($totem->{cluster_name}) {
-                   $res->{clustername} = $totem->{cluster_name};
-               }
+               eval {
+                   my $conf = cfs_read_file('corosync.conf');
+                   my $totem = PVE::Corosync::totem_config($conf);
+                   if ($totem->{cluster_name}) {
+                       $res->{clustername} = $totem->{cluster_name};
+                   }
+               };
+               warn "$@\n" if $@;
            }
        }