From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id ED29B1FF0E9 for ; Thu, 16 Jul 2026 12:31:58 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 71A78213F2; Thu, 16 Jul 2026 12:31:58 +0200 (CEST) From: Christoph Heiss To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 2/2] manager: user: add 'user update-token' command Date: Thu, 16 Jul 2026 12:29:57 +0200 Message-ID: <20260716103108.724902-3-c.heiss@proxmox.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260716103108.724902-1-c.heiss@proxmox.com> References: <20260716103108.724902-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1784197864935 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: EKBSCRTUSAAX3XB3NF7F7AJ6PMXHPPEE X-Message-ID-Hash: EKBSCRTUSAAX3XB3NF7F7AJ6PMXHPPEE X-MailFrom: c.heiss@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: .. enabling users to easily update API tokens from the command line. Signed-off-by: Christoph Heiss --- src/bin/proxmox_backup_manager/user.rs | 62 +++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox_backup_manager/user.rs b/src/bin/proxmox_backup_manager/user.rs index a429823de..93cb2d43f 100644 --- a/src/bin/proxmox_backup_manager/user.rs +++ b/src/bin/proxmox_backup_manager/user.rs @@ -6,7 +6,10 @@ use std::collections::HashMap; use proxmox_router::{ApiHandler, RpcEnvironment, cli::*}; use proxmox_schema::api; -use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Tokenname, Userid}; +use pbs_api_types::{ + ACL_PATH_SCHEMA, Authid, ENABLE_USER_SCHEMA, EXPIRE_USER_SCHEMA, REGENERATE_TOKEN_SCHEMA, + SINGLE_LINE_COMMENT_SCHEMA, Tokenname, Userid, +}; use proxmox_backup::api2; @@ -136,6 +139,56 @@ fn generate_token(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result Result { + let output_format = get_output_format(¶m); + + let info = &api2::access::user::API_METHOD_UPDATE_TOKEN; + let mut data = match info.handler { + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, + _ => unreachable!(), + }; + + let options = default_table_format_options().column(ColumnConfig::new("secret")); + if !data.is_null() { + format_and_print_result_full(&mut data, &info.returns, &output_format, &options); + } + + Ok(Value::Null) +} + #[api( input: { properties: { @@ -258,6 +311,13 @@ pub fn user_commands() -> CommandLineInterface { .arg_param(&["userid", "token-name"]) .completion_cb("userid", pbs_config::user::complete_userid), ) + .insert( + "update-token", + CliCommand::new(&API_METHOD_UPDATE_TOKEN) + .arg_param(&["userid", "token-name"]) + .completion_cb("userid", pbs_config::user::complete_userid) + .completion_cb("token-name", pbs_config::user::complete_token_name), + ) .insert( "delete-token", CliCommand::new(&api2::access::user::API_METHOD_DELETE_TOKEN) -- 2.54.0