Nroxy icon indicating copy to clipboard operation
Nroxy copied to clipboard

不支持 Android 10

Open nondanee opened this issue 5 years ago • 13 comments

https://developer.android.com/about/versions/10/privacy/changes#proc-net-filesystem

/proc/net 文件系统的访问权限实施了限制

https://github.com/nondanee/Nroxy/blob/7933f070216b2e2e30d36e92e390e9564107089b/app/src/main/cpp/tun2http/ip.c#L321-L333

导致 get_uid 出错

type=1400 audit(0.0:13003): avc: denied { read } for name="tcp" dev="proc" ino=4026532086 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:proc_net_tcp_udp:s0 tclass=file permissive=0

需使用 getConnectionOwnerUid(Called from C code)

https://developer.android.com/reference/android/net/ConnectivityManager.html#getConnectionOwnerUid(int,%20java.net.InetSocketAddress,%20java.net.InetSocketAddress)

参考 https://stackoverflow.com/questions/58497492/acccess-to-proc-net-tcp-in-android-q

nondanee avatar Mar 22 '20 10:03 nondanee

而且,node binary(target 29)被拦下

W sh : avc: granted { execute } for name="node" scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file
W sh : avc: denied { execute_no_trans } for path="..nroxy/files/usr/bin/node" scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=0

NewBugger avatar Mar 29 '20 13:03 NewBugger

@NewBugger 这个问题不大

nondanee avatar Mar 29 '20 13:03 nondanee

@NewBugger targetAPI 不要升 29 还是可以用的啊

nondanee avatar Mar 29 '20 13:03 nondanee

有无接口能查询 package installation dir /data/app/name-*

NewBugger avatar Mar 29 '20 16:03 NewBugger

getApplicationInfo().nativeLibraryDir

nondanee avatar Mar 29 '20 16:03 nondanee

getApplicationInfo().nativeLibraryDir

感谢。我试了一圈都返回 /data/data

———回信快的人太棒了

NewBugger avatar Mar 29 '20 16:03 NewBugger

关于 Android 10 运行 binary file 的问题

https://developer.android.com/ndk/guides/wrap-script#packaging_wrapsh 放在 src/main/resources/lib/ 中的二进制文件只在 debug 打包中可以 extract (其实 release 打包可以看到有 lib/ 有文件,但 nativeLibraryDir 里就是没有)

没搜到解决方法 https://stackoverflow.com/questions/58753615/native-libraries-not-installed-in-release-build https://issuetracker.google.com/u/0/issues/147972074

现在用了假名字 libnode.so,可以正确 extract,类似如下这个改动 (必须放在 jniLibs/,必须命名为 libxxx.so) https://github.com/devgianlu/aria2lib/pull/8/files#diff-ffa122908d75bd2b6cdb03fad044c33fR101

https://stackoverflow.com/questions/5583487/hosting-an-executable-within-android-application/58748468#58748468 用 new File(getfilesDir().getParentFile(), 'lib') 这个地址肯定不对

附: termux 相关讨论 https://github.com/termux/termux-app/issues/1072 v2ex 相关讨论 https://www.v2ex.com/t/597716

nondanee avatar Mar 29 '20 16:03 nondanee

关于 Android 10 运行 binary file 的问题

https://developer.android.com/ndk/guides/wrap-script#packaging_wrapsh 放在 src/main/resources/lib/ 中的二进制文件只在 debug 打包中可以 extract (其实 release 打包可以看到有 lib/ 有文件,但 nativeLibraryDir 里就是没有)

没搜到解决方法 https://stackoverflow.com/questions/58753615/native-libraries-not-installed-in-release-build https://issuetracker.google.com/u/0/issues/147972074

现在用了假名字 libnode.so,可以正确 extract,类似如下这个改动 (必须放在 jniLibs/,必须命名为 libxxx.so) https://github.com/devgianlu/aria2lib/pull/8/files#diff-ffa122908d75bd2b6cdb03fad044c33fR101

https://stackoverflow.com/questions/5583487/hosting-an-executable-within-android-application/58748468#58748468 用 new File(getfilesDir().getParentFile(), 'lib') 这个地址肯定不对

附: termux 相关讨论 termux/termux-app#1072 v2ex 相关讨论 https://www.v2ex.com/t/597716

jniLibs 可行,但在跑 js 报错如:

fs.js:115
    throw err;
    ^

Error: EACCES: permission denied, open '/storage/emulated/0/.../js/app-conf.js'
    at Object.openSync (fs.js:439:3)
    at Object.readFileSync (fs.js:344:35)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:20)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

NewBugger avatar Mar 29 '20 18:03 NewBugger

看了下又是 29 的限制 https://developer.android.com/training/data-storage/files/external-scoped#java 没意思,28 又不是不能用

nondanee avatar Mar 29 '20 18:03 nondanee

那估计是命令行 access file 都不行了,不管 app 有没有权限

nondanee avatar Mar 29 '20 19:03 nondanee

是把 script 位置写死了吗?那有什么用?

nondanee avatar Mar 31 '20 00:03 nondanee

都会判 我又不懂安卓开发。。。 有 notification 应该不会被杀掉

https://github.com/nondanee/Nroxy/blob/d3ecc15c43614905c08c218e8d98e22a57c6715c/app/src/main/java/dev/nondanee/nroxy/ShellService.java#L121-L125

感觉可能和这个有关系,换个位置试一下 https://www.jianshu.com/p/0aa29c9f9ab3

这周很忙,没空管

nondanee avatar Apr 01 '20 11:04 nondanee

都会判 我又不懂安卓开发。。。 有 notification 应该不会被杀掉

https://github.com/nondanee/Nroxy/blob/d3ecc15c43614905c08c218e8d98e22a57c6715c/app/src/main/java/dev/nondanee/nroxy/ShellService.java#L121-L125

感觉可能和这个有关系,换个位置试一下 https://www.jianshu.com/p/0aa29c9f9ab3

这周很忙,没空管

打扰了,可以有空再回我

NewBugger avatar Apr 01 '20 11:04 NewBugger