mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-09 03:10:11 +00:00
api2 : network: anybridge: don't display bridges if user have access to vnets.
This remove vmbr* from bridgeselector if user have access to vnets. if user need to have also access to vmbr, we can add a permission in path "/sdn/vnets/vmbrX" Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
f28f611370
commit
89d146f207
@ -226,6 +226,7 @@ __PACKAGE__->register_method({
|
|||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
my $rpcenv = PVE::RPCEnvironment::get();
|
my $rpcenv = PVE::RPCEnvironment::get();
|
||||||
|
my $authuser = $rpcenv->get_user();
|
||||||
|
|
||||||
my $tmp = PVE::INotify::read_file('interfaces', 1);
|
my $tmp = PVE::INotify::read_file('interfaces', 1);
|
||||||
my $config = $tmp->{data};
|
my $config = $tmp->{data};
|
||||||
@ -238,21 +239,27 @@ __PACKAGE__->register_method({
|
|||||||
delete $ifaces->{lo}; # do not list the loopback device
|
delete $ifaces->{lo}; # do not list the loopback device
|
||||||
|
|
||||||
if ($param->{type}) {
|
if ($param->{type}) {
|
||||||
|
my $vnets = {};
|
||||||
|
my $filtered_sdn = undef;
|
||||||
|
my $privs = [ 'SDN.Audit', 'SDN.Allocate' ];
|
||||||
|
|
||||||
|
if ($have_sdn && $param->{type} eq 'any_bridge') {
|
||||||
|
$vnets = PVE::Network::SDN::get_local_vnets();
|
||||||
|
$filtered_sdn = 1 if $authuser ne 'root@pam' && keys %{$vnets} > 0;
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $k (keys %$ifaces) {
|
foreach my $k (keys %$ifaces) {
|
||||||
my $type = $ifaces->{$k}->{type};
|
my $type = $ifaces->{$k}->{type};
|
||||||
my $match = ($param->{type} eq $type) || (
|
my $match = ($param->{type} eq $type) || (
|
||||||
($param->{type} eq 'any_bridge') &&
|
($param->{type} eq 'any_bridge') &&
|
||||||
($type eq 'bridge' || $type eq 'OVSBridge'));
|
($type eq 'bridge' || $type eq 'OVSBridge'));
|
||||||
delete $ifaces->{$k} if !$match;
|
delete $ifaces->{$k} if !$match || ($filtered_sdn && !$rpcenv->check_any($authuser, "/sdn/vnets/$k", $privs, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($have_sdn && $param->{type} eq 'any_bridge') {
|
|
||||||
my $vnets = PVE::Network::SDN::get_local_vnets();
|
|
||||||
map {
|
map {
|
||||||
$ifaces->{$_} = $vnets->{$_};
|
$ifaces->{$_} = $vnets->{$_};
|
||||||
} keys %$vnets;
|
} keys %$vnets;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return PVE::RESTHandler::hash_to_array($ifaces, 'iface');
|
return PVE::RESTHandler::hash_to_array($ifaces, 'iface');
|
||||||
}});
|
}});
|
||||||
|
Loading…
Reference in New Issue
Block a user