问题
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:
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.
来源:https://stackoverflow.com/questions/40410190/permission-denied-error-despite-having-all-needed-file-system-permissions