Closed arno01 closed 5 years ago
It appears to be issue with process setting itself to be undumpable. It can be worked around with following LD_PRELOAD (but note that this workaround should be probably put in proot)
#define prctl prctl_from_header
#define _GNU_SOURCE
#include <sys/prctl.h>
#include <dlfcn.h>
#undef prctl
int prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
if (option == PR_SET_DUMPABLE) {
return 0;
}
int (*real_prctl)(int, unsigned long, unsigned long, unsigned long, unsigned long);
real_prctl = dlsym(RTLD_NEXT, "prctl");
return real_prctl(option, arg2, arg3, arg4, arg5);
}
gcc forcedumpable.c -o forcedumpable.so -shared -ldl
LD_PRELOAD=`pwd`/forcedumpable.so ./proot ssh-agent
@michalbednarski thank you, it does work! :-)
Do you know by chance why proot
does not return the terminal prompt back?
$ LD_PRELOAD=`pwd`/forcedumpable.so proot ssh-agent
SSH_AUTH_SOCK=/data/data/com.termux/files/usr/tmp/ssh-ly8djYKpp36p/agent.25762; export SSH_AUTH_SOCK;
SSH_AGENT_PID=25763; export SSH_AGENT_PID;
echo Agent pid 25763;
(I'd expect proot to give the $ prompt back at this moment, but it does not)
Edit oh, that should not be a big issue, since I do not need to run it directly as proot ssh-agent
anyway. It's rather proot <flags> bash -l
, and then just ssh-agent
.
Thats by design as proot doesn't go into background (which is expected as it is usually used for interactive shell) and then stays alive as long as any process is traced.
Note that you can start proot in background when launching it from shell (proot ... &
)
Yeah, it all makes sense. Thanks for the explanation, Michal!
Filtering of PR_SET_DUMPABLE
is now done on proot side. Workaround should no longer be needed.
Command Output
with strace:
Specifications
Extra
On Android Pie (
Linux 4.9.112
, Samsung):with strace:
I've also opened it here https://github.com/proot-me/proot/issues/173