开发者

Linux device node accessible to only certain process groups

I have a device driver module which does a register_chardev(). In the driver open() function I wish to be able to determine the pid or pgid of the process which is attempting to open the device node. Is this possible? Does anyone have any ideas of where to begin?

I am assuming this should somewhat secure my device node to only allow my applications to use it, since you cannot migrate a process to a new process group u开发者_如何转开发nless they are in the same session.


The kernel isn't the right place to make this kind of policy decision - the correct place to set the permissions on who can open the device node is by setting the usual ownership and permissions on the device node file in the filesystem.

If you really have your heart set on it, current->pid is the PID, current->tgid is the thread group id and current->group_leader->pid is the PGID.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜