From e8275d1371e941755514aff5d478026ba170563f Mon Sep 17 00:00:00 2001 From: Mr-Kanister <68117355+Mr-Kanister@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:52:12 +0100 Subject: [PATCH] Change all int32 pids to uint32 to align them with the rest Signed-off-by: Mr-Kanister <68117355+Mr-Kanister@users.noreply.github.com> --- .../src/main/java/de/amosproj3/ziofa/client/Client.kt | 4 ++-- .../src/mock/java/de/amosproj3/ziofa/client/RustClient.kt | 4 ++-- rust/backend/daemon/src/procfs_utils.rs | 8 ++++---- rust/shared/proto/config.proto | 2 +- rust/shared/proto/ziofa.proto | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) 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 1c745a65..8646641c 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 @@ -18,7 +18,7 @@ data class VfsWriteConfig(val entries: Map) data class SysSendmsgConfig(val entries: Map) -data class UprobeConfig(val fnName: String, val offset: ULong, var target: String, val pid: Int?) +data class UprobeConfig(val fnName: String, val offset: ULong, var target: String, val pid: UInt?) data class JniReferencesConfig(val pids: List) @@ -40,7 +40,7 @@ sealed class Event { ) : Event() } -data class Process(val pid: Int, val ppid: Int, val state: String, val cmd: Command?) +data class Process(val pid: UInt, val ppid: UInt, val state: String, val cmd: Command?) data class StringResponse(val name: String) 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 8805f974..ee0a1612 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 @@ -63,8 +63,8 @@ object RustClient : Client { private val processes = alphabet.indices.map { Process( - pid = Random.nextUInt(1000u).toInt(), - ppid = Random.nextUInt(1000u).toInt(), + pid = Random.nextUInt(1000u), + ppid = Random.nextUInt(1000u), state = "R", cmd = Command.Comm("/bin/sh/${alphabet.substring(it, it + 1)}"), ) diff --git a/rust/backend/daemon/src/procfs_utils.rs b/rust/backend/daemon/src/procfs_utils.rs index 81eaf0de..08fb82b0 100644 --- a/rust/backend/daemon/src/procfs_utils.rs +++ b/rust/backend/daemon/src/procfs_utils.rs @@ -29,15 +29,15 @@ pub fn list_processes() -> Result { let cmdline = process.cmdline(); match cmdline { Ok(c) if !c.is_empty() => Some(ziofa::Process { - pid: stat.pid, - ppid: stat.ppid, + pid: u32::try_from(stat.pid).unwrap(), + ppid: u32::try_from(stat.ppid).unwrap(), cmd: Some(Cmd::Cmdline(CmdlineData { args: c })), state: stat.state.to_string(), }), // fallback to stat.comm if cmdline is empty _ => Some(ziofa::Process { - pid: stat.pid, - ppid: stat.ppid, + pid: u32::try_from(stat.pid).unwrap(), + ppid: u32::try_from(stat.ppid).unwrap(), cmd: Some(Cmd::Comm(stat.comm)), state: stat.state.to_string(), }), diff --git a/rust/shared/proto/config.proto b/rust/shared/proto/config.proto index 20a232be..74635dcb 100644 --- a/rust/shared/proto/config.proto +++ b/rust/shared/proto/config.proto @@ -14,7 +14,7 @@ message UprobeConfig { string fn_name = 1; uint64 offset = 2; // offset of the aya attach function string target = 3; // target of the aya attach function - optional int32 pid = 4; // pid of the aya attach function + optional uint32 pid = 4; // pid of the aya attach function } message Configuration { diff --git a/rust/shared/proto/ziofa.proto b/rust/shared/proto/ziofa.proto index 11d8bc7f..db381007 100644 --- a/rust/shared/proto/ziofa.proto +++ b/rust/shared/proto/ziofa.proto @@ -50,8 +50,8 @@ message ProcessList { } message Process { - int32 pid = 1; - int32 ppid = 2; + uint32 pid = 1; + uint32 ppid = 2; oneof cmd { CmdlineData cmdline = 3; string comm = 4;