From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8D6A47156A for ; Mon, 4 Oct 2021 08:09:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 781F316D0E for ; Mon, 4 Oct 2021 08:09:01 +0200 (CEST) Received: from kvmformation3.odiso.net (globalOdiso.M6Lille.odiso.net [89.248.211.242]) by firstgate.proxmox.com (Proxmox) with ESMTP id 22DBC16CF0 for ; Mon, 4 Oct 2021 08:08:59 +0200 (CEST) Received: by kvmformation3.odiso.net (Postfix, from userid 0) id AE44B1247AD; Mon, 4 Oct 2021 08:08:52 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Mon, 4 Oct 2021 08:08:51 +0200 Message-Id: <20211004060851.2084800-3-aderumier@odiso.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004060851.2084800-1-aderumier@odiso.com> References: <20211004060851.2084800-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.855 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% HEADER_FROM_DIFFERENT_DOMAINS 0.249 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods KHOP_HELO_FCRDNS 0.399 Relay HELO differs from its IP's reverse DNS NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH v2 pve-manager 2/2] api2 : network: anybridge: don't display bridges if user have access to vnets. X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2021 06:09:31 -0000 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 --- PVE/API2/Network.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm index a26f36d2..53165660 100644 --- a/PVE/API2/Network.pm +++ b/PVE/API2/Network.pm @@ -226,6 +226,7 @@ __PACKAGE__->register_method({ my ($param) = @_; my $rpcenv = PVE::RPCEnvironment::get(); + my $authuser = $rpcenv->get_user(); my $tmp = PVE::INotify::read_file('interfaces', 1); my $config = $tmp->{data}; @@ -238,20 +239,26 @@ __PACKAGE__->register_method({ delete $ifaces->{lo}; # do not list the loopback device 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) { my $type = $ifaces->{$k}->{type}; my $match = ($param->{type} eq $type) || ( ($param->{type} eq 'any_bridge') && ($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 { - $ifaces->{$_} = $vnets->{$_}; - } keys %$vnets; - } + map { + $ifaces->{$_} = $vnets->{$_}; + } keys %$vnets; } return PVE::RESTHandler::hash_to_array($ifaces, 'iface'); -- 2.30.2