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

ARM toolchain statically linked binds /bin/sh #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arkanoid87
Copy link

@arkanoid87 arkanoid87 commented Apr 28, 2018

/bin/sh is not present in Android, so you have to handle iptables manually as described in
https://github.com/wangyu-/udp2raw-tunnel/blob/master/doc/android_guide.md

By applying this patch I've been able to compile and run natively in
android using termux g++ using dynamic linking, so I have -a flag
working on Android

Android, so you have to handle iptables manually as described in
https://github.com/wangyu-/udp2raw-tunnel/blob/master/doc/android_guide.md

By applying this patch I've been able to compile and run natively in
android using termux g++ using dynamic linking, so I have -a flag
working on Android
@wangyu-
Copy link
Owner

wangyu- commented Apr 29, 2018

Sorry, can you explain further on how the patch works ?

The only differences in this patch is changed pthread_cancel to pthread_kill and bind to ::bind.

The pthread_cancel will be invoked only when --keep-rule is enabled, and doestnt affect -a. And I personally think "bind and ::bind" means the same fuction.

-a doesnt work is mainly bc of popen doesnt work correctly on android.

How does this patch make a difference for -a ?

@arkanoid87
Copy link
Author

arkanoid87 commented Apr 30, 2018

It is not really a patch, it is just a notification that the -a options is not working on android not because the popen is broken, but your binaries statically links a libc version of popen that tries to execute (execve syscall) /bin/sh, that is not existing on all android devices.
You can just:
strings udp2raw | grep /bin/sh
or just
strace -ff udp2raw
to find out where the problem is

What I have done to fix the problem is compiling "make dynamic" inside a termux environment, so basically compiling using arm g++ for arm architecture and linking agains local libc, and it works flawlessy.
The modification proposed is just what I had to edit to "make dynamic" using this environment.

Not sure how to fix this using the toolchain you are using to build the binary bundle, but I think a dynamic linked version could be a better choice for android.

Thank you for working on this tools

@wangyu-
Copy link
Owner

wangyu- commented May 2, 2018

It is not really a patch, it is just a notification that the -a options is not working on android not because the popen is broken, but your binaries statically links a libc version of popen that tries to execute (execve syscall) /bin/sh, that is not existing on all android devices.

Got it, thank you for explanation.

Not sure how to fix this using the toolchain you are using to build the binary bundle, but I think a dynamic linked version could be a better choice for android.

I will try to fix this later. Or provide a dynamically linked version for android (not sure if one dynamic binary fits all android versions).

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.

2 participants