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 BDD25612BA for ; Tue, 13 Oct 2020 10:59:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A7D5AC3F0 for ; Tue, 13 Oct 2020 10:58:52 +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 AB778C3C0 for ; Tue, 13 Oct 2020 10:58:51 +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 57CBC45D2F for ; Tue, 13 Oct 2020 10:58:51 +0200 (CEST) From: Dylan Whyte To: pbs-devel@lists.proxmox.com Date: Tue, 13 Oct 2020 10:58:41 +0200 Message-Id: <20201013085841.22773-2-d.whyte@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201013085841.22773-1-d.whyte@proxmox.com> References: <20201013085841.22773-1-d.whyte@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 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] Subject: [pbs-devel] [PATCH proxmox-backup 2/2] fix #2847: proxmox-backup-client: add change-owner cmd 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: Tue, 13 Oct 2020 08:59:22 -0000 This adds a change-owner command to proxmox-backup-client, that allows a caller with datastore modify privileges to change the owner of a backup-group. Signed-off-by: Dylan Whyte --- src/bin/proxmox-backup-client.rs | 43 +++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 97398f49..90cb8378 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -412,6 +412,41 @@ async fn list_backup_groups(param: Value) -> Result { Ok(Value::Null) } +#[api( + input: { + properties: { + repository: { + schema: REPO_URL_SCHEMA, + optional: true, + }, + group: { + type: String, + description: "Backup group.", + }, + "new-owner": { + type: String, + description: "Userid to transfer ownership to", + }, + } + } +)] +/// Change owner of a backup group +async fn change_backup_owner(mut param: Value) -> Result<(), Error> { + + let repo = extract_repository_from_value(¶m)?; + + let mut client = connect(repo.host(), repo.port(), repo.user())?; + + param.as_object_mut().unwrap().remove("repository"); + + let path = format!("api2/json/admin/datastore/{}/change-owner", repo.store()); + client.post(&path, Some(param)).await?; + + record_repository(&repo); + + Ok(()) +} + #[api( input: { properties: { @@ -1967,6 +2002,11 @@ fn main() { let version_cmd_def = CliCommand::new(&API_METHOD_API_VERSION) .completion_cb("repository", complete_repository); + 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("repository", complete_repository); + let cmd_def = CliCommandMap::new() .insert("backup", backup_cmd_def) .insert("upload-log", upload_log_cmd_def) @@ -1987,7 +2027,8 @@ fn main() { .insert("catalog", catalog_mgmt_cli()) .insert("task", task_mgmt_cli()) .insert("version", version_cmd_def) - .insert("benchmark", benchmark_cmd_def); + .insert("benchmark", benchmark_cmd_def) + .insert("change-owner", change_owner_cmd_def); let rpcenv = CliEnvironment::new(); run_cli_command(cmd_def, rpcenv, Some(|future| { -- 2.20.1