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

Unable to attach to pid #32

Open
wilzbach opened this issue Jan 23, 2014 · 7 comments
Open

Unable to attach to pid #32

wilzbach opened this issue Jan 23, 2014 · 7 comments

Comments

@wilzbach
Copy link

Commands I tried to far:
a) echo "hi" ; sleep 200; echo "hi"
b) ping "foo.com"
c) irssi

Version: 0.5 on x64.
Tested on zsh + bash.

Steps to reproduce

$ ctrl+z                     # Suspend the current process
(I also tried to use bg here)
(optional: $ jobs -l      # get the PID )
$ disown "%1"           # Detach irssi from the shell

start a new terminal:

$ reptyr  <PID>  # Get back the process

Unfortunately I get the following error:

[+] Checking for problematic process group members...
[+] Allocated scratch page: 7f011f20d000
[+] Looking up fds for tty in child.
[+] Resolved child tty: 880a
[+] Found an alias for the tty: 0
[+] Found an alias for the tty: 1
[+] Found an alias for the tty: 2
[-] Unable to open the tty in the child.
Unable to attach to pid 15021: Permission denied
@Thanatermesis
Copy link

Same problem here, using Debian Wheezy with a debian kernel (upgraded) 3.10

@Thanatermesis
Copy link

Tried also with the default kernel, I got this:

~ ❯❯❯ reptyr 8453 1
[+] Allocated scratch page: b7723000
[+] Looking up fds for tty in child.
[+] Resolved child tty: 880c
[+] Found an alias for the tty: 0
[+] Found an alias for the tty: 1
[+] Found an alias for the tty: 2
[+] Opened the new tty in the child: 3
[+] Target is not a session leader, attempting to setsid.
[+] Forked a child: 8592
[+] Change pgid for pid 8453
[+] Change pgid for pid 8579
[-] failed: Permission denied
[-] Failed to setsid: Operation not permitted
[+] Change pgid for pid 8453
[+] Change pgid for pid 8592
Unable to attach to pid 8453: Operation not permitted

@rossjones
Copy link

Did you do this as mentioned in the documentation/readme?

echo 0 > /proc/sys/kernel/yama/ptrace_scope

@Thanatermesis
Copy link

yes, also tried as root

@jensenak
Copy link

jensenak commented Jul 2, 2014

I had this problem with a pg_basebackup that I wanted to move to a screen session. I followed similar steps to those previously mentioned (suspend, background, disown, reptyr) and got "permission denied" exactly as mentioned by Thanatermesis.

Oddly, as root I was unable to assume control of the process, but as postgres, it worked. I hope that helps someone.

@Earnestly
Copy link

Note for others, even with ptrace_scope set to 0, the UIDs of both parent and child needs to be the same, thus if you try to reptyr as root (or as a different UID) a program running as your user, it will not let you.

@eromoe
Copy link

eromoe commented Jun 28, 2017

echo 0 > /proc/sys/kernel/yama/ptrace_scope donot work in a docker container
And Seems ptrace and strace not work due to security features
moby/moby#20064
moby/moby#21051

Running docker with

--security-opt="apparmor=unconfined" --cap-add=SYS_PTRACE 

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

6 participants