Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for waiting using netlink #10

Merged
merged 6 commits into from
Sep 7, 2024
Merged

Add support for waiting using netlink #10

merged 6 commits into from
Sep 7, 2024

Conversation

diazona
Copy link
Owner

@diazona diazona commented Sep 6, 2024

This PR adds another method of waiting for a process to finish, using the netlink IPC system in the Linux kernel.

I've made this new method the default since it's less invasive than ptrace (the preexisting method). ptrace requires attaching to the process being traced, which can only be done by one tracing process at a time, so for example it'd be impossible to pwait for a process that's being debugged or debug a process that is being pwaited for, or to run two separate instances of pwait with the same target process. On the other hand, the netlink approach should not have any of these limitations. (Though I haven't tested that.)

This commit adds another method of waiting for a process to finish,
using the netfilter connector from the Linux kernel.
This commit adds an option to choose the method to be used for waiting,
either ptrace or netlink. It also adds a help option that displays a
moderately detailed help message.
This commit adds code to the CMakeLists file to enable both cap_sys_ptrace
and cap_net_admin when the program is installed. However it changes from
the previous version in that it only adds the capabilities to the
permitted set, not the effective set. This is so that you can run pwait
as a non-root user and use e.g. the ptrace method without acquiring
cap_net_admin, if you have some reason to think a process with
cap_net_admin would cause problems, and vice versa. (I can't really
think of a situation where this helps anything, but why not.)
This commit adds code to the CMakeLists file to enable both
cap_sys_ptrace and cap_net_admin when the program is being tested, just
like the last commit did when the program was installed.
This makes it easy to run all the tests multiple times under different
configurations.
I configured the test script to accept an environment variable that
specifies the backend method, and created two test targets in CMake
for the two methods, netlink and ptrace. This way each method appears
as a separate test.
@diazona diazona merged commit 36fe9a0 into master Sep 7, 2024
2 checks passed
@diazona diazona deleted the netlink branch September 7, 2024 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant