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

Updating remote process capture FAQ #44

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

guyzmo
Copy link

@guyzmo guyzmo commented Jan 5, 2017

fixes #43

processes by giving it a special capability (you'll need `libcap2-bin` installed):

```
sudo setcap cap_sys_ptrace=eip /usr/bin/lldb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test the plugin with this set? I ask this because the plugin is loading the debugger as a python library, and there is no /usr/bin/lldb process when running the plugin. So I can't see this change affecting the plugin.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, I wrongly assumed the python library was still using the lldb binary… I'm changing this… At least that still applies to lldb-server ☺

I'll rewrite it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least that still applies to lldb-server

Don't you think running lldb-server as root is more "secure" than escalating its capability? Or is there a significant usability improvement by doing that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it's a matter of personal choice, but yes I believe that it's still better from a security perspective, as running lldb-server as root gives a lot more than just remote process capture (basically r/w anywhere). So I believe it's worth noting in the FAQ

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as running lldb-server as root gives a lot more than just remote process capture

But that's limited to the text editor's scope. Another process cannot jack into the lldb-server process to access its capabilities. But changing the capability of lldb-server executable itself grants any process (that can execute it) with similar capabilities.

Copy link
Collaborator

@critiqjo critiqjo Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, there is an option to limit the number of clients to just one. (Not sure if it is the default.)

Update: Yes, it is the default. Passing --server option will make it fork for every incoming connection.

sudo setcap cap_sys_ptrace=eip /usr/bin/lldb
```

This cannot be reverted, so you can use user permissions to restrict the risk of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot be reverted

What do you mean? Doesn't this work:

sudo setcap -r /usr/bin/lldb

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but it's what I've read on the ubuntu forum link you've given and some other place… but because it was late, I've been a bit too fast at proposing the change ☺

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like -r works, just tested. removing that 👌

fixed a few stupid things, and added better tips (included some viml)
@guyzmo
Copy link
Author

guyzmo commented Jan 5, 2017

ok I've updated the FAQ with a section on what I was originally asking: how to work with interactive processes. Then I've exposed the different ways to attach a process, and then how to automate that with a bit of viml.

Basically stuff that I would have love to read in the FAQ 😀

Copy link
Collaborator

@critiqjo critiqjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like the FAQ is growing too large. I might move some parts to another md file later. For now, looks good except the minor changes suggested.

the ptrace system call:

```
sysct -w kernel.yama.ptrace_scope=0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sysctl (l missing)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

So please read [the following FAQ entry on how to run a remote server][remote-debug].

Instead of disabling `ptrace` scoping globally, you can as well disable it just for
the `lldb-server` executable (on debian, you'll need `libcap2-bin` installed):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just stating "you'll need libcap2" is enough, I think. Anyway, libcap2 is a prerequisite for coreutils, so it's very unlikely to not have it installed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

in your `vimrc`:

```
function! LLSpawn(target)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of starting lldb-server here, I think it would be cleaner to let them start it elsewhere, and make this function take a port number as argument.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made both work

Copy link
Collaborator

@critiqjo critiqjo Jan 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made both work

That wasn't my intention. I primarily wanted to make the snippet short. If FAQ is too long, people will be even more reluctant to read it. Besides, it still has syntax errors.

I'll fix them and merge it when I get free. Probably after a month.

scoping in any way suggested [above][attach-process].

[attach-process]:https://github.com/guyzmo/lldb.nvim/blob/patch-1/README.md#how-do-I-attach-to-a-running-process
[remote-debug]:https://github.com/guyzmo/lldb.nvim/blob/patch-1/README.md#remote-debugging-does-not-work
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong links! Just the id part should work:

[attach-process]: #how-do-I-attach-to-a-running-process
[remote-debug]: #remote-debugging-does-not-work

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

added syntax argument, fixed typos
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.

How to debug an interactive command line application?
2 participants