ticket: use clinfo to get cluster name

instead of parsing corosync.conf, and avoid coupling the access-control
API with PVE::Corosync. if corosync.conf and pmxcfs don't agree on how
the cluster is called, there is a bigger issue anyway..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2019-11-06 13:36:28 +01:00 committed by Thomas Lamprecht
parent 6bc6a78ac0
commit 0fb0c62d74

View File

@ -10,7 +10,6 @@ use PVE::Exception qw(raise raise_perm_exc);
use PVE::SafeSyslog; use PVE::SafeSyslog;
use PVE::RPCEnvironment; use PVE::RPCEnvironment;
use PVE::Cluster qw(cfs_read_file); use PVE::Cluster qw(cfs_read_file);
use PVE::Corosync;
use PVE::RESTHandler; use PVE::RESTHandler;
use PVE::AccessControl; use PVE::AccessControl;
use PVE::JSONSchema qw(get_standard_option); use PVE::JSONSchema qw(get_standard_option);
@ -314,17 +313,9 @@ __PACKAGE__->register_method ({
$res->{cap} = &$compute_api_permission($rpcenv, $username) $res->{cap} = &$compute_api_permission($rpcenv, $username)
if !defined($res->{NeedTFA}); if !defined($res->{NeedTFA});
if (PVE::Corosync::check_conf_exists(1)) { my $clinfo = PVE::Cluster::get_clinfo();
if ($rpcenv->check($username, '/', ['Sys.Audit'], 1)) { if ($clinfo->{cluster}->{name} && $rpcenv->check($username, '/', ['Sys.Audit'], 1)) {
eval { $res->{clustername} = $clinfo->{cluster}->{name};
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 $@;
}
} }
PVE::Cluster::log_msg('info', 'root@pam', "successful auth for user '$username'"); PVE::Cluster::log_msg('info', 'root@pam', "successful auth for user '$username'");