procps/man
Chris Down 4b44ab98c1 pgrep: Add support for ignoring ancestors with -A/--ignore-ancestors
pgrep and friends naturally filter their own processes from their
matches. The same issue can occur when elevating with tools like sudo or
doas, where the elevating shim layers linger as a parent and are
returned in the results. For example:

    % sudo pkill -9 -cf someelevatedcmdline
    1
    zsh: killed     sudo pkill -9 -cf someelevatedcmdline

This is a situation we've actually seen in production, where some poor
soul changes how permission management works (for example with Linux's
hidepid option), needs to elevate a pgrep or pkill call, and now ends up
with more than they bargained for. Even after the issue is noticed,
resolving it requires reinventing some of the pgrep logic, which is
unfortunate.

This commit adds the -A/--ignore-ancestors option which excludes pgrep's
ancestors from the results:

    % sudo ./pkill -9 -Acf someelevatedcmdline
    0

We looks at multiple layers of the process hierarchy because, while
things like sudo only have one layer of shimming, some mechanisms (like
those found in a typical container manager like those found in Docker or
Kubernetes) may have many more.

Signed-off-by: Chris Down <chris@chrisdown.name>
2022-08-31 07:37:10 +00:00
..
free.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
kill.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
pgrep.1 pgrep: Add support for ignoring ancestors with -A/--ignore-ancestors 2022-08-31 07:37:10 +00:00
pidof.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
pidwait.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
pkill.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
pmap.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
procio.3 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
procps_misc.3 docs: Update manpages 2022-08-29 20:56:43 +10:00
procps_pids.3 docs: Update manpages 2022-08-29 20:56:43 +10:00
procps.3 docs: Update manpages 2022-08-29 20:56:43 +10:00
ps.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
pwdx.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
skill.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
slabtop.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
snice.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
sysctl.8 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
sysctl.conf.5 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
tload.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
top.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
uptime.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
vmstat.8 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
w.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00
watch.1 build-sys: Rearrange the manual pages 2022-08-29 18:07:43 +10:00