spotsnel / tailscaled-android

Modified version to run on Android 11+ (proot + SElinux), for Termux, Userland, VScode for Android
https://tailscale.com
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Fix permission denied when reading from interfaces on Android #1

Closed gbraad closed 1 month ago

gbraad commented 1 month ago

This is related to https://github.com/Dev-Environments/VScode/issues/63; for my Android 12 (Samsung Tab S6) tablet it is not possible to run tailscaled from the ubuntu-based userspace provided by VScode for Android. It does however work on Termux (download from f-droid). The issue seems to be related to how proc/net is queried to get interface information.

$ ./tailscale_1.74.1_arm64/tailscaled --tun=userspace-networking
2024/09/28 09:57:09 netmon.New: route ip+net: netlinkrib: permission denied

Might be possible to use: https://github.com/wlynxg/anet

gbraad commented 1 month ago
gbraad commented 1 month ago

This fails: https://github.com/spotsnel/tailscaled-android/blob/c62b0732d23ec5f19c2006c14497dcaa86b92dd8/net/netmon/state.go#L454

https://github.com/spotsnel/tailscaled-android/blob/c62b0732d23ec5f19c2006c14497dcaa86b92dd8/net/netmon/state.go#L696


Cross-compile issues:

$ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CC=/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang ./tool/go install tailscale.com/cmd/tailscaled 
# runtime/cgo
gcc_android.c:6:10: fatal error: android/log.h: No such file or directory
    6 | #include <android/log.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
gbraad commented 1 month ago

Seems someone had already attempted this:

@Asutorufa I hope you can give some pointers on how you compiled this. So far I have tried a cross-compile, but ended up with errors

Asutorufa commented 1 month ago

It need android ndk, you can see:

  1. https://github.com/Asutorufa/tailscaled-socks5-android/blob/main/app/src/main/jniLibs/build.sh
  2. https://github.com/Asutorufa/tailscaled-socks5-android/blob/4000ea33088eaedfb8320b9087d59e46d51c792f/.github/workflows/android.yml#L21C1-L42C1
  3. https://github.com/Asutorufa/tailscaled-socks5-android/tree/main
  4. https://github.com/Asutorufa/tailscale
Asutorufa commented 1 month ago

You can also get it from my android apk, just decompress it, github actions https://github.com/Asutorufa/tailscaled-socks5-android/actions/runs/10776956015

gbraad commented 1 month ago

Thanks! Seems we have similar 'interests'. I'll have a look as for some reason my NDK did not function as expected; android/log.h missing... but in disk under sysroot.

What base platform did you use?

https://github.com/Asutorufa/tailscaled-socks5-android/blob/4000ea33088eaedfb8320b9087d59e46d51c792f/.github/workflows/android.yml#L12

Ubuntu, as I tried. Will check this tomorrow in more detail.

Asutorufa commented 1 month ago

My pc linux system is archlinux, it also no problem.

gbraad commented 1 month ago

@Asutorufa compiling your https://github.com/Asutorufa/tailscale/commit/787d121bfab06133dcc0452098405dc2fdfb9198 worked as expected with make buildlinuxarm for use with VScode/deVStudio and Userland. 👍