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 5108F666F7 for ; Fri, 6 Nov 2020 14:58:32 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 44ED622577 for ; Fri, 6 Nov 2020 14:58:02 +0100 (CET) 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 B77D62256D for ; Fri, 6 Nov 2020 14:58:01 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8034E46031 for ; Fri, 6 Nov 2020 14:58:01 +0100 (CET) Date: Fri, 6 Nov 2020 14:58:00 +0100 From: Wolfgang Bumiller To: Fabian =?utf-8?Q?Gr=C3=BCnbichler?= Cc: pbs-devel@lists.proxmox.com Message-ID: <20201106135800.d522llerg5uwe5pq@olga.proxmox.com> References: <20201106134444.1118415-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201106134444.1118415-1-f.gruenbichler@proxmox.com> User-Agent: NeoMutt/20180716 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 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-backup-client.rs, user.rs] Subject: [pbs-devel] applied: [PATCH proxmox-backup] client: properly complete new-owner 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: Fri, 06 Nov 2020 13:58:32 -0000 applied On Fri, Nov 06, 2020 at 02:44:44PM +0100, Fabian Grünbichler wrote: > with remote Authids, not local Userids. > > Signed-off-by: Fabian Grünbichler > --- > src/api2/access/user.rs | 1 + > src/bin/proxmox-backup-client.rs | 31 +++++++++++++++++++++++++++++-- > 2 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs > index c0daf3ce..8be512c4 100644 > --- a/src/api2/access/user.rs > +++ b/src/api2/access/user.rs > @@ -76,6 +76,7 @@ pub struct UserWithTokens { > #[serde(skip_serializing_if="Option::is_none")] > pub email: Option, > #[serde(skip_serializing_if="Vec::is_empty")] > + #[serde(default="Vec::new")] > pub tokens: Vec, > } > > diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs > index ec60b3a9..760e59df 100644 > --- a/src/bin/proxmox-backup-client.rs > +++ b/src/bin/proxmox-backup-client.rs > @@ -32,11 +32,11 @@ use proxmox::{ > use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation}; > > use proxmox_backup::tools; > +use proxmox_backup::api2::access::user::UserWithTokens; > use proxmox_backup::api2::types::*; > use proxmox_backup::api2::version; > use proxmox_backup::client::*; > use proxmox_backup::pxar::catalog::*; > -use proxmox_backup::config::user::complete_userid; > use proxmox_backup::backup::{ > archive_type, > decrypt_key, > @@ -1904,6 +1904,33 @@ fn complete_chunk_size(_arg: &str, _param: &HashMap) -> Vec result > } > > +fn complete_auth_id(_arg: &str, param: &HashMap) -> Vec { > + proxmox_backup::tools::runtime::main(async { complete_auth_id_do(param).await }) > +} > + > +async fn complete_auth_id_do(param: &HashMap) -> Vec { > + > + let mut result = vec![]; > + > + let repo = match extract_repository_from_map(param) { > + Some(v) => v, > + _ => return result, > + }; > + > + let data = try_get(&repo, "api2/json/access/users?include_tokens=true").await; > + > + if let Ok(parsed) = serde_json::from_value::>(data) { > + for user in parsed { > + result.push(user.userid.to_string()); > + for token in user.tokens { > + result.push(token.tokenid.to_string()); > + } > + } > + }; > + > + result > +} > + > use proxmox_backup::client::RemoteChunkReader; > /// This is a workaround until we have cleaned up the chunk/reader/... infrastructure for better > /// async use! > @@ -2013,7 +2040,7 @@ fn main() { > let change_owner_cmd_def = CliCommand::new(&API_METHOD_CHANGE_BACKUP_OWNER) > .arg_param(&["group", "new-owner"]) > .completion_cb("group", complete_backup_group) > - .completion_cb("new-owner", complete_userid) > + .completion_cb("new-owner", complete_auth_id) > .completion_cb("repository", complete_repository); > > let cmd_def = CliCommandMap::new() > -- > 2.20.1