Skip to content

Commit f22b8ed

Browse files
committed
TerminalShell: ignore the parent process if $FFTS_IGNORE_PARENT is set to 1
Fix #1205
1 parent 893b3a6 commit f22b8ed

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/detection/terminalshell/terminalshell_linux.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,14 @@ const FFShellResult* ffDetectShell()
384384
result.tty = -1;
385385

386386
pid_t ppid = getppid();
387+
388+
const char* ignoreParent = getenv("FFTS_IGNORE_PARENT");
389+
if (ignoreParent && ffStrEquals(ignoreParent, "1"))
390+
{
391+
FF_STRBUF_AUTO_DESTROY _ = ffStrbufCreate();
392+
ffProcessGetBasicInfoLinux(ppid, &_, &ppid, NULL);
393+
}
394+
387395
ppid = getShellInfo(&result, ppid);
388396
getUserShellFromEnv(&result);
389397
setShellInfoDetails(&result);

src/detection/terminalshell/terminalshell_windows.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ const FFShellResult* ffDetectShell(void)
345345
if(!ffProcessGetInfoWindows(0, &ppid, NULL, NULL, NULL, NULL, NULL))
346346
return &result;
347347

348+
const char* ignoreParent = getenv("FFTS_IGNORE_PARENT");
349+
if (ignoreParent && ffStrEquals(ignoreParent, "1"))
350+
ffProcessGetInfoWindows(ppid, &ppid, NULL, NULL, NULL, NULL, NULL);
351+
348352
ppid = getShellInfo(&result, ppid);
349353

350354
if (result.processName.length > 0)

0 commit comments

Comments
 (0)