From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id D638E1FF136 for ; Mon, 26 Jan 2026 16:13:37 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E8D34112C2; Mon, 26 Jan 2026 16:13:59 +0100 (CET) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Mon, 26 Jan 2026 16:13:44 +0100 Message-ID: <20260126151349.627829-8-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260126151349.627829-1-m.sandoval@proxmox.com> References: <20260126151349.627829-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1769440366777 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.911 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_MAILER 2 Automated Mailer Tag Left in Email SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox 07/10] cargo: run fmt again 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Signed-off-by: Maximiliano Sandoval --- pbs-api-types/src/maintenance.rs | 7 +- proxmox-api-macro/src/api/enums.rs | 21 +++--- proxmox-api-macro/src/api/method.rs | 43 ++++++------ proxmox-api-macro/src/serde.rs | 7 +- proxmox-api-macro/src/util.rs | 36 +++++----- proxmox-apt/src/cache.rs | 7 +- proxmox-apt/src/cache_api.rs | 7 +- proxmox-apt/src/deb822/release_file.rs | 9 +-- proxmox-apt/src/repositories/file.rs | 13 ++-- .../src/repositories/file/list_parser.rs | 9 +-- proxmox-apt/src/repositories/repository.rs | 7 +- proxmox-config-digest/src/lib.rs | 7 +- proxmox-ldap/src/sync.rs | 6 +- proxmox-rrd/src/cache/journal.rs | 17 ++--- proxmox-section-config/src/lib.rs | 9 +-- proxmox-section-config/src/typed.rs | 7 +- proxmox-tfa/src/api/mod.rs | 68 +++++++++---------- proxmox-tfa/src/api/webauthn.rs | 7 +- pve-api-types/src/types/array.rs | 17 ++--- pve-api-types/src/types/verifiers.rs | 8 ++- 20 files changed, 168 insertions(+), 144 deletions(-) diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs index 404d2c32..baf4e29a 100644 --- a/pbs-api-types/src/maintenance.rs +++ b/pbs-api-types/src/maintenance.rs @@ -111,9 +111,10 @@ impl MaintenanceMode { } else if self.ty == MaintenanceType::S3Refresh { bail!("S3 refresh maintenance mode: {}", message); } else if self.ty == MaintenanceType::ReadOnly - && let Some(Operation::Write) = operation { - bail!("read-only maintenance mode: {}", message); - } + && let Some(Operation::Write) = operation + { + bail!("read-only maintenance mode: {}", message); + } Ok(()) } } diff --git a/proxmox-api-macro/src/api/enums.rs b/proxmox-api-macro/src/api/enums.rs index 378e7f05..483686f2 100644 --- a/proxmox-api-macro/src/api/enums.rs +++ b/proxmox-api-macro/src/api/enums.rs @@ -138,18 +138,19 @@ fn handle_string_enum( }; if derives_default - && let Some(attr) = variant.attrs.iter().find(|a| a.path().is_ident("default")) { - if let Some(default_value) = &default_value { - error!(attr => "multiple default values defined"); - error!(default_value => "default previously defined here"); - } else { - default_value = Some(variant_string.clone()); - if let Some(span) = has_default_attrib { - error!(attr => "#[default] attribute in use with 'default' #[api] key"); - error!(span, "'default' also defined here"); - } + && let Some(attr) = variant.attrs.iter().find(|a| a.path().is_ident("default")) + { + if let Some(default_value) = &default_value { + error!(attr => "multiple default values defined"); + error!(default_value => "default previously defined here"); + } else { + default_value = Some(variant_string.clone()); + if let Some(span) = has_default_attrib { + error!(attr => "#[default] attribute in use with 'default' #[api] key"); + error!(span, "'default' also defined here"); } } + } variants.extend(quote_spanned! { variant.ident.span() => ::proxmox_schema::EnumEntry { diff --git a/proxmox-api-macro/src/api/method.rs b/proxmox-api-macro/src/api/method.rs index c55a21d4..fdea5f35 100644 --- a/proxmox-api-macro/src/api/method.rs +++ b/proxmox-api-macro/src/api/method.rs @@ -494,24 +494,26 @@ fn handle_function_signature(method_info: &mut MethodInfo) -> Result bool { if let syn::Type::Reference(r) = ty - && let syn::Type::Path(p) = &*r.elem { - if p.qself.is_some() { - return false; - } - if let Some(ps) = p.path.segments.last() { - return ps.ident == "ApiMethod"; - } + && let syn::Type::Path(p) = &*r.elem + { + if p.qself.is_some() { + return false; } + if let Some(ps) = p.path.segments.last() { + return ps.ident == "ApiMethod"; + } + } false } fn is_rpc_env_type(ty: &syn::Type) -> bool { if let syn::Type::Reference(r) = ty && let syn::Type::TraitObject(t) = &*r.elem - && let Some(syn::TypeParamBound::Trait(b)) = t.bounds.first() - && let Some(ps) = b.path.segments.last() { - return ps.ident == "RpcEnvironment"; - } + && let Some(syn::TypeParamBound::Trait(b)) = t.bounds.first() + && let Some(ps) = b.path.segments.last() + { + return ps.ident == "RpcEnvironment"; + } false } @@ -942,17 +944,18 @@ struct DefaultParameters<'a>(&'a Schema); impl VisitMut for DefaultParameters<'_> { fn visit_expr_mut(&mut self, i: &mut syn::Expr) { if let syn::Expr::Macro(exprmac) = i - && exprmac.mac.path.is_ident("api_get_default") { - // replace api_get_default macros with the actual default found in the #[api] - // macro. - match self.get_default(mem::take(&mut exprmac.mac.tokens)) { - Ok(expr) => *i = expr, - Err(err) => { - *i = syn::Expr::Verbatim(err.to_compile_error()); - return; - } + && exprmac.mac.path.is_ident("api_get_default") + { + // replace api_get_default macros with the actual default found in the #[api] + // macro. + match self.get_default(mem::take(&mut exprmac.mac.tokens)) { + Ok(expr) => *i = expr, + Err(err) => { + *i = syn::Expr::Verbatim(err.to_compile_error()); + return; } } + } visit_mut::visit_expr_mut(self, i) } diff --git a/proxmox-api-macro/src/serde.rs b/proxmox-api-macro/src/serde.rs index 52dd8fed..345b3f2e 100644 --- a/proxmox-api-macro/src/serde.rs +++ b/proxmox-api-macro/src/serde.rs @@ -230,9 +230,10 @@ impl FieldAttrib { pub fn check_non_option_type(&self) { if let Some(span) = self.has_skip_serializing_if - && !self.has_default { - error!(span, "`skip_serializing_if` without `default`"); - } + && !self.has_default + { + error!(span, "`skip_serializing_if` without `default`"); + } } } diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs index 042684ff..db2acdf2 100644 --- a/proxmox-api-macro/src/util.rs +++ b/proxmox-api-macro/src/util.rs @@ -435,16 +435,17 @@ pub fn derive_descriptions( let mut parts = doc_comment.split("\nReturns:"); if let Some(first) = parts.next() - && input_schema.description.is_none() { - input_schema.description = Maybe::Derived(syn::LitStr::new(first.trim(), doc_span)); - } + && input_schema.description.is_none() + { + input_schema.description = Maybe::Derived(syn::LitStr::new(first.trim(), doc_span)); + } if let Some(second) = parts.next() { if let Some(returns_schema) = returns_schema - && returns_schema.description.is_none() { - returns_schema.description = - Maybe::Derived(syn::LitStr::new(second.trim(), doc_span)); - } + && returns_schema.description.is_none() + { + returns_schema.description = Maybe::Derived(syn::LitStr::new(second.trim(), doc_span)); + } if parts.next().is_some() { bail!( @@ -519,9 +520,10 @@ pub fn is_option_type(ty: &syn::Type) -> Option<&syn::Type> { if let syn::PathArguments::AngleBracketed(generic) = &segs.last().unwrap().arguments && generic.args.len() == 1 - && let syn::GenericArgument::Type(ty) = generic.args.first().unwrap() { - return Some(ty); - } + && let syn::GenericArgument::Type(ty) = generic.args.first().unwrap() + { + return Some(ty); + } } None } @@ -744,17 +746,19 @@ where match arg { Pair::Punctuated(item, punct) => { if let syn::Meta::Path(path) = &item - && !func(path) { - continue; - } + && !func(path) + { + continue; + } args.push_value(item); args.push_punct(punct); } Pair::End(item) => { if let syn::Meta::Path(path) = &item - && !func(path) { - continue; - } + && !func(path) + { + continue; + } args.push_value(item); } } diff --git a/proxmox-apt/src/cache.rs b/proxmox-apt/src/cache.rs index bd12eb22..b27fa886 100644 --- a/proxmox-apt/src/cache.rs +++ b/proxmox-apt/src/cache.rs @@ -248,9 +248,10 @@ where let mut pkg_iter = origin.file(); let pkg_file = pkg_iter.next(); if let Some(pkg_file) = pkg_file - && let Some(origin_name) = pkg_file.origin() { - origin_res = origin_name; - } + && let Some(origin_name) = pkg_file.origin() + { + origin_res = origin_name; + } } if let Some(depends) = depends { diff --git a/proxmox-apt/src/cache_api.rs b/proxmox-apt/src/cache_api.rs index d2c7dbfc..771c69ee 100644 --- a/proxmox-apt/src/cache_api.rs +++ b/proxmox-apt/src/cache_api.rs @@ -14,9 +14,10 @@ pub fn list_available_apt_update>( ) -> Result, Error> { let apt_state_file = apt_state_file.as_ref(); if let Ok(false) = crate::cache::pkg_cache_expired(apt_state_file) - && let Ok(Some(cache)) = crate::cache::read_pkg_state(apt_state_file) { - return Ok(cache.package_status); - } + && let Ok(Some(cache)) = crate::cache::read_pkg_state(apt_state_file) + { + return Ok(cache.package_status); + } let cache = crate::cache::update_cache(apt_state_file)?; diff --git a/proxmox-apt/src/deb822/release_file.rs b/proxmox-apt/src/deb822/release_file.rs index e5e9ed74..54e4afa8 100644 --- a/proxmox-apt/src/deb822/release_file.rs +++ b/proxmox-apt/src/deb822/release_file.rs @@ -151,10 +151,11 @@ impl FileReferenceType { "debian-installer" => { // another layer, then like regular repo but pointing at udebs if let Some((dir, rest)) = rest.split_once('/') - && let Some(arch) = dir.strip_prefix("binary-") { - // Packages or compat-Release - return parse_binary_dir(rest, arch); - } + && let Some(arch) = dir.strip_prefix("binary-") + { + // Packages or compat-Release + return parse_binary_dir(rest, arch); + } // all the rest Ok(FileReferenceType::Unknown) diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs index abf9e55e..b0e426c2 100644 --- a/proxmox-apt/src/repositories/file.rs +++ b/proxmox-apt/src/repositories/file.rs @@ -351,12 +351,13 @@ impl APTRepositoryFileImpl for APTRepositoryFile { } if let Some(require_suffix) = require_suffix - && suffix != require_suffix { - add_info( - "warning", - format!("expected suite '{current_codename}{require_suffix}'"), - ); - } + && suffix != require_suffix + { + add_info( + "warning", + format!("expected suite '{current_codename}{require_suffix}'"), + ); + } } } diff --git a/proxmox-apt/src/repositories/file/list_parser.rs b/proxmox-apt/src/repositories/file/list_parser.rs index b800473c..7a0e23a5 100644 --- a/proxmox-apt/src/repositories/file/list_parser.rs +++ b/proxmox-apt/src/repositories/file/list_parser.rs @@ -166,10 +166,11 @@ impl APTListFileParser { // check for commented out repository first if let Some(commented_out) = line.strip_prefix('#') - && let Ok(Some(mut repo)) = self.parse_one_line(commented_out) { - repo.set_enabled(false); - return Ok(Some(repo)); - } + && let Ok(Some(mut repo)) = self.parse_one_line(commented_out) + { + repo.set_enabled(false); + return Ok(Some(repo)); + } let mut repo = APTRepository::new(APTRepositoryFileType::List); diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs index 4ec1c4e7..57fe16da 100644 --- a/proxmox-apt/src/repositories/repository.rs +++ b/proxmox-apt/src/repositories/repository.rs @@ -225,9 +225,10 @@ fn uri_to_filename(uri: &str) -> String { } if (uri.starts_with("http://") || uri.starts_with("https://")) - && let Some(begin) = filename.find('@') { - filename = &filename[(begin + 1)..]; - } + && let Some(begin) = filename.find('@') + { + filename = &filename[(begin + 1)..]; + } // APT seems to only strip one final slash, so do the same filename = filename.strip_suffix('/').unwrap_or(filename); diff --git a/proxmox-config-digest/src/lib.rs b/proxmox-config-digest/src/lib.rs index 993e31cc..0b113f21 100644 --- a/proxmox-config-digest/src/lib.rs +++ b/proxmox-config-digest/src/lib.rs @@ -42,9 +42,10 @@ impl ConfigDigest { /// This function fails with a reasonable error message if checksums do not match. pub fn detect_modification(&self, user_digest: Option<&Self>) -> Result<(), Error> { if let Some(user_digest) = user_digest - && user_digest != self { - bail!("detected modified configuration - file changed by other user? Try again."); - } + && user_digest != self + { + bail!("detected modified configuration - file changed by other user? Try again."); + } Ok(()) } } diff --git a/proxmox-ldap/src/sync.rs b/proxmox-ldap/src/sync.rs index 87841ec3..e5bfdf3e 100644 --- a/proxmox-ldap/src/sync.rs +++ b/proxmox-ldap/src/sync.rs @@ -342,9 +342,9 @@ impl LdapRealmSyncJob { if !self.dry_run && let Err(e) = proxmox_access_control::token_shadow::delete_secret(&tokenid) - { - log::warn!("could not delete token for user {userid}: {e}",) - } + { + log::warn!("could not delete token for user {userid}: {e}",) + } if self.general_sync_settings.should_remove_acls() { acl_config.delete_authid(&tokenid); diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs index a78d06ee..80711021 100644 --- a/proxmox-rrd/src/cache/journal.rs +++ b/proxmox-rrd/src/cache/journal.rs @@ -172,14 +172,15 @@ impl JournalState { if let Some(extension) = path.extension() && let Some(extension) = extension.to_str() - && let Some(rest) = extension.strip_prefix("journal-") - && let Ok(time) = u64::from_str_radix(rest, 16) { - list.push(JournalFileInfo { - time, - name: format!("rrd.{extension}"), - path: path.to_owned(), - }); - } + && let Some(rest) = extension.strip_prefix("journal-") + && let Ok(time) = u64::from_str_radix(rest, 16) + { + list.push(JournalFileInfo { + time, + name: format!("rrd.{extension}"), + path: path.to_owned(), + }); + } } list.sort_unstable_by_key(|entry| entry.time); Ok(list) diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index 3fca933d..fec6a423 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -434,10 +434,11 @@ impl SectionConfig { -> Result<(), Error> { for (name, optional, _prop_schema) in schema.properties() { if let Some(id_property) = id_property - && name == id_property { - // the id_property is the section header, skip for requirement check - continue; - } + && name == id_property + { + // the id_property is the section header, skip for requirement check + continue; + } if !*optional && value[name] == Value::Null { return Err(format_err!( "property '{}' is missing and it is not optional.", diff --git a/proxmox-section-config/src/typed.rs b/proxmox-section-config/src/typed.rs index b06d290e..55cb3c75 100644 --- a/proxmox-section-config/src/typed.rs +++ b/proxmox-section-config/src/typed.rs @@ -216,9 +216,10 @@ impl SectionConfigData { let removed_value = self.sections.remove(key); // only update the order vector if we actually removed something if removed_value.is_some() - && let Some(pos) = self.order.iter().position(|k| k.borrow() == key) { - self.order.remove(pos); - } + && let Some(pos) = self.order.iter().position(|k| k.borrow() == key) + { + self.order.remove(pos); + } removed_value } } diff --git a/proxmox-tfa/src/api/mod.rs b/proxmox-tfa/src/api/mod.rs index 5b2841be..f8188346 100644 --- a/proxmox-tfa/src/api/mod.rs +++ b/proxmox-tfa/src/api/mod.rs @@ -434,10 +434,9 @@ impl TfaConfig { save = true; } - if save - && let Err(err) = data.save() { - log::error!("failed to store user challenge data: {err}"); - } + if save && let Err(err) = data.save() { + log::error!("failed to store user challenge data: {err}"); + } r } Ok(r) => r, @@ -995,26 +994,26 @@ impl TfaUserData { && u2f .auth_verify_obj(&entry.public_key, &challenge.challenge, response)? .is_some() - { - let mut data = match access.open_no_create(userid)? { - Some(data) => data, - None => bail!("no such challenge"), - }; - let index = data - .get_mut() - .u2f_auths - .iter() - .position(|r| r == challenge) - .ok_or_else(|| format_err!("no such challenge"))?; - let entry = data.get_mut().u2f_auths.remove(index); - if entry.is_expired(expire_before) { - bail!("no such challenge"); - } - data.save() - .map_err(|err| format_err!("failed to save challenge file: {}", err))?; - - return Ok(()); + { + let mut data = match access.open_no_create(userid)? { + Some(data) => data, + None => bail!("no such challenge"), + }; + let index = data + .get_mut() + .u2f_auths + .iter() + .position(|r| r == challenge) + .ok_or_else(|| format_err!("no such challenge"))?; + let entry = data.get_mut().u2f_auths.remove(index); + if entry.is_expired(expire_before) { + bail!("no such challenge"); } + data.save() + .map_err(|err| format_err!("failed to save challenge file: {}", err))?; + + return Ok(()); + } bail!("u2f verification failed"); } @@ -1087,19 +1086,20 @@ impl TfaUserData { value: &str, ) -> Result<(), Error> { if let Some(r) = &mut self.recovery - && r.verify(value)? { - // On success we reset the failure state. - self.totp_locked = false; - self.tfa_locked_until = None; + && r.verify(value)? + { + // On success we reset the failure state. + self.totp_locked = false; + self.tfa_locked_until = None; - let mut data = access.open(userid)?; - let access = data.get_mut(); - if access.totp_failures != 0 { - access.totp_failures = 0; - data.save()?; - } - return Ok(()); + let mut data = access.open(userid)?; + let access = data.get_mut(); + if access.totp_failures != 0 { + access.totp_failures = 0; + data.save()?; } + return Ok(()); + } bail!("recovery verification failed"); } diff --git a/proxmox-tfa/src/api/webauthn.rs b/proxmox-tfa/src/api/webauthn.rs index 8343d721..8c08401c 100644 --- a/proxmox-tfa/src/api/webauthn.rs +++ b/proxmox-tfa/src/api/webauthn.rs @@ -197,9 +197,10 @@ fn force_allow_backup_eligibility( let mut state = serde_json::to_value(&state).context("failed to convert authentication state to json")?; if let Some(obj) = state.get_mut("ast") - && let Some(allow) = obj.get_mut("allow_backup_eligible_upgrade") { - *allow = serde_json::Value::Bool(true); - } + && let Some(allow) = obj.get_mut("allow_backup_eligible_upgrade") + { + *allow = serde_json::Value::Bool(true); + } serde_json::from_value(state).context("failed to convert json back to authentication state") } diff --git a/pve-api-types/src/types/array.rs b/pve-api-types/src/types/array.rs index 75a98af4..1465c5f2 100644 --- a/pve-api-types/src/types/array.rs +++ b/pve-api-types/src/types/array.rs @@ -175,15 +175,16 @@ impl ArrayMap { while let Some((key, value)) = map.next_entry::, T>()? { if let Some(id) = key.as_ref().strip_prefix(self.prefix) - && let Ok(id) = id.parse::() { - if this.insert(id, value).map_err(A::Error::custom)?.is_some() { - return Err(A::Error::custom(format!( - "multiple '{}{id}' elements", - self.prefix - ))); - } - continue; + && let Ok(id) = id.parse::() + { + if this.insert(id, value).map_err(A::Error::custom)?.is_some() { + return Err(A::Error::custom(format!( + "multiple '{}{id}' elements", + self.prefix + ))); } + continue; + } return Err(A::Error::custom(format!( "invalid array element name {key}" ))); diff --git a/pve-api-types/src/types/verifiers.rs b/pve-api-types/src/types/verifiers.rs index 18d16470..25098b6f 100644 --- a/pve-api-types/src/types/verifiers.rs +++ b/pve-api-types/src/types/verifiers.rs @@ -218,9 +218,11 @@ pub fn verify_lxc_mp_string(s: &str) -> Result<(), Error> { pub fn verify_ip_with_ll_iface(s: &str) -> Result<(), Error> { if let Some(percent) = s.find('%') - && FE80_RE.is_match(s) && IFACE_RE.is_match(&s[(percent + 1)..]) { - return verify_ipv6(&s[..percent]); - } + && FE80_RE.is_match(s) + && IFACE_RE.is_match(&s[(percent + 1)..]) + { + return verify_ipv6(&s[..percent]); + } verify_ip(s) } -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel