diff --git a/frontend/client/src/main/java/de/amosproj3/ziofa/client/Client.kt b/frontend/client/src/main/java/de/amosproj3/ziofa/client/Client.kt index 44b2a987..90ceb3bc 100644 --- a/frontend/client/src/main/java/de/amosproj3/ziofa/client/Client.kt +++ b/frontend/client/src/main/java/de/amosproj3/ziofa/client/Client.kt @@ -70,7 +70,7 @@ interface Client { suspend fun getConfiguration(): Configuration - suspend fun setConfiguration(configuration: Configuration): UInt + suspend fun setConfiguration(configuration: Configuration) suspend fun getOdexFiles(pid: UInt): Flow diff --git a/frontend/client/src/mock/java/de/amosproj3/ziofa/client/RustClient.kt b/frontend/client/src/mock/java/de/amosproj3/ziofa/client/RustClient.kt index 1eacc63d..ca3b9231 100644 --- a/frontend/client/src/mock/java/de/amosproj3/ziofa/client/RustClient.kt +++ b/frontend/client/src/mock/java/de/amosproj3/ziofa/client/RustClient.kt @@ -77,10 +77,8 @@ object RustClient : Client { return configuration } - override suspend fun setConfiguration(configuration: Configuration): UInt { + override suspend fun setConfiguration(configuration: Configuration) { this.configuration = configuration - - return 0u } override suspend fun initStream(): Flow = flow { diff --git a/frontend/client/src/real/java/de.amosproj3.ziofa.client/RustClient.kt b/frontend/client/src/real/java/de.amosproj3.ziofa.client/RustClient.kt index 286d6e45..690f23bf 100644 --- a/frontend/client/src/real/java/de.amosproj3.ziofa.client/RustClient.kt +++ b/frontend/client/src/real/java/de.amosproj3.ziofa.client/RustClient.kt @@ -104,7 +104,7 @@ class RustClient(private val inner: uniffi.client.Client) : Client { override suspend fun getConfiguration(): Configuration = inner.getConfiguration().into() - override suspend fun setConfiguration(configuration: Configuration): UInt = + override suspend fun setConfiguration(configuration: Configuration) = inner.setConfiguration(configuration.into()) override suspend fun getOdexFiles(pid: UInt): Flow = diff --git a/rust/backend/daemon/src/server.rs b/rust/backend/daemon/src/server.rs index b3fca3ba..283158f1 100644 --- a/rust/backend/daemon/src/server.rs +++ b/rust/backend/daemon/src/server.rs @@ -25,7 +25,7 @@ use shared::{ counter::counter_server::CounterServer, ziofa::{ ziofa_server::{Ziofa, ZiofaServer}, - CheckServerResponse, ProcessList, SetConfigurationResponse, + CheckServerResponse, ProcessList, }, }; use std::path::PathBuf; @@ -93,7 +93,7 @@ impl Ziofa for ZiofaImpl { async fn set_configuration( &self, request: Request, - ) -> Result, Status> { + ) -> Result, Status> { let config = request.into_inner(); // TODO: Implement function 'validate' @@ -109,7 +109,7 @@ impl Ziofa for ZiofaImpl { .update_from_config(ebpf_guard.deref_mut(), &config) .map_err(EbpfErrorWrapper::from)?; - Ok(Response::new(SetConfigurationResponse { response_type: 0 })) + Ok(Response::new(())) } type InitStreamStream = Receiver>; diff --git a/rust/backend/daemon/tests/base.rs b/rust/backend/daemon/tests/base.rs index fe53dde2..fe5bd501 100644 --- a/rust/backend/daemon/tests/base.rs +++ b/rust/backend/daemon/tests/base.rs @@ -63,18 +63,17 @@ async fn set_get_configuration() { let mut client = setup().await; let default_config = Configuration { uprobes: vec![], - vfs_write: Some(VfsWriteConfig { entries: std::collections::HashMap::new() }), - sys_sendmsg: Some(SysSendmsgConfig { entries: std::collections::HashMap::new() }), + vfs_write: Some(VfsWriteConfig { + entries: std::collections::HashMap::new(), + }), + sys_sendmsg: Some(SysSendmsgConfig { + entries: std::collections::HashMap::new(), + }), }; - assert_eq!( - client - .set_configuration(default_config.clone()) - .await - .expect("should work") - .into_inner() - .response_type, - 0 - ); + client + .set_configuration(default_config.clone()) + .await + .expect("should work"); let res_config = client .get_configuration(()) @@ -82,8 +81,5 @@ async fn set_get_configuration() { .expect("should work") .into_inner(); - assert_eq!( - res_config, - default_config - ); + assert_eq!(res_config, default_config); } diff --git a/rust/client/src/bin/cli.rs b/rust/client/src/bin/cli.rs index dfbc2983..aefb5867 100644 --- a/rust/client/src/bin/cli.rs +++ b/rust/client/src/bin/cli.rs @@ -92,21 +92,18 @@ async fn sendmsg(client: &mut Client, pid: u32) -> Result<()> { } async fn set_config(client: &mut Client) -> Result<()> { - println!( - "response_type: {}", - client - .set_configuration(Configuration { - uprobes: vec![], - vfs_write: Some(VfsWriteConfig { - entries: std::collections::HashMap::new(), - }), - sys_sendmsg: Some(SysSendmsgConfig { - entries: std::collections::HashMap::new(), - }), - }) - .await? - ); - + client + .set_configuration(Configuration { + uprobes: vec![], + vfs_write: Some(VfsWriteConfig { + entries: std::collections::HashMap::new(), + }), + sys_sendmsg: Some(SysSendmsgConfig { + entries: std::collections::HashMap::new(), + }), + }) + .await?; + println!("Success"); Ok(()) } @@ -187,7 +184,7 @@ pub async fn main() -> anyhow::Result<()> { } Commands::Odex { pid, silent } => { get_odex_files(&mut client, pid, silent).await?; - }, + } Commands::Symbols { odex_file, silent } => { get_symbols(&mut client, odex_file, silent).await?; } diff --git a/rust/client/src/bindings.rs b/rust/client/src/bindings.rs index d4a9dfa8..bce060f8 100644 --- a/rust/client/src/bindings.rs +++ b/rust/client/src/bindings.rs @@ -137,7 +137,7 @@ impl Client { Ok(self.0.lock().await.get_configuration().await?) } - pub async fn set_configuration(&self, configuration: Configuration) -> Result { + pub async fn set_configuration(&self, configuration: Configuration) -> Result<()> { Ok(self.0.lock().await.set_configuration(configuration).await?) } diff --git a/rust/client/src/client.rs b/rust/client/src/client.rs index 4aeafdad..a3e2020b 100644 --- a/rust/client/src/client.rs +++ b/rust/client/src/client.rs @@ -101,13 +101,9 @@ impl Client { Ok(self.ziofa.get_configuration(()).await?.into_inner()) } - pub async fn set_configuration(&mut self, configuration: Configuration) -> Result { - Ok(self - .ziofa - .set_configuration(configuration) - .await? - .into_inner() - .response_type) + pub async fn set_configuration(&mut self, configuration: Configuration) -> Result<()> { + self.ziofa.set_configuration(configuration).await?; + Ok(()) } pub async fn init_stream(&mut self) -> Result>> { diff --git a/rust/shared/proto/ziofa.proto b/rust/shared/proto/ziofa.proto index b76addf5..11d8bc7f 100644 --- a/rust/shared/proto/ziofa.proto +++ b/rust/shared/proto/ziofa.proto @@ -15,8 +15,8 @@ service Ziofa { rpc CheckServer(google.protobuf.Empty) returns (CheckServerResponse) {} rpc ListProcesses(google.protobuf.Empty) returns (ProcessList) {} - rpc GetConfiguration(google.protobuf.Empty) returns (config.Configuration){} - rpc SetConfiguration(config.Configuration) returns (SetConfigurationResponse){} + rpc GetConfiguration(google.protobuf.Empty) returns (config.Configuration) {} + rpc SetConfiguration(config.Configuration) returns (google.protobuf.Empty) {} rpc InitStream(google.protobuf.Empty) returns (stream Event) {} // all Responses genereated by the ebpf-programms are send via this stream @@ -64,10 +64,6 @@ message CmdlineData { repeated string args = 1; } -message SetConfigurationResponse{ - uint32 response_type = 1; -} - message Event { oneof event_data { VfsWriteEvent vfs_write = 1;