“permission denied” error despite having all neede

2019-09-19 00:19发布

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

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)

If I try to stat /dev/snd without su, however, I get Permission denied.

Why would this be? I've even tried su -c 'chmod -R a+rx /dev/snd', but that makes no difference.

1条回答
神经病院院长
2楼-- · 2019-09-19 00:58

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

...you can experience the permissions that you see when you run stat as root.

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.

查看更多
登录 后发表回答