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
1 change: 1 addition & 0 deletions crates/fspy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod artifact;

pub mod error;

#[cfg(not(target_env = "musl"))]
mod ipc;

#[cfg(unix)]
Expand Down
34 changes: 21 additions & 13 deletions crates/fspy/src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::{io, path::Path};

#[cfg(target_os = "linux")]
use fspy_seccomp_unotify::supervisor::supervise;
use fspy_shared::ipc::PathAccess;
#[cfg(not(target_env = "musl"))]
use fspy_shared::ipc::NativeStr;
use fspy_shared::ipc::{PathAccess, channel::channel};
use fspy_shared::ipc::{NativeStr, channel::channel};
#[cfg(target_os = "macos")]
use fspy_shared_unix::payload::Artifacts;
use fspy_shared_unix::{
Expand All @@ -24,12 +24,9 @@ use syscall_handler::SyscallHandler;
use tokio::task::spawn_blocking;
use tokio_util::sync::CancellationToken;

use crate::{
ChildTermination, Command, TrackedChild,
arena::PathAccessArena,
error::SpawnError,
ipc::{OwnedReceiverLockGuard, SHM_CAPACITY},
};
#[cfg(not(target_env = "musl"))]
use crate::ipc::{OwnedReceiverLockGuard, SHM_CAPACITY};
use crate::{ChildTermination, Command, TrackedChild, arena::PathAccessArena, error::SpawnError};

#[derive(Debug)]
pub struct SpyImpl {
Expand Down Expand Up @@ -92,8 +89,6 @@ impl SpyImpl {
#[cfg(not(target_env = "musl"))]
let (ipc_channel_conf, ipc_receiver) =
channel(SHM_CAPACITY).map_err(SpawnError::ChannelCreation)?;
#[cfg(target_env = "musl")]
let (_, ipc_receiver) = channel(SHM_CAPACITY).map_err(SpawnError::ChannelCreation)?;

let payload = Payload {
#[cfg(not(target_env = "musl"))]
Expand Down Expand Up @@ -174,9 +169,14 @@ impl SpyImpl {

// Lock the ipc channel after the child has exited.
// We are not interested in path accesses from descendants after the main child has exited.
#[cfg(not(target_env = "musl"))]
let ipc_receiver_lock_guard =
OwnedReceiverLockGuard::lock_async(ipc_receiver).await?;
let path_accesses = PathAccessIterable { arenas, ipc_receiver_lock_guard };
let path_accesses = PathAccessIterable {
arenas,
#[cfg(not(target_env = "musl"))]
ipc_receiver_lock_guard,
};

io::Result::Ok(ChildTermination { status, path_accesses })
})
Expand All @@ -188,6 +188,7 @@ impl SpyImpl {

pub struct PathAccessIterable {
arenas: Vec<PathAccessArena>,
#[cfg(not(target_env = "musl"))]
ipc_receiver_lock_guard: OwnedReceiverLockGuard,
}

Expand All @@ -196,7 +197,14 @@ impl PathAccessIterable {
let accesses_in_arena =
self.arenas.iter().flat_map(|arena| arena.borrow_accesses().iter()).copied();

let accesses_in_shm = self.ipc_receiver_lock_guard.iter_path_accesses();
accesses_in_shm.chain(accesses_in_arena)
#[cfg(not(target_env = "musl"))]
{
let accesses_in_shm = self.ipc_receiver_lock_guard.iter_path_accesses();
accesses_in_shm.chain(accesses_in_arena)
}
#[cfg(target_env = "musl")]
{
accesses_in_arena
}
}
}
1 change: 1 addition & 0 deletions crates/fspy_shared/src/ipc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(target_env = "musl"))]
pub mod channel;
mod native_path;
pub(crate) mod native_str;
Expand Down
5 changes: 4 additions & 1 deletion crates/fspy_shared_unix/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ pub struct Payload {
pub artifacts: Artifacts,

#[cfg(target_os = "linux")]
#[expect(clippy::struct_field_names, reason = "descriptive field name for clarity")]
#[cfg_attr(
not(target_env = "musl"),
expect(clippy::struct_field_names, reason = "descriptive field name for clarity")
)]
pub seccomp_payload: fspy_seccomp_unotify::payload::SeccompPayload,
}

Expand Down
Loading