Closed tonhathuy closed 1 year ago
While it should probably not segfault, the binary while not work without the management interface from the app. It needs the management interface + app to do all the privileged operations. If you want to run OpenVPN standalone you need to compile it with Linux as target and not Android
Thanks for the response, I wonder what you mean i need to compile a version of OpenVPN with linux then run it on android using the above command. Second, where can I find OpenVPN standalone, I have seen this issue but the link doesn't exist anymore.
My binaries use TARGET_ANDROID
instead of the normal TARGET_LINUX
in OpenVPN. I meant that it needs to be compiled as a normal Linux target and not as the special Android target.
Patch to fix the segfault: https://patchwork.openvpn.net/project/openvpn2/patch/20230220131424.1749736-1-arne@rfc2549.org/
Hi @schwabe
Thank you for patch to fix segfault, but I've got a problem:
I tried rebuild your app and replace #define TARGET_ANDROID
with #define TARGET_LINUX
in config.h
file. I found that there were quite a lot of errors inside the tun file during build in Android studio , so I cloned the openVPN repo to android and built from here , it seems that inside android lacks many other tools like gcc , build-essential package to build on this.
Log in Android studio:
ld: error: undefined symbol: net_addr_v4_del
>>> referenced by tun.c:1632 (/home/huy/Downloads/OVPN/ics-openvpn/main/src/main/cpp/openvpn/src/openvpn/tun.c:1632)
>>> CMakeFiles/openvpn.dir/openvpn/src/openvpn/tun.c.o:(undo_ifconfig_ipv4)
ld: error: undefined symbol: net_addr_v6_del
Update: Yeah I built OpenVPN on termux ( I installed the necessary build tools through pkg ) . And it seems to be working and I guess I have to tweak a few places to make it work properly log :
WARNING: linker: /data/data/com.termux/files/home/openvpn-2.6.0/src/openvpn/openvpn: unsupported flags DT_FLAGS_1=0x8000001
2023-02-22 10:51:48 DEPRECATED OPTION: --cipher set to 'AES-256-CBC' but missing in --data-ciphers (AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305). OpenVPN ignores --cipher for cipher negotiations.
2023-02-22 10:51:48 OpenVPN 2.6.0 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD]
2023-02-22 10:51:48 library versions: OpenSSL 3.0.8 7 Feb 2023, LZO 2.10
2023-02-22 10:51:48 WARNING: --ns-cert-type is DEPRECATED. Use --remote-cert-tls instead.
2023-02-22 10:51:48 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2023-02-22 10:51:48 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2023-02-22 10:51:48 TCP/UDP: Preserving recently used remote address: [AF_INET]XX.XXX.90.211:1194
2023-02-22 10:51:48 Socket Buffers: R=[212992->212992] S=[212992->212992]
2023-02-22 10:51:48 UDPv4 link local: (not bound)
2023-02-22 10:51:48 UDPv4 link remote: [AF_INET]XX.XXX.90.211:1194
2023-02-22 10:51:48 TLS: Initial packet from [AF_INET]XX.XXX.90.211:1194, sid=80d57a5e ae80c587
2023-02-22 10:51:48 net_route_v4_best_gw query: dst 0.0.0.0
2023-02-22 10:51:48 net_route_v4_best_gw result: via 0.0.0.0 dev
2023-02-22 10:51:49 VERIFY OK: depth=1, CN=OpenVPN CA
2023-02-22 10:51:49 VERIFY OK: nsCertType=SERVER
2023-02-22 10:51:49 VERIFY OK: depth=0, CN=OpenVPN Server
2023-02-22 10:51:49 Control Channel: TLSv1.3, cipher TLSv1.3 TLS_AES_256_GCM_SHA384, peer certificate: 2048 bit RSA, signature: RSA-SHA256
2023-02-22 10:51:49 [OpenVPN Server] Peer Connection Initiated with [AF_INET]XX.XXX.90.211:1194
2023-02-22 10:51:49 TLS: move_session: dest=TM_ACTIVE src=TM_INITIAL reinit_src=1
2023-02-22 10:51:49 TLS: tls_multi_process: initial untrusted session promoted to trusted
2023-02-22 10:51:50 SENT CONTROL [OpenVPN Server]: 'PUSH_REQUEST' (status=1)
2023-02-22 10:51:50 PUSH: Received control message: 'PUSH_REPLY,explicit-exit-notify,topology subnet,route-delay 5 30,dhcp-pre-release,dhcp-renew,dhcp-release,route-metric 101,ping 12,ping-restart 50,compress stub-v2,redirect-private def1,redirect-private bypass-dhcp,redirect-private autolocal,redirect-private bypass-dns,route-gateway 172.27.232.1,route 172.27.224.0 255.255.240.0,route 172.28.224.0 255.255.240.0,route 172.31.0.0 255.255.0.0,block-ipv6,ifconfig 172.27.233.58 255.255.248.0,peer-id 0,auth-tokenSESS_ID,cipher AES-256-GCM'
2023-02-22 10:51:50 Unrecognized option or missing or extra parameter(s) in [PUSH-OPTIONS]:4: dhcp-pre-release (2.6.0)
2023-02-22 10:51:50 Unrecognized option or missing or extra parameter(s) in [PUSH-OPTIONS]:5: dhcp-renew (2.6.0)
2023-02-22 10:51:50 Unrecognized option or missing or extra parameter(s) in [PUSH-OPTIONS]:6: dhcp-release (2.6.0)
2023-02-22 10:51:50 WARNING: You have specified redirect-gateway and redirect-private at the same time (or the same option multiple times). This is not well supported and may lead to unexpected results
2023-02-22 10:51:50 WARNING: You have specified redirect-gateway and redirect-private at the same time (or the same option multiple times). This is not well supported and may lead to unexpected results
2023-02-22 10:51:50 WARNING: You have specified redirect-gateway and redirect-private at the same time (or the same option multiple times). This is not well supported and may lead to unexpected results
2023-02-22 10:51:50 OPTIONS IMPORT: timers and/or timeouts modified
2023-02-22 10:51:50 OPTIONS IMPORT: explicit notify parm(s) modified
2023-02-22 10:51:50 OPTIONS IMPORT: compression parms modified
2023-02-22 10:51:50 OPTIONS IMPORT: --ifconfig/up options modified
2023-02-22 10:51:50 OPTIONS IMPORT: route options modified
2023-02-22 10:51:50 OPTIONS IMPORT: route-related options modified
2023-02-22 10:51:50 OPTIONS IMPORT: peer-id set
2023-02-22 10:51:50 OPTIONS IMPORT: data channel crypto options modified
2023-02-22 10:51:50 net_route_v4_best_gw query: dst 0.0.0.0
2023-02-22 10:51:50 net_route_v4_best_gw result: via 0.0.0.0 dev
2023-02-22 10:51:50 ROUTE_GATEWAY 0.0.0.0
2023-02-22 10:51:50 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
2023-02-22 10:51:50 Exiting due to fatal error
The undefined errors are there since the android version does not compile things like networking_sitnl.c
as those files are not needed for the Android version. You will have to modify the CmakeLists.txt
to include them.
As for the error of /dev/net/tun
. Yes. that is expected. Android is not a normal Linux and things work different there. I think at least older Android version still had /dev/tun
. But Android's routing/forward is configured COMPLETLY different from a typical Linux system so be prepared that OpenVPN'x route and ifconfig commands wreak havoc.
To make issues more manageable, I would appreciate it if you fill out the following details as applicable:
General information
Description of the issue
I'm tried to start vpn via openvpn core ( compiled binary ) . I used below command but
Segmentation fault
error occurred. I tried running the ovpn file with your application, it works perfectly fine. Please tell me if I am missing a step or is it not possible to launch the vpn.LD_LIBRARY_PATH=/data/app/de.blinkt.openvpn-1/lib/x86_64/ ./cache/c_pie_openvpn.x86_64 --config /assets/client.ovpn
Log (if applicable)
Logcat :