From 2c88dc97fd075ff5a2555fbb942c641f259777d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 20 Apr 2022 13:58:41 +0200 Subject: [PATCH] api2: read_remote: also return RemoteWithoutPassword MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit like for the index, instead of manually stripping it. this (and the previous change) is backwards-compatible since `Remote` already skipped serializing empty strings, so the returned JSON is identical. Signed-off-by: Fabian Grünbichler --- src/api2/config/remote.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs index 3fcc650a..a3ee6649 100644 --- a/src/api2/config/remote.rs +++ b/src/api2/config/remote.rs @@ -111,7 +111,7 @@ pub fn create_remote(name: String, config: RemoteConfig, password: String) -> Re }, }, }, - returns: { type: Remote }, + returns: { type: RemoteWithoutPassword }, access: { permission: &Permission::Privilege(&["remote", "{name}"], PRIV_REMOTE_AUDIT, false), } @@ -121,10 +121,9 @@ pub fn read_remote( name: String, _info: &ApiMethod, mut rpcenv: &mut dyn RpcEnvironment, -) -> Result { +) -> Result { let (config, digest) = pbs_config::remote::config()?; - let mut data: Remote = config.lookup("remote", &name)?; - data.password = "".to_string(); // do not return password in api + let data: RemoteWithoutPassword = config.lookup("remote", &name)?; rpcenv["digest"] = hex::encode(&digest).into(); Ok(data) }