Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
aviramha committed Oct 13, 2024
1 parent 184170f commit 64c891f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
19 changes: 17 additions & 2 deletions mirrord/intproxy/protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ pub enum LayerToProxyMessage {
GetEnv(GetEnvVarsRequest),
}

/// Load Type of mirrord-layer
#[derive(Debug, Encode, Decode)]
pub enum LoadType {
/// Mirrord is loaded fully and layer should connect to agent
Full,

/// Only load sip patch required hooks
#[cfg(target_os = "macos")]
SIPOnly,

/// Skip on current process, make only a dummy connection to the internal proxy (to prevent
/// timeouts)
Skip,
}

/// Layer process information
#[derive(Encode, Decode, Debug)]
pub struct ProcessInfo {
Expand All @@ -62,8 +77,8 @@ pub struct ProcessInfo {
pub name: String,
/// Command line
pub cmdline: Vec<String>,
/// Is layer loaded?
pub loaded: bool,
/// What kind if loading was done?
pub loaded: LoadType,
}

/// Unique `layer <-> proxy` session identifier.
Expand Down
3 changes: 1 addition & 2 deletions mirrord/layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use mirrord_config::{
feature::{fs::FsModeConfig, network::incoming::IncomingMode},
LayerConfig,
};
use mirrord_intproxy_protocol::NewSessionRequest;
use mirrord_intproxy_protocol::{LoadType, NewSessionRequest};
use mirrord_layer_macro::{hook_fn, hook_guard_fn};
use mirrord_protocol::{EnvVars, GetEnvVarsRequest};
use proxy_connection::ProxyConnection;
Expand All @@ -98,7 +98,6 @@ use tracing_subscriber::{fmt::format::FmtSpan, prelude::*};

use crate::{
common::make_proxy_request_with_response, debugger_ports::DebuggerPorts, detour::DetourGuard,
load::LoadType,
};

mod common;
Expand Down
20 changes: 3 additions & 17 deletions mirrord/layer/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use mirrord_config::LayerConfig;
use mirrord_intproxy_protocol::ProcessInfo;
use mirrord_intproxy_protocol::{LoadType, ProcessInfo};
use tracing::trace;

use crate::error::LayerError;
Expand Down Expand Up @@ -146,7 +146,7 @@ impl ExecuteArgs {
.iter()
.map(|arg| arg.to_string_lossy().to_string())
.collect(),
loaded: matches!(self.load_type(config), LoadType::Full),
loaded: self.load_type(config),
}
}
}
Expand All @@ -165,7 +165,7 @@ mod sip {
use super::*;

static SIP_ONLY_PROCESSES: LazyLock<HashSet<&str>> =
LazyLock::new(|| HashSet::from(["sh", "bash", "env", "go", "dlv"]));
LazyLock::new(|| HashSet::from(["sh", "bash", "env", "go", "dlv", "cgo"]));

pub fn is_sip_only(given_process: &ExecuteArgs) -> bool {
given_process.is_build_tool()
Expand All @@ -174,20 +174,6 @@ mod sip {
}
}

/// Load Type of mirrord-layer
pub enum LoadType {
/// Mirrord is loaded fully and layer should connect to agent
Full,

/// Only load sip patch required hooks
#[cfg(target_os = "macos")]
SIPOnly,

/// Skip on current process, make only a dummy connection to the internal proxy (to prevent
/// timeouts)
Skip,
}

#[cfg(test)]
mod tests {
use rstest::rstest;
Expand Down

0 comments on commit 64c891f

Please sign in to comment.