Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
meowjesty committed Jul 23, 2024
1 parent 638f829 commit c604a85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion mirrord/layer/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! Shared place for a few types and functions that are used everywhere by the layer.
use std::{ffi::CStr, fmt::Debug, ops::Not, path::PathBuf};
use std::{
ffi::CStr,
fmt::{Debug, Display},
ops::Not,
path::PathBuf,
};

use libc::c_char;
use mirrord_intproxy_protocol::{IsLayerRequest, IsLayerRequestWithResponse, MessageId};
Expand Down Expand Up @@ -118,6 +123,8 @@ impl CheckedInto<PathBuf> for *const c_char {
}
}

// **Warning**: The implementation here expects that `*const *const c_char` be a valid,
// null-terminated list! We're using `Nul::new_unchecked`, which doesn't check for this.
impl CheckedInto<Argv> for *const *const c_char {
fn checked_into(self) -> Detour<Argv> {
let c_list = self
Expand Down
4 changes: 2 additions & 2 deletions mirrord/layer/src/exec_hooks/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{

/// Converts the [`SOCKETS`] map into a vector of pairs `(Fd, UserSocket)`, so we can rebuild
/// it as a map.
#[tracing::instrument(level = Level::TRACE, ret)]
#[mirrord_layer_macro::instrument(level = Level::TRACE, ret)]
fn shared_sockets() -> Vec<(i32, UserSocket)> {
SOCKETS
.iter()
Expand Down Expand Up @@ -95,6 +95,7 @@ pub(crate) unsafe extern "C" fn execve_detour(
argv: *const *const c_char,
envp: *const *const c_char,
) -> c_int {
// Hopefully `envp` is a properly null-terminated list.
let checked_envp = envp.checked_into();

if let Detour::Success(modified_envp) = execve(checked_envp) {
Expand All @@ -108,7 +109,6 @@ pub(crate) unsafe extern "C" fn execve_detour(
_ => FN_EXECVE(path, argv, envp),
}

// tracing::info!("Success execve!");
#[cfg(target_os = "linux")]
FN_EXECVE(path, argv, modified_envp)
} else {
Expand Down

0 comments on commit c604a85

Please sign in to comment.