Compare commits

3 Commits

Author SHA1 Message Date
00afc7130b use relative path for shared_memory_dependency 2025-10-30 14:10:09 +01:00
830dc9671c add default value for NUM_AGENTS 2025-10-29 16:22:42 +01:00
af0d286549 hardcode path 2025-10-27 13:53:16 +01:00
5 changed files with 18 additions and 12 deletions

1
Cargo.lock generated
View File

@@ -26,7 +26,6 @@ checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[package]]
name = "shared_memory_heap"
version = "0.1.0"
source = "git+https://gitea.rixxc.de/rixxc/shared_memory_heap.git#ef9bcc94fb04d7191514a249c78d608d2f7cb9a6"
dependencies = [
"libc",
]

View File

@@ -8,4 +8,4 @@ edition = "2021"
[dependencies]
anyhow = "1.0.82"
libc = "0.2.153"
shared_memory_heap = { git = "https://gitea.rixxc.de/rixxc/shared_memory_heap.git" }
shared_memory_heap = { path = "../shared_memory_heap/" }

View File

@@ -47,9 +47,9 @@ impl Agent {
if child == 0 {
// child
close(0);
close(1);
close(2);
// close(0);
// close(1);
// close(2);
let path = CString::new(agent_path.as_os_str().as_encoded_bytes()).unwrap();
let data_fd = CString::new(data_fd.to_string()).unwrap();

View File

@@ -13,7 +13,7 @@ static ED25519AGENT: LazyLock<Vec<Mutex<Agent>>> = LazyLock::new(|| {
let keyfile_path =
std::env::var("ED25519_KEYFILE").expect("Ed25519_KEYFILE environment variable missing");
let num_agents: usize = std::env::var("NUM_AGENTS")
.expect("NUM_AGENTS environment variable missing")
.unwrap_or("1".to_string())
.parse()
.expect("NUM_AGENTS should be an integer");
let mut agents = Vec::with_capacity(num_agents);

View File

@@ -2,13 +2,17 @@ pub use shared_memory_heap::sharedptr::SharedPtr;
use crate::agent::Agent;
use std::{
ops::Deref, path::Path, sync::{LazyLock, Mutex}
ops::Deref,
path::Path,
sync::{LazyLock, Mutex},
};
static X25519AGENT: LazyLock<Mutex<Agent>> = LazyLock::new(|| {
let agent_path = std::env::var("X25519_AGENT_PATH").expect("X25519_AGENT_PATH environment variable missing");
let keyfile_path = std::env::var("X25519_KEYFILE").expect("X25519_KEYFILE environment variable missing");
let agent = unsafe { Agent::new(Path::new(&agent_path), Path::new(&keyfile_path)).expect("Agent failed to start") };
let agent_path = "agent_harness";
let keyfile_path = "/etc/x25519-agent/keyfile";
let agent = unsafe {
Agent::new(Path::new(&agent_path), Path::new(&keyfile_path)).expect("Agent failed to start")
};
Mutex::new(agent)
});
@@ -94,7 +98,10 @@ pub fn x25519(sk: &X25519PrivKey, pk: &X25519PubKey) -> X25519SharedKey {
let mut agent = X25519AGENT.lock().unwrap();
unsafe {
agent.perform_ipc_call(2, &[out.0.get_offset(), sk.0.get_offset(), pk.0.get_offset()]);
agent.perform_ipc_call(
2,
&[out.0.get_offset(), sk.0.get_offset(), pk.0.get_offset()],
);
}
drop(agent);