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 C0F39622B1 for ; Wed, 16 Sep 2020 11:51:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B5CF2224B9 for ; Wed, 16 Sep 2020 11:51:22 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS id D3549224AF for ; Wed, 16 Sep 2020 11:51:21 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A085C453D8 for ; Wed, 16 Sep 2020 11:51:21 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Wed, 16 Sep 2020 11:51:13 +0200 Message-Id: <20200916095113.4040822-2-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200916095113.4040822-1-f.gruenbichler@proxmox.com> References: <20200916095113.4040822-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, subscription.rs] Subject: [pbs-devel] [PATCH proxmox-backup 2/2] always allow retrieving (censored) subscription info X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 09:51:52 -0000 like we do for PVE. this is visible on the dashboard, and caused 403 on each update which bothers me when looking at the dev console. Signed-off-by: Fabian Grünbichler --- Notes: this will need more work once we actually introduce subscription keys, but seems good enough for now.. src/api2/node/subscription.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/api2/node/subscription.rs b/src/api2/node/subscription.rs index 186019cb..f8b14187 100644 --- a/src/api2/node/subscription.rs +++ b/src/api2/node/subscription.rs @@ -1,11 +1,12 @@ use anyhow::{Error}; use serde_json::{json, Value}; -use proxmox::api::{api, Router, Permission}; +use proxmox::api::{api, Router, RpcEnvironment, Permission}; use crate::tools; use crate::config::acl::PRIV_SYS_AUDIT; -use crate::api2::types::NODE_SCHEMA; +use crate::config::cached_user_info::CachedUserInfo; +use crate::api2::types::{NODE_SCHEMA, Userid}; #[api( input: { @@ -28,7 +29,7 @@ use crate::api2::types::NODE_SCHEMA; }, serverid: { type: String, - description: "The unique server ID.", + description: "The unique server ID, if permitted to access.", }, url: { type: String, @@ -37,18 +38,29 @@ use crate::api2::types::NODE_SCHEMA; }, }, access: { - permission: &Permission::Privilege(&[], PRIV_SYS_AUDIT, false), + permission: &Permission::Anybody, }, )] /// Read subscription info. -fn get_subscription(_param: Value) -> Result { +fn get_subscription( + _param: Value, + rpcenv: &mut dyn RpcEnvironment, +) -> Result { + let userid: Userid = rpcenv.get_user().unwrap().parse()?; + let user_info = CachedUserInfo::new()?; + let user_privs = user_info.lookup_privs(&userid, &[]); + let server_id = if (user_privs & PRIV_SYS_AUDIT) != 0 { + tools::get_hardware_address()? + } else { + "hidden".to_string() + }; let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing"; Ok(json!({ "status": "NotFound", - "message": "There is no subscription key", - "serverid": tools::get_hardware_address()?, - "url": url, + "message": "There is no subscription key", + "serverid": server_id, + "url": url, })) } -- 2.20.1