“权限被拒绝";尽管具有所有必需的文件系统权限,仍然发生错误 [英] "permission denied" error despite having all needed file system permissions
问题描述
我在android上,使用adb shell
来解决我的应用程序与文件系统有关的问题.使用tinyalsa时遇到权限错误,因此我希望调查所涉及的目录.
I'm on an android, using adb shell
to troubleshoot an issue which my app has with the file system. I'm encountering a permissions error when using tinyalsa, so I wish to investigate the directories involved.
cannot open device '/dev/snd/pcmC1D0c': Permission denied
如果我先su
然后再stat
路径中的每个项目,则外壳程序会告诉我以下权限:
If I su
and then stat
each item in the path, the shell tells me the following permissions:
/ (755/drwxr-xr-x)
/dev/ (755/drwxr-xr-x)
/dev/snd/ (755/drwxr-xr-x)
但是,如果我尝试在没有su
的情况下尝试stat /dev/snd
,则会得到Permission denied
.
If I try to stat /dev/snd
without su
, however, I get Permission denied
.
为什么会这样?我什至尝试过su -c 'chmod -R a+rx /dev/snd'
,但这没什么区别.
Why would this be? I've even tried su -c 'chmod -R a+rx /dev/snd'
, but that makes no difference.
推荐答案
我在这方面了解不多,但是看来SELinux正在干扰.如果禁用它:
I don't know much in this area, but it appears that SELinux is interfering. If you disable it:
# In a "su" adb shell
printf 0 > /sys/fs/selinux/enforce
...您可以体验以root用户身份运行stat
时看到的权限.
...you can experience the permissions that you see when you run stat
as root.
这可能不是最佳解决方案,但是它将允许您执行所需的操作.如果您只针对非常专有的用户群进行开发,我建议您阅读SELinux.
This may not be the optimal solution, but it will allow you to perform the actions needed. I recommend reading up on SELinux if you are developing for anything but a very exclusive user base.
这篇关于“权限被拒绝";尽管具有所有必需的文件系统权限,仍然发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!