Skip to content

Commit 957de6a

Browse files
committed
docs: Add section on matchBinaries behavior with shebang scripts
Clarify that matchBinaries matches against the interpreter binary rather than the script path when executing scripts with shebangs, since the kernel executes the interpreter and passes the script as an argument. Signed-off-by: ariosmon <[email protected]>
1 parent 57410f7 commit 957de6a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/content/en/docs/concepts/tracing-policy/selectors.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,35 @@ while the whole `kprobe` call is the following:
328328
- "3"
329329
```
330330

331+
332+
### Scripts with shebangs
333+
334+
{{< caution >}}
335+
`matchBinaries` matches against the `interpreter`, not the script path.
336+
{{< /caution >}}
337+
338+
When executing a script with a shebang (`#!/usr/bin/python3`), Linux actually runs the
339+
interpreter and passes the script as an argument. Since `matchBinaries` filters based on
340+
what the kernel is executing, it sees `/usr/bin/python3`, not `/opt/scripts/my_script.py`.
341+
342+
This won't work:
343+
344+
```yaml
345+
- matchBinaries:
346+
- operator: "In"
347+
values:
348+
- "/opt/scripts/my_script.py"
349+
```
350+
351+
Match the interpreter instead:
352+
353+
```yaml
354+
- matchBinaries:
355+
- operator: "In"
356+
values:
357+
- "/usr/bin/python3"
358+
```
359+
331360
## Parent binaries filter
332361

333362
{{< warning >}}

0 commit comments

Comments
 (0)