microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Sudo elevation not working with gdb #4196

Open letmaik opened 5 years ago

letmaik commented 5 years ago

Type: Debugger

Describe the bug

When trying to attach with gdb it correctly asks "Superuser access is required to attach to a process. Attaching as superuser can potentially harm your computer. Do you want to continue? [y/N]". After typing "y" and enter, I get the following:

==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/bin/gdb' as the super user
Multiple identities can be used for authentication:
 1.  ...
 2.  ...
 ...
Choose identity to authenticate as (1-16): [1] + Stopped (tty input)        /usr/bin/pkexec "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-hrnsnxv9.sdc" 1>"/tmp/Microsoft-MIEngine-Out-prn74k9m.v7c"
You have stopped jobs.

It immediately stops and doesn't let me select an identity. It says "Running" in the debug view but this seems not correct, also nothing happens when pressing pause.

To Reproduce Please include a code sample and launch.json configuration.

        {
            "name": "Attach",
            "type": "cppdbg",
            "request": "attach",
            "MIMode": "gdb",
            "program": "...",
            "processId": "${command:pickProcess}",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },

Additional context If applicable, please include logging by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json Add any other context about the problem here including log or error messages in your Debug Console or Output windows.

pieandcakes commented 5 years ago

This sounds like #4133. Are you able to change your ptrace_scope value?

letmaik commented 5 years ago

The original ptrace_scope value was 1. When I change it to 0 with echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope everything works.

pieandcakes commented 5 years ago

That can be the work around for now. I think with pkexec allowing selection of profiles to elevate to needs some more investigation.

saareliad commented 2 years ago

The original ptrace_scope value was 1. When I change it to 0 with echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope everything works.

Unfortunately, it does not solve the problem for me. I get prompt by pkexec and it doe not wait for the next prompts

sean-mcmanus commented 2 years ago

Has anyone found a workaround for this? We're hitting this with our shared test machine that has multiple accounts.