tree-wide: fix needless borrows
found and fixed via clippy Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
@ -109,7 +109,7 @@ impl CachedUserInfo {
|
||||
required_privs: u64,
|
||||
partial: bool,
|
||||
) -> Result<(), Error> {
|
||||
let privs = self.lookup_privs(&auth_id, path);
|
||||
let privs = self.lookup_privs(auth_id, path);
|
||||
let allowed = if partial {
|
||||
(privs & required_privs) != 0
|
||||
} else {
|
||||
|
@ -45,7 +45,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
}
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(DATASTORE_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(DATASTORE_CFG_FILENAME, config)?;
|
||||
replace_backup_config(DATASTORE_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
}
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(DOMAINS_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(DOMAINS_CFG_FILENAME, config)?;
|
||||
replace_backup_config(DOMAINS_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
|
||||
/// Save the configuration file
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(DRIVE_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(DRIVE_CFG_FILENAME, config)?;
|
||||
replace_backup_config(DRIVE_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ impl KeyDerivationConfig {
|
||||
// estimated scrypt memory usage is 128*r*n*p
|
||||
openssl::pkcs5::scrypt(
|
||||
passphrase,
|
||||
&salt,
|
||||
salt,
|
||||
*n, *r, *p,
|
||||
1025*1024*1024,
|
||||
&mut key,
|
||||
@ -52,7 +52,7 @@ impl KeyDerivationConfig {
|
||||
|
||||
openssl::pkcs5::pbkdf2_hmac(
|
||||
passphrase,
|
||||
&salt,
|
||||
salt,
|
||||
*iter,
|
||||
openssl::hash::MessageDigest::sha256(),
|
||||
&mut key,
|
||||
@ -235,10 +235,10 @@ impl KeyConfig {
|
||||
openssl::symm::decrypt_aead(
|
||||
cipher,
|
||||
&derived_key,
|
||||
Some(&iv),
|
||||
Some(iv),
|
||||
b"",
|
||||
&enc_data,
|
||||
&tag,
|
||||
enc_data,
|
||||
tag,
|
||||
).map_err(|err| {
|
||||
match self.hint {
|
||||
Some(ref hint) => {
|
||||
|
@ -59,7 +59,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
|
||||
/// Save the configuration file
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(MEDIA_POOL_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(MEDIA_POOL_CFG_FILENAME, config)?;
|
||||
replace_backup_config(MEDIA_POOL_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ pub fn parse_address_or_cidr(cidr: &str) -> Result<(String, Option<u8>, bool), E
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
if let Some(caps) = CIDR_V4_REGEX.captures(&cidr) {
|
||||
if let Some(caps) = CIDR_V4_REGEX.captures(cidr) {
|
||||
let address = &caps[1];
|
||||
if let Some(mask) = caps.get(2) {
|
||||
let mask = u8::from_str_radix(mask.as_str(), 10)?;
|
||||
@ -104,7 +104,7 @@ pub fn parse_address_or_cidr(cidr: &str) -> Result<(String, Option<u8>, bool), E
|
||||
} else {
|
||||
Ok((address.to_string(), None, false))
|
||||
}
|
||||
} else if let Some(caps) = CIDR_V6_REGEX.captures(&cidr) {
|
||||
} else if let Some(caps) = CIDR_V6_REGEX.captures(cidr) {
|
||||
let address = &caps[1];
|
||||
if let Some(mask) = caps.get(2) {
|
||||
let mask = u8::from_str_radix(mask.as_str(), 10)?;
|
||||
|
@ -46,7 +46,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
}
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(REMOTE_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(REMOTE_CFG_FILENAME, config)?;
|
||||
crate::replace_backup_config(REMOTE_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
}
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(SYNC_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(SYNC_CFG_FILENAME, config)?;
|
||||
replace_backup_config(SYNC_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
}
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(TAPE_JOB_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(TAPE_JOB_CFG_FILENAME, config)?;
|
||||
replace_backup_config(TAPE_JOB_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ pub fn verify_secret(tokenid: &Authid, secret: &str) -> Result<(), Error> {
|
||||
let data = read_file()?;
|
||||
match data.get(tokenid) {
|
||||
Some(hashed_secret) => {
|
||||
proxmox_sys::crypt::verify_crypt_pw(secret, &hashed_secret)
|
||||
proxmox_sys::crypt::verify_crypt_pw(secret, hashed_secret)
|
||||
},
|
||||
None => bail!("invalid API token"),
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
|
||||
/// Save the configuration file
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(TRAFFIC_CONTROL_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(TRAFFIC_CONTROL_CFG_FILENAME, config)?;
|
||||
replace_backup_config(TRAFFIC_CONTROL_CFG_FILENAME, raw.as_bytes())?;
|
||||
|
||||
// increase traffic control version
|
||||
@ -88,7 +88,7 @@ mod test {
|
||||
timeframe mon..wed 8:00-16:30
|
||||
timeframe fri 9:00-12:00
|
||||
";
|
||||
let data = CONFIG.parse(TRAFFIC_CONTROL_CFG_FILENAME, &content)?;
|
||||
let data = CONFIG.parse(TRAFFIC_CONTROL_CFG_FILENAME, content)?;
|
||||
eprintln!("GOT {:?}", data);
|
||||
|
||||
Ok(())
|
||||
|
@ -117,7 +117,7 @@ pub fn cached_config() -> Result<Arc<SectionConfigData>, Error> {
|
||||
}
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(USER_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(USER_CFG_FILENAME, config)?;
|
||||
replace_backup_config(USER_CFG_FILENAME, raw.as_bytes())?;
|
||||
|
||||
// increase user version
|
||||
|
@ -46,7 +46,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
}
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(VERIFICATION_CFG_FILENAME, &config)?;
|
||||
let raw = CONFIG.write(VERIFICATION_CFG_FILENAME, config)?;
|
||||
replace_backup_config(VERIFICATION_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user