简体   繁体   English

/ dev文件夹中的open()设备

[英]open() device in /dev folder

I am writing a kernel module. 我正在编写一个内核模块。 I have a utility provided by the course staff, which is ran by web2py at the browser windows. 我有一个由课程人员提供的实用程序,它由web2py在浏览器窗口运行。 The utility tries to access character devices at /dev folder, by calling open function (the utility is written in python)and gets "permission is denied" error. 该实用程序尝试通过调用open函数访问/ dev文件夹中的字符设备(该实用程序是用python编写的)并获得“权限被拒绝”错误。

I read that it is possible to run browser as a root but is depricated. 我读到可以将浏览器作为root运行但是已被删除。 Is there a way to set permissions for the devices thru the code? 有没有办法通过代码设置设备的权限?

Or I have to do it manualy each time 或者我每次都必须手工制作

There are several ways to set permissions: 有几种方法可以设置权限:

1) have a boot script (or the script that loads the module) set the permissions 1)有一个启动脚本(或加载模块的脚本)设置权限

2) write a udev rule that sets the owner/permissions when the device is created. 2)编写一个udev规则 ,在创建设备时设置所有者/权限。 The author of the kernel module can tell you how to setup the udev rules. 内核模块的作者可以告诉您如何设置udev规则。

It's more secure to use chown to set the owner to your web user, than to use chmod and open the file up to anybody. 使用chown将所有者设置为Web用户更安全,而不是使用chmod并将文件打开给任何人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM