【发布时间】:2015-02-06 19:20:39
【问题描述】:
这是我的麻烦。
事实:
1. There is a device placed in /dev/xxx.
All files under /dev/ should have permission of 700
(root permission only accessible. No ownership change and group setting)
2. Not-root user application 'A' needs to open /dev/xxx and
perform ioctl on the FD.
我想到了几个选择:
option 1) Write a stub application 'X' that can run with root.
Open /dev/xxx in 'X' and perform IPC between A and X.
由于IPC开销,这个选项实际上不是一个好选项,因为A需要非常频繁地执行ioctl。
option 2) Change the location of /dev/xxx into some other place like
/data/xxx where /data/ is accessible by 'A'
由于某种原因,如果我尝试以有效权限打开此 /data/xxx,则打开函数返回权限被拒绝错误。我不明白为什么会这样。内核是否有一些额外的保护来在 /dev 的其他地方打开设备文件?
option 3) Write a stub application 'X' that can run with root.
Open /dev/xxx in 'X' and pass the FD to 'A'.
我不确定这是一个合理的选择。我希望你能提供任何关于这个选项的 cmets。
【问题讨论】: