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

Enable capabillity handling for attaching to process via sudo prompt and dynamic startup configuration #1034

Open
matu3ba opened this issue Sep 8, 2023 · 1 comment

Comments

@matu3ba
Copy link

matu3ba commented Sep 8, 2023

Problem Statement

Error on attach: Operation not permitted is given on attaching. My usual workflow is to use least capability debugger approach via

PID=$(pgrep PROGRAM) && sudo -E capsh --caps="cap_setpcap,cap_setuid,cap_setgid+ep cap_sys_ptrace+eip" --keep=1 --user="$USER" --addamb="cap_sys_ptrace" --shell=/usr/bin/gdb -- -p $PID
  1. It would be nice to have this scriptable in some form instead of relying on the primitive attach functionality leading to potential exploits via ptrace.
  2. Likewise, it would be much nicer to have something akind to the cli for configuration and/or a selection of multiple configurations.

Possible Solutions

  1. make start commands dynamic and let the user handle it, provide logic+logs for recently used debug commands
  2. explain how it is too clunky due to DAP + shell shortcomings too implement
  3. explain roughly how to make this work in a task runner like overseer.nvim

Considered Alternatives

Ideally, one could have multiple input and output channels to a gdb instances since ptrace only allows 1 debugger.
However, afaiu, multi clients in gdbserver do not work and other debuggers dont even provide such infrastructure, see https://sourceware.org/gdb/wiki/MultiClient.
That way one would only need to attach to such a session, ie via same pid/port.

@matu3ba matu3ba changed the title Enable capabillity handling via sudo prompt and dynamic startup configuration Enable capabillity handling for attaching to process via sudo prompt and dynamic startup configuration Sep 8, 2023
@matu3ba
Copy link
Author

matu3ba commented Sep 8, 2023

For example this script https://github.com/mfussenegger/nvim-dap/wiki/Cookbook#run-the-current-buffer-script-with-cli-arguments-and-enter-into-debug-mode only handles additional cli input, but not modifying the gdb invocation itself.

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

No branches or pull requests

1 participant