From 3b156e819bccd7b1d03888c266a3703104e7ff22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 1 Jul 2024 23:56:19 +0800 Subject: [PATCH] Terminal (Linux): support ptyxis version detection --- src/detection/terminalshell/terminalshell.c | 17 +++++++++++++++++ .../terminalshell/terminalshell_linux.c | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 28bd7c591..f4e4ccdef 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -499,6 +499,20 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) //kitty 0.21.2 created by Kovid Goyal return getExeVersionGeneral(exe, version); } + +static bool getTerminalVersionPtyxis(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdOut(version, (char* const[]) { + "ptyxis", + "--version", + NULL + }) != NULL) + return false; + + ffStrbufSubstrBeforeFirstC(version, '\n'); + ffStrbufSubstrAfterFirstC(version, ' '); + return true; +} #endif #ifdef _WIN32 @@ -595,6 +609,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe ) return getTerminalVersionUrxvt(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "ptyxis-agent")) + return getTerminalVersionPtyxis(exe, version); + #endif #ifdef _WIN32 diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 40a1ee600..61c05a82b 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -331,6 +331,8 @@ static void setTerminalInfoDetails(FFTerminalResult* result) ffStrbufEqualS(&result->processName, "rxvt") ) ffStrbufInitStatic(&result->prettyName, "rxvt-unicode"); + else if(ffStrbufStartsWithS(&result->processName, "ptyxis-agent")) + ffStrbufInitStatic(&result->prettyName, "Ptyxis"); #elif defined(__APPLE__)