gpt4 book ai didi

android - 无法将文件推送到设备

转载 作者:行者123 更新时间:2023-12-02 16:10:40 25 4
gpt4 key购买 nike

我正在使用 adb 将文件推送到 Android 设备或从 Android 设备提取文件。这些文件是我们应用程序的配置和数据,在受限用户帐户上安装和使用。

设备用户主目录中有一个特殊的交换文件夹。典型的文件夹布局(适用于 android 6+)如下:

/storage/emulated/0             // home dir of main device user

/storage/emulated/10 // home dir of restricted user
/storage/emulated/10/exchange // our file exchange dir

最近我们发现文件交换在运行 Android 6.0.1 的 Samsung Galaxy Tab S 上无法正常工作。

// Pushing to main user works just fine
$ ./adb push barfoo.txt /storage/emulated/0
[ ?] /storage/emulated/0/barfoo.txt: 0/?

// Pushing to restricted user does not work
$ ./adb push barfoo.txt /storage/emulated/10
adb: error: failed to copy 'barfoo.txt' to '/storage/emulated/10/barfoo.txt': Permission denied

在 logcat 输出中我发现了以下线索:

audit   : type=1400 msg=audit(1496849979.822:280): avc:  denied  { write } for  pid=15762 comm="adbd" name="10" dev="sdcardfs" ino=130656 scontext=u:r:adbd:s0 tcontext=u:object_r:container_app_data_backend:s0:c522,c768 tclass=dir
audit : SEPF_SECMOBILE_6.0.1_0021
audit : type=1300 msg=audit(1496849979.822:280): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=b6bc0fc8 a2=a00c1 a3=1b6 items=1 ppid=1 ppcomm=init pid=15762 auid=4294967295 uid=2000 gid=2000 euid=2000 suid=2000 fsuid=2000 egid=2000 sgid=2000 fsgid=2000 tty=(none) ses=4294967295 comm="adbd" exe="/sbin/adbd" subj=u:r:adbd:s0 key=(null)
audit : type=1307 msg=audit(1496849979.822:280): cwd="/"
audit : type=1302 msg=audit(1496849979.822:280): item=0 name="/storage/emulated/10/barfoo.txt" inode=130656 dev=00:17 mode=040771 ouid=0 ogid=1015 rdev=00:00 obj=u:object_r:container_app_data_backend:s0:c522,c768
audit : type=1327 msg=audit(1496849979.822:280): proctitle=2F7362696E2F61646264002D2D726F6F745F7365636C6162656C3D753A723A73753A7330
audit : type=1320 msg=audit(1496849979.822:280):

据我了解,强制执行的一些 SELinux 策略会阻止我推送文件。

有人可以重现这个吗?有没有办法放松 SELinux 政策?您将如何交换文件?

最佳答案

您通过AndroidFileTransfer看到的文件实际上并不在您尝试推送的路径中。

尝试一下adb push barfoo.txt sdcard/

如果您使用 adb shellcd sdcard,我敢打赌您可以看到与 AndroidFileTransfer 中看到的相同文件。这是因为它们实际上是符号链接(symbolic link),尽管您本身没有 sdcard,但这就是使用的目录名称。

关于android - 无法将文件推送到设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44433981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com