Skip to content

Commit bd7190c

Browse files
committed
TerminalShell (Linux): always ignore pid1
1 parent 4998258 commit bd7190c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/detection/terminalshell/terminalshell_linux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
3838
//Common programs that are between terminal and own process, but are not the shell
3939
if(
4040
// tty < 0 || //A shell should connect to a tty
41+
pid == 1 || // init/systemd
4142
ffStrbufEqualS(&result->processName, "sh") || //This prevents us from detecting things like pipes and redirects, i hope nobody uses plain `sh` as shell
4243
ffStrbufEqualS(&result->processName, "sudo") ||
4344
ffStrbufEqualS(&result->processName, "su") ||
@@ -85,6 +86,7 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
8586
{
8687
//Known shells
8788
if (
89+
pid == 1 || // init/systemd
8890
ffStrbufEqualS(&result->processName, "sudo") ||
8991
ffStrbufEqualS(&result->processName, "su") ||
9092
ffStrbufEqualS(&result->processName, "sh") ||
@@ -109,8 +111,6 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
109111
ffStrbufEqualS(&result->processName, "chezmoi") || // #762
110112
ffStrbufEqualS(&result->processName, "proot") ||
111113
ffStrbufEqualS(&result->processName, "script") ||
112-
ffStrbufEqualS(&result->processName, "init") ||
113-
ffStrbufEqualS(&result->processName, "systemd") ||
114114
#ifdef __linux__
115115
ffStrbufStartsWithS(&result->processName, "flatpak-") || // #707
116116
#endif

0 commit comments

Comments
 (0)