Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions proxy_agent/src/acl/linux_acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ use std::path::PathBuf;
pub fn acl_directory(dir_to_acl: PathBuf) -> Result<()> {
let dir_str = misc_helpers::path_to_string(&dir_to_acl);
logger::write(format!(
"acl_directory: start to set root-only permission to folder {}.",
dir_str
"acl_directory: start to set root-only permission to folder {dir_str}."
));

match chown(&dir_to_acl, Some(Uid::from_raw(0)), Some(Gid::from_raw(0))) {
Ok(_) => logger::write(format!(
"acl_directory: successfully set root-only permission to folder {}.",
dir_str
"acl_directory: successfully set root-only permission to folder {dir_str}."
)),
Err(e) => {
logger::write(format!(
"acl_directory: failed to set root-only permission to folder {}. Error: {:?}",
dir_str, e
"acl_directory: failed to set root-only permission to folder {dir_str}. Error: {e:?}"
));
}
}
Expand All @@ -31,13 +28,11 @@ pub fn acl_directory(dir_to_acl: PathBuf) -> Result<()> {
let permissions = fs::Permissions::from_mode(0o700);
match fs::set_permissions(dir_to_acl, permissions) {
Ok(_) => logger::write(format!(
"acl_directory: successfully set root-only permission to folder {}.",
dir_str
"acl_directory: successfully set root-only permission to folder {dir_str}."
)),
Err(e) => {
logger::write(format!(
"acl_directory: failed to set root-only permission to folder {}. Error: {:?}",
dir_str, e
"acl_directory: failed to set root-only permission to folder {dir_str}. Error: {e:?}"
));
}
}
Expand Down
22 changes: 8 additions & 14 deletions proxy_agent/src/acl/windows_acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ pub fn acl_directory(dir_to_acl: PathBuf) -> Result<()> {
.map_err(|e| Error::Acl(AclErrorType::Sid(BUILDIN_ADMIN_SID.to_string()), e))?;

logger::write(format!(
"acl_directory: removing all the remaining access rules for folder {}.",
dir_str
"acl_directory: removing all the remaining access rules for folder {dir_str}."
));

match acl.all() {
Ok(entries) => {
logger::write(format!(
"acl_directory: get '{}' access rules for folder {}.",
entries.len(),
dir_str
"acl_directory: get '{len}' access rules for folder {dir_str}.",
len = entries.len()
));
for entry in entries {
match entry.sid {
Expand All @@ -55,12 +53,11 @@ pub fn acl_directory(dir_to_acl: PathBuf) -> Result<()> {
None, // remove all, including inherited permissions
) {
Ok(r) => {
logger::write(format!("acl_directory: removed '{}' entry.", r));
logger::write(format!("acl_directory: removed '{r}' entry."));
}
Err(e) => {
logger::write_warning(format!(
"acl_directory: remove_entry failed with error '{}' entry.",
e
"acl_directory: remove_entry failed with error '{e}' entry.",
));
}
}
Expand All @@ -77,8 +74,7 @@ pub fn acl_directory(dir_to_acl: PathBuf) -> Result<()> {
}

logger::write(format!(
"acl_directory: Adding new access rules for the target directory {}.",
dir_str
"acl_directory: Adding new access rules for the target directory {dir_str}."
));
let flags = (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE) as u8;
let mask = FULL_CONTROL;
Expand All @@ -90,8 +86,7 @@ pub fn acl_directory(dir_to_acl: PathBuf) -> Result<()> {
) {
Ok(r) => {
logger::write(format!(
"acl_directory: Adding new access rules for sid {} with result {}.",
LOCAL_SYSTEM_SID, r
"acl_directory: Adding new access rules for sid {LOCAL_SYSTEM_SID} with result {r}.",
));
}
Err(e) => {
Expand All @@ -109,8 +104,7 @@ pub fn acl_directory(dir_to_acl: PathBuf) -> Result<()> {
) {
Ok(r) => {
logger::write(format!(
"acl_directory: Adding new access rules for sid {} with result {}.",
BUILDIN_ADMIN_SID, r
"acl_directory: Adding new access rules for sid {BUILDIN_ADMIN_SID} with result {r}."
));
}
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion proxy_agent/src/common/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static CURRENT_SYS_INFO: Lazy<(u64, usize)> = Lazy::new(|| {
let ram_in_mb = match windows::get_memory_in_mb() {
Ok(ram) => ram,
Err(e) => {
logger::write_error(format!("get_memory_in_mb failed: {}", e));
logger::write_error(format!("get_memory_in_mb failed: {e}"));
0
}
};
Expand Down
21 changes: 9 additions & 12 deletions proxy_agent/src/common/hyper_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ where
Err(e) => Err(Error::Hyper(
HyperErrorType::Deserialize(
format!(
"Failed to xml deserialize response body with content_type {} from: {} with error {}",
content_type, body_string, e
"Failed to xml deserialize response body with content_type {content_type} from: {body_string} with error {e}"
)
),
)),
Expand All @@ -178,8 +177,7 @@ where
Err(e) => Err(Error::Hyper(
HyperErrorType::Deserialize(
format!(
"Failed to json deserialize response body with {} from: {} with error {}",
content_type, body_string, e
"Failed to json deserialize response body with {content_type} from: {body_string} with error {e}"
)
),
)),
Expand Down Expand Up @@ -246,8 +244,7 @@ pub fn build_request(
match request_builder.body(boxed_body) {
Ok(r) => Ok(r),
Err(e) => Err(Error::Hyper(HyperErrorType::RequestBuilder(format!(
"Failed to build request body: {}",
e
"Failed to build request body: {e}"
)))),
}
}
Expand All @@ -268,7 +265,7 @@ where
let mut sender = build_http_sender(host, port, log_fun).await?;
sender.send_request(request).await.map_err(|e| {
Error::Hyper(HyperErrorType::Custom(
format!("Failed to send request to {}", full_url),
format!("Failed to send request to {full_url}"),
e,
))
})
Expand All @@ -285,12 +282,12 @@ where
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
F: FnMut(String) + Send + 'static,
{
let addr = format!("{}:{}", host, port);
let addr = format!("{host}:{port}");
let stream = match TcpStream::connect(addr.to_string()).await {
Ok(tcp_stream) => tcp_stream,
Err(e) => {
return Err(Error::Io(
format!("Failed to open TCP connection to {}", addr),
format!("Failed to open TCP connection to {addr}"),
e,
))
}
Expand All @@ -301,13 +298,13 @@ where
.await
.map_err(|e| {
Error::Hyper(HyperErrorType::Custom(
format!("Failed to establish connection to {}", addr),
format!("Failed to establish connection to {addr}"),
e,
))
})?;
tokio::task::spawn(async move {
if let Err(err) = conn.await {
log_fun(format!("Connection failed: {:?}", err));
log_fun(format!("Connection failed: {err:?}"));
}
});

Expand Down Expand Up @@ -428,7 +425,7 @@ fn get_path_and_canonicalized_parameters(url: &Uri) -> (String, String) {
pairs.insert(
// add the query parameter value for sorting,
// just in case of duplicate keys by value lexicographically in ascending order.
format!("{}{}", key, value),
format!("{key}{value}"),
(key.to_lowercase(), value.to_string()),
);
}
Expand Down
4 changes: 2 additions & 2 deletions proxy_agent/src/common/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ pub fn write_serial_console_log(message: String) {
{
Ok(mut serial_console) => {
if serial_console.write_all(message.as_bytes()).is_err() {
eprintln!("Failed to write to serial console: {}", message);
eprintln!("Failed to write to serial console: {message}");
}
}
Err(e) => {
eprintln!("Failed to open serial console: {}", e);
eprintln!("Failed to open serial console: {e}");
}
}
}
7 changes: 2 additions & 5 deletions proxy_agent/src/host_clients/wire_server_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl WireServerClient {
Err(e) => {
return Err(Error::WireServer(
WireServerErrorType::Telemetry,
format!("Failed to send request {}", e),
format!("Failed to send request {e}"),
))
}
};
Expand All @@ -91,10 +91,7 @@ impl WireServerClient {
if !status.is_success() {
return Err(Error::WireServer(
WireServerErrorType::Telemetry,
format!(
"Failed to get response from {}, status code: {}",
url, status
),
format!("Failed to get response from {url}, status code: {status}"),
));
}

Expand Down
Loading
Loading