Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
meowjesty committed Jul 23, 2024
1 parent 6e3bbf8 commit c47a48a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions mirrord/layer/src/exec_hooks/hooks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{ffi::CString, os::unix::process::parent_id};

use base64::prelude::*;
use libc::{c_char, c_int, FD_CLOEXEC};
use libc::{c_char, c_int};
use mirrord_layer_macro::hook_guard_fn;
use tracing::Level;

Expand All @@ -13,17 +13,15 @@ use crate::{
detour::Detour,
hooks::HookManager,
replace,
socket::{hooks::FN_FCNTL, UserSocket, SHARED_SOCKETS_ENV_VAR},
socket::{UserSocket, SHARED_SOCKETS_ENV_VAR},
SOCKETS,
};

#[tracing::instrument(level = Level::TRACE, ret)]
fn shared_sockets() -> Vec<(i32, UserSocket)> {
SOCKETS
.iter()
.map(|inner| {
(*inner.key(), UserSocket::clone(inner.value()))
})
.map(|inner| (*inner.key(), UserSocket::clone(inner.value())))
.collect::<Vec<_>>()
}

Expand All @@ -40,11 +38,7 @@ pub(crate) fn execve(env_vars: Detour<Argv>) -> Detour<*const *const c_char> {
let encoded = bincode::encode_to_vec(shared_sockets(), bincode::config::standard())
.map(|bytes| BASE64_URL_SAFE.encode(bytes))?;

if !encoded.is_empty() {
env_vars.push(CString::new(format!("{SHARED_SOCKETS_ENV_VAR}={encoded}"))?);
}

tracing::info!("too many args? {:?}", env_vars.len() > 256);
env_vars.push(CString::new(format!("{SHARED_SOCKETS_ENV_VAR}={encoded}"))?);

Detour::Success(env_vars.leak())
}
Expand Down

0 comments on commit c47a48a

Please sign in to comment.