* [pve-devel] [PATCH proxmox-perl-rs 02/15] pve-rs: tfa: clippy: unnecessary `pub(self)`
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 03/15] pve-rs: tfa: clippy: this function has too many arguments Lukas Wagner
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pve-rs/src/tfa.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs
index 2b61344..798cdad 100644
--- a/pve-rs/src/tfa.rs
+++ b/pve-rs/src/tfa.rs
@@ -20,7 +20,7 @@ use nix::errno::Errno;
use nix::sys::stat::Mode;
use serde_json::Value as JsonValue;
-pub(self) use proxmox_tfa::api::{
+use proxmox_tfa::api::{
RecoveryState, TfaChallenge, TfaConfig, TfaResponse, TfaUserData, U2fConfig,
UserChallengeAccess, WebauthnConfig,
};
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 03/15] pve-rs: tfa: clippy: this function has too many arguments
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 02/15] pve-rs: tfa: clippy: unnecessary `pub(self)` Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 04/15] pve-rs: tfa: clippy: question mark operator is useless here Lukas Wagner
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pve-rs/src/tfa.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs
index 798cdad..6650151 100644
--- a/pve-rs/src/tfa.rs
+++ b/pve-rs/src/tfa.rs
@@ -409,6 +409,7 @@ mod export {
methods::list_tfa(&this.inner.lock().unwrap(), authid, top_level_allowed)
}
+ #[allow(clippy::too_many_arguments)]
#[export]
fn api_add_tfa_entry(
#[raw] raw_this: Value,
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 04/15] pve-rs: tfa: clippy: question mark operator is useless here
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 02/15] pve-rs: tfa: clippy: unnecessary `pub(self)` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 03/15] pve-rs: tfa: clippy: this function has too many arguments Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 05/15] pve-rs: tfa: clippy: borrowed expression impls the required traits Lukas Wagner
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pve-rs/src/tfa.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs
index 6650151..9381ef0 100644
--- a/pve-rs/src/tfa.rs
+++ b/pve-rs/src/tfa.rs
@@ -490,11 +490,11 @@ mod export {
#[export]
fn api_unlock_tfa(#[raw] raw_this: Value, userid: &str) -> Result<bool, Error> {
let this: &Tfa = (&raw_this).try_into()?;
- Ok(methods::unlock_and_reset_tfa(
+ methods::unlock_and_reset_tfa(
&mut this.inner.lock().unwrap(),
&UserAccess::new(&raw_this)?,
userid,
- )?)
+ )
}
#[derive(serde::Serialize)]
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 05/15] pve-rs: tfa: clippy: borrowed expression impls the required traits
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (2 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 04/15] pve-rs: tfa: clippy: question mark operator is useless here Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 06/15] pve-rs: tfa: clippy: accessing first element with `.get(0)` Lukas Wagner
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pve-rs/src/tfa.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs
index 9381ef0..7588d6d 100644
--- a/pve-rs/src/tfa.rs
+++ b/pve-rs/src/tfa.rs
@@ -1048,7 +1048,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
fn remove(&self, userid: &str) -> Result<bool, Error> {
let path = challenge_data_path(userid, self.is_debug());
- match std::fs::remove_file(&path) {
+ match std::fs::remove_file(path) {
Ok(()) => Ok(true),
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(false),
Err(err) => Err(err.into()),
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 06/15] pve-rs: tfa: clippy: accessing first element with `.get(0)`
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (3 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 05/15] pve-rs: tfa: clippy: borrowed expression impls the required traits Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 07/15] pve-rs: tfa: clippy: redundant slicing of the whole range Lukas Wagner
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pve-rs/src/tfa.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs
index 7588d6d..7ead18c 100644
--- a/pve-rs/src/tfa.rs
+++ b/pve-rs/src/tfa.rs
@@ -831,7 +831,7 @@ fn generate_legacy_config(out: &mut perlmod::Hash, config: &TfaConfig) {
let users = Hash::new();
for (user, data) in &config.users {
- if let Some(u2f) = data.u2f.get(0) {
+ if let Some(u2f) = data.u2f.first() {
let data = Hash::new();
data.insert(
"publicKey",
@@ -850,7 +850,7 @@ fn generate_legacy_config(out: &mut perlmod::Hash, config: &TfaConfig) {
continue;
}
- if let Some(totp) = data.totp.get(0) {
+ if let Some(totp) = data.totp.first() {
let totp = &totp.entry;
let config = Hash::new();
config.insert("digits", Value::new_int(isize::from(totp.digits())));
@@ -873,7 +873,7 @@ fn generate_legacy_config(out: &mut perlmod::Hash, config: &TfaConfig) {
continue;
}
- if let Some(entry) = data.yubico.get(0) {
+ if let Some(entry) = data.yubico.first() {
let mut keys = entry.entry.clone();
for entry in data.yubico.iter().skip(1) {
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 07/15] pve-rs: tfa: clippy: redundant slicing of the whole range
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (4 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 06/15] pve-rs: tfa: clippy: accessing first element with `.get(0)` Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 08/15] pve-rs: tfa: clippy: stripping a prefix manually Lukas Wagner
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pve-rs/src/tfa.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs
index 7ead18c..1054169 100644
--- a/pve-rs/src/tfa.rs
+++ b/pve-rs/src/tfa.rs
@@ -802,7 +802,7 @@ fn usize_from_perl(value: JsonValue) -> Option<usize> {
fn trim_ascii_whitespace_start(data: &[u8]) -> &[u8] {
match data.iter().position(|&c| !c.is_ascii_whitespace()) {
Some(from) => &data[from..],
- None => &data[..],
+ None => data,
}
}
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 08/15] pve-rs: tfa: clippy: stripping a prefix manually
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (5 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 07/15] pve-rs: tfa: clippy: redundant slicing of the whole range Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 09/15] pmg-rs: tfa: clippy: unnecessary `pub(self)` Lukas Wagner
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pve-rs/src/tfa.rs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs
index 1054169..66dca3d 100644
--- a/pve-rs/src/tfa.rs
+++ b/pve-rs/src/tfa.rs
@@ -736,10 +736,10 @@ fn decode_old_oath_entry(
let key = unsafe { std::str::from_utf8_unchecked(key) };
// See PVE::OTP::oath_verify_otp
- let key = if key.starts_with("v2-0x") {
- hex::decode(&key[5..]).map_err(|_| format_err!("bad v2 hex key in oath entry"))?
- } else if key.starts_with("v2-") {
- base32::decode(base32::Alphabet::RFC4648 { padding: true }, &key[3..])
+ let key = if let Some(key) = key.strip_prefix("v2-0x") {
+ hex::decode(key).map_err(|_| format_err!("bad v2 hex key in oath entry"))?
+ } else if let Some(key) = key.strip_prefix("v2-") {
+ base32::decode(base32::Alphabet::RFC4648 { padding: true }, key)
.ok_or_else(|| format_err!("bad v2 base32 key in oath entry"))?
} else if key.len() == 16 {
base32::decode(base32::Alphabet::RFC4648 { padding: true }, key)
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 09/15] pmg-rs: tfa: clippy: unnecessary `pub(self)`
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (6 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 08/15] pve-rs: tfa: clippy: stripping a prefix manually Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 10/15] pmg-rs: tfa: clippy: question mark operator is useless here Lukas Wagner
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pmg-rs/src/tfa.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pmg-rs/src/tfa.rs b/pmg-rs/src/tfa.rs
index 1924488..0680baa 100644
--- a/pmg-rs/src/tfa.rs
+++ b/pmg-rs/src/tfa.rs
@@ -17,7 +17,7 @@ use anyhow::{bail, format_err, Error};
use nix::errno::Errno;
use nix::sys::stat::Mode;
-pub(self) use proxmox_tfa::api::{
+use proxmox_tfa::api::{
RecoveryState, TfaChallenge, TfaConfig, TfaResponse, U2fConfig, UserChallengeAccess,
WebauthnConfig,
};
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 10/15] pmg-rs: tfa: clippy: question mark operator is useless here
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (7 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 09/15] pmg-rs: tfa: clippy: unnecessary `pub(self)` Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 11/15] pmg-rs: tfa: clippy: this function has too many arguments Lukas Wagner
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pmg-rs/src/tfa.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pmg-rs/src/tfa.rs b/pmg-rs/src/tfa.rs
index 0680baa..a97d171 100644
--- a/pmg-rs/src/tfa.rs
+++ b/pmg-rs/src/tfa.rs
@@ -441,11 +441,11 @@ mod export {
#[export]
fn api_unlock_tfa(#[raw] raw_this: Value, userid: &str) -> Result<bool, Error> {
let this: &Tfa = (&raw_this).try_into()?;
- Ok(methods::unlock_and_reset_tfa(
+ methods::unlock_and_reset_tfa(
&mut this.inner.lock().unwrap(),
&UserAccess::new(&raw_this)?,
userid,
- )?)
+ )
}
#[derive(serde::Serialize)]
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 11/15] pmg-rs: tfa: clippy: this function has too many arguments
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (8 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 10/15] pmg-rs: tfa: clippy: question mark operator is useless here Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 12/15] pmg-rs: tfa: clippy: the borrowed expression implements the required traits Lukas Wagner
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pmg-rs/src/tfa.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/pmg-rs/src/tfa.rs b/pmg-rs/src/tfa.rs
index a97d171..928b50b 100644
--- a/pmg-rs/src/tfa.rs
+++ b/pmg-rs/src/tfa.rs
@@ -361,6 +361,7 @@ mod export {
methods::list_tfa(&this.inner.lock().unwrap(), authid, top_level_allowed)
}
+ #[allow(clippy::too_many_arguments)]
#[export]
fn api_add_tfa_entry(
#[raw] raw_this: Value,
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 12/15] pmg-rs: tfa: clippy: the borrowed expression implements the required traits
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (9 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 11/15] pmg-rs: tfa: clippy: this function has too many arguments Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 13/15] pmg-rs: tfa: clippy: useless conversion to the same type Lukas Wagner
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pmg-rs/src/tfa.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pmg-rs/src/tfa.rs b/pmg-rs/src/tfa.rs
index 928b50b..af69721 100644
--- a/pmg-rs/src/tfa.rs
+++ b/pmg-rs/src/tfa.rs
@@ -178,7 +178,7 @@ mod export {
#[try_from_ref] this: &Tfa,
) -> Result<(Option<String>, Option<super::WebauthnConfig>), Error> {
Ok(match this.inner.lock().unwrap().webauthn.clone() {
- Some(config) => (Some(hex::encode(&config.digest())), Some(config.into())),
+ Some(config) => (Some(hex::encode(config.digest())), Some(config.into())),
None => (None, None),
})
}
@@ -644,7 +644,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
fn remove(&self, userid: &str) -> Result<bool, Error> {
let path = challenge_data_path(userid, self.is_debug());
- match std::fs::remove_file(&path) {
+ match std::fs::remove_file(path) {
Ok(()) => Ok(true),
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(false),
Err(err) => Err(err.into()),
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 13/15] pmg-rs: tfa: clippy: useless conversion to the same type
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (10 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 12/15] pmg-rs: tfa: clippy: the borrowed expression implements the required traits Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 14/15] pmg-rs: acme: clippy: reference is immediately deref'd by the compiler Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 15/15] pmg-rs: acme: simplify acount config saving Lukas Wagner
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pmg-rs/src/tfa.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pmg-rs/src/tfa.rs b/pmg-rs/src/tfa.rs
index af69721..4e9ce8f 100644
--- a/pmg-rs/src/tfa.rs
+++ b/pmg-rs/src/tfa.rs
@@ -178,7 +178,7 @@ mod export {
#[try_from_ref] this: &Tfa,
) -> Result<(Option<String>, Option<super::WebauthnConfig>), Error> {
Ok(match this.inner.lock().unwrap().webauthn.clone() {
- Some(config) => (Some(hex::encode(config.digest())), Some(config.into())),
+ Some(config) => (Some(hex::encode(config.digest())), Some(config)),
None => (None, None),
})
}
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 14/15] pmg-rs: acme: clippy: reference is immediately deref'd by the compiler
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (11 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 13/15] pmg-rs: tfa: clippy: useless conversion to the same type Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 15/15] pmg-rs: acme: simplify acount config saving Lukas Wagner
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pmg-rs/src/acme.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pmg-rs/src/acme.rs b/pmg-rs/src/acme.rs
index 7ea78c6..e2e7327 100644
--- a/pmg-rs/src/acme.rs
+++ b/pmg-rs/src/acme.rs
@@ -403,7 +403,7 @@ pub mod export {
this.inner
.lock()
.unwrap()
- .revoke_certificate(&data, reason)?;
+ .revoke_certificate(data, reason)?;
Ok(())
}
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [pve-devel] [PATCH proxmox-perl-rs 15/15] pmg-rs: acme: simplify acount config saving
2024-06-20 11:50 [pve-devel] [PATCH proxmox-perl-rs 01/15] pve-rs: apt: clippy: the borrowed expression implements the required traits Lukas Wagner
` (12 preceding siblings ...)
2024-06-20 11:50 ` [pve-devel] [PATCH proxmox-perl-rs 14/15] pmg-rs: acme: clippy: reference is immediately deref'd by the compiler Lukas Wagner
@ 2024-06-20 11:50 ` Lukas Wagner
13 siblings, 0 replies; 15+ messages in thread
From: Lukas Wagner @ 2024-06-20 11:50 UTC (permalink / raw)
To: pve-devel
We already depend on proxmox_sys, so we can just use
`replace_file`. Fixing a clippy warning (missing
truncate setting for OpenOptions) is an added benefit.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
pmg-rs/src/acme.rs | 62 ++++++++++------------------------------------
1 file changed, 13 insertions(+), 49 deletions(-)
diff --git a/pmg-rs/src/acme.rs b/pmg-rs/src/acme.rs
index e2e7327..ca24f17 100644
--- a/pmg-rs/src/acme.rs
+++ b/pmg-rs/src/acme.rs
@@ -2,11 +2,9 @@
//!
//! The functions in here are perl bindings.
-use std::fs::OpenOptions;
-use std::io::{self, Write};
-use std::os::unix::fs::OpenOptionsExt;
-
use anyhow::{format_err, Error};
+use nix::sys::stat::Mode;
+use proxmox_sys::fs::CreateOptions;
use serde::{Deserialize, Serialize};
use proxmox_acme::types::AccountData as AcmeAccountData;
@@ -90,19 +88,12 @@ impl Inner {
let _account = self
.client
.new_account(contact, tos_agreed, rsa_bits, eab_creds)?;
- let file = OpenOptions::new()
- .write(true)
- .create(true)
- .mode(0o600)
- .open(&account_path)
- .map_err(|err| format_err!("failed to open {:?} for writing: {}", account_path, err))?;
- self.write_to(file).map_err(|err| {
- format_err!(
- "failed to write acme account to {:?}: {}",
- account_path,
- err
- )
- })?;
+
+ let data = serde_json::to_vec(&self.to_account_data()?)?;
+ let create_options = CreateOptions::new().perm(Mode::from_bits_truncate(0o600));
+ proxmox_sys::fs::replace_file(&account_path, &data, create_options, true)
+ .map_err(|err| format_err!("failed to replace ACME account config: {err}"))?;
+
self.account_path = Some(account_path);
Ok(())
@@ -131,12 +122,6 @@ impl Inner {
})
}
- fn write_to<T: io::Write>(&mut self, out: T) -> Result<(), Error> {
- let data = self.to_account_data()?;
-
- Ok(serde_json::to_writer_pretty(out, &data)?)
- }
-
pub fn update_account<T: Serialize>(&mut self, data: &T) -> Result<(), Error> {
let account_path = self
.account_path
@@ -144,32 +129,11 @@ impl Inner {
.ok_or_else(|| format_err!("missing account path"))?;
self.client.update_account(data)?;
- let tmp_path = format!("{}.tmp", account_path);
- // FIXME: move proxmox::tools::replace_file & make_temp out into a nice *little* crate...
- let mut file = OpenOptions::new()
- .write(true)
- .create(true)
- .mode(0o600)
- .open(&tmp_path)
- .map_err(|err| format_err!("failed to open {:?} for writing: {}", tmp_path, err))?;
- self.write_to(&mut file).map_err(|err| {
- format_err!("failed to write acme account to {:?}: {}", tmp_path, err)
- })?;
- file.flush().map_err(|err| {
- format_err!("failed to flush acme account file {:?}: {}", tmp_path, err)
- })?;
-
- // re-borrow since we needed `self` as mut earlier
- let account_path = self.account_path.as_deref().unwrap();
- std::fs::rename(&tmp_path, account_path).map_err(|err| {
- format_err!(
- "failed to rotate temp file into place ({:?} -> {:?}): {}",
- &tmp_path,
- account_path,
- err
- )
- })?;
- drop(file);
+ let data = serde_json::to_vec(&self.to_account_data()?)?;
+ let create_options = CreateOptions::new().perm(Mode::from_bits_truncate(0o600));
+ proxmox_sys::fs::replace_file(account_path, &data, create_options, true)
+ .map_err(|err| format_err!("failed to replace ACME account config: {err}"))?;
+
Ok(())
}
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 15+ messages in thread