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:
Fabian Grünbichler
2021-12-30 12:57:37 +01:00
parent a0c69902c8
commit 9a37bd6c84
104 changed files with 238 additions and 241 deletions

View File

@ -330,7 +330,7 @@ async fn order_certificate(
for auth_url in &order.data.authorizations {
task_log!(worker, "Getting authorization details from '{}'", auth_url);
let mut auth = acme.get_authorization(&auth_url).await?;
let mut auth = acme.get_authorization(auth_url).await?;
let domain = match &mut auth.identifier {
Identifier::Dns(domain) => domain.to_ascii_lowercase(),
@ -442,7 +442,7 @@ async fn request_validation(
validation_url: &str,
) -> Result<(), Error> {
task_log!(worker, "Triggering validation");
acme.request_challenge_validation(&validation_url).await?;
acme.request_challenge_validation(validation_url).await?;
task_log!(worker, "Sleeping for 5 seconds");
tokio::time::sleep(Duration::from_secs(5)).await;
@ -450,7 +450,7 @@ async fn request_validation(
loop {
use proxmox_acme_rs::authorization::Status;
let auth = acme.get_authorization(&auth_url).await?;
let auth = acme.get_authorization(auth_url).await?;
match auth.status {
Status::Pending => {
task_log!(worker, "Status is still 'pending', trying again in 10 seconds");

View File

@ -282,7 +282,7 @@ fn create_datastore_mount_unit(
what: &str,
) -> Result<String, Error> {
let mut mount_unit_name = proxmox_sys::systemd::escape_unit(&mount_point, true);
let mut mount_unit_name = proxmox_sys::systemd::escape_unit(mount_point, true);
mount_unit_name.push_str(".mount");
let mount_unit_path = format!("/etc/systemd/system/{}", mount_unit_name);

View File

@ -55,9 +55,9 @@ pub fn read_etc_resolv_conf() -> Result<Value, Error> {
for line in data.lines() {
if let Some(caps) = DOMAIN_REGEX.captures(&line) {
if let Some(caps) = DOMAIN_REGEX.captures(line) {
result["search"] = Value::from(&caps[1]);
} else if let Some(caps) = SERVER_REGEX.captures(&line) {
} else if let Some(caps) = SERVER_REGEX.captures(line) {
nscount += 1;
if nscount > 3 { continue };
let nameserver = &caps[1];

View File

@ -121,7 +121,7 @@ async fn termproxy(cmd: Option<String>, rpcenv: &mut dyn RpcEnvironment) -> Resu
let ticket = Ticket::new(ticket::TERM_PREFIX, &Empty)?.sign(
private_auth_key(),
Some(&tools::ticket::term_aad(&userid, &path, port)),
Some(&tools::ticket::term_aad(userid, path, port)),
)?;
let mut command = Vec::new();
@ -161,7 +161,7 @@ async fn termproxy(cmd: Option<String>, rpcenv: &mut dyn RpcEnvironment) -> Resu
arguments.push(&fd_string);
arguments.extend_from_slice(&[
"--path",
&path,
path,
"--perm",
"Sys.Console",
"--authport",
@ -293,7 +293,7 @@ fn upgrade_to_websocket(
Ticket::<Empty>::parse(ticket)?.verify(
crate::auth_helpers::public_auth_key(),
ticket::TERM_PREFIX,
Some(&tools::ticket::term_aad(&userid, "/system", port)),
Some(&tools::ticket::term_aad(userid, "/system", port)),
)?;
let (ws, response) = WebSocket::new(parts.headers.clone())?;

View File

@ -17,7 +17,7 @@ use pbs_config::network::{self, NetworkConfig};
use proxmox_rest_server::WorkerTask;
fn split_interface_list(list: &str) -> Result<Vec<String>, Error> {
let value = NETWORK_INTERFACE_ARRAY_SCHEMA.parse_property_string(&list)?;
let value = NETWORK_INTERFACE_ARRAY_SCHEMA.parse_property_string(list)?;
Ok(value.as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_string()).collect())
}

View File

@ -176,9 +176,9 @@ fn get_service_state(
bail!("unknown service name '{}'", service);
}
let status = get_full_service_state(&service)?;
let status = get_full_service_state(service)?;
Ok(json_service_state(&service, status))
Ok(json_service_state(service, status))
}
fn run_service_command(service: &str, cmd: &str, auth_id: Authid) -> Result<Value, Error> {

View File

@ -24,9 +24,9 @@ use pbs_config::CachedUserInfo;
fn check_job_privs(auth_id: &Authid, user_info: &CachedUserInfo, upid: &UPID) -> Result<(), Error> {
match (upid.worker_type.as_str(), &upid.worker_id) {
("verificationjob", Some(workerid)) => {
if let Some(captures) = VERIFICATION_JOB_WORKER_ID_REGEX.captures(&workerid) {
if let Some(captures) = VERIFICATION_JOB_WORKER_ID_REGEX.captures(workerid) {
if let Some(store) = captures.get(1) {
return user_info.check_privs(&auth_id,
return user_info.check_privs(auth_id,
&["datastore", store.as_str()],
PRIV_DATASTORE_VERIFY,
true);
@ -34,7 +34,7 @@ fn check_job_privs(auth_id: &Authid, user_info: &CachedUserInfo, upid: &UPID) ->
}
},
("syncjob", Some(workerid)) => {
if let Some(captures) = SYNC_JOB_WORKER_ID_REGEX.captures(&workerid) {
if let Some(captures) = SYNC_JOB_WORKER_ID_REGEX.captures(workerid) {
let remote = captures.get(1);
let remote_store = captures.get(2);
let local_store = captures.get(3);
@ -42,7 +42,7 @@ fn check_job_privs(auth_id: &Authid, user_info: &CachedUserInfo, upid: &UPID) ->
if let (Some(remote), Some(remote_store), Some(local_store)) =
(remote, remote_store, local_store) {
return check_pull_privs(&auth_id,
return check_pull_privs(auth_id,
local_store.as_str(),
remote.as_str(),
remote_store.as_str(),
@ -51,15 +51,15 @@ fn check_job_privs(auth_id: &Authid, user_info: &CachedUserInfo, upid: &UPID) ->
}
},
("garbage_collection", Some(workerid)) => {
return user_info.check_privs(&auth_id,
&["datastore", &workerid],
return user_info.check_privs(auth_id,
&["datastore", workerid],
PRIV_DATASTORE_MODIFY,
true)
},
("prune", Some(workerid)) => {
return user_info.check_privs(&auth_id,
return user_info.check_privs(auth_id,
&["datastore",
&workerid],
workerid],
PRIV_DATASTORE_MODIFY,
true);
},
@ -73,7 +73,7 @@ fn check_job_privs(auth_id: &Authid, user_info: &CachedUserInfo, upid: &UPID) ->
fn check_job_store(upid: &UPID, store: &str) -> bool {
match (upid.worker_type.as_str(), &upid.worker_id) {
(workertype, Some(workerid)) if workertype.starts_with("verif") => {
if let Some(captures) = VERIFICATION_JOB_WORKER_ID_REGEX.captures(&workerid) {
if let Some(captures) = VERIFICATION_JOB_WORKER_ID_REGEX.captures(workerid) {
if let Some(jobstore) = captures.get(1) {
return store == jobstore.as_str();
}
@ -82,7 +82,7 @@ fn check_job_store(upid: &UPID, store: &str) -> bool {
}
}
("syncjob", Some(workerid)) => {
if let Some(captures) = SYNC_JOB_WORKER_ID_REGEX.captures(&workerid) {
if let Some(captures) = SYNC_JOB_WORKER_ID_REGEX.captures(workerid) {
if let Some(local_store) = captures.get(3) {
return store == local_store.as_str();
}
@ -112,7 +112,7 @@ fn check_task_access(auth_id: &Authid, upid: &UPID) -> Result<(), Error> {
// or task == job which the user/token could have configured/manually executed
user_info.check_privs(auth_id, &["system", "tasks"], PRIV_SYS_AUDIT, false)
.or_else(|_| check_job_privs(&auth_id, &user_info, upid))
.or_else(|_| check_job_privs(auth_id, &user_info, upid))
.or_else(|_| bail!("task access not allowed"))
}
}
@ -250,7 +250,7 @@ async fn get_task_status(
fn extract_upid(param: &Value) -> Result<UPID, Error> {
let upid_str = pbs_tools::json::required_string_param(&param, "upid")?;
let upid_str = pbs_tools::json::required_string_param(param, "upid")?;
upid_str.parse::<UPID>()
}
@ -569,7 +569,7 @@ const UPID_API_SUBDIRS: SubdirMap = &sorted!([
pub const UPID_API_ROUTER: Router = Router::new()
.get(&list_subdirs_api_method!(UPID_API_SUBDIRS))
.delete(&API_METHOD_STOP_TASK)
.subdirs(&UPID_API_SUBDIRS);
.subdirs(UPID_API_SUBDIRS);
pub const ROUTER: Router = Router::new()
.get(&API_METHOD_LIST_TASKS)