开发者

how to prevent opening serial port on linux by foreign application?

In case of "bug" in port driver using l开发者_Go百科ocking is not acceptable.


So you need to lock out other processes from opening a device file, but file locking is unacceptable...

Well, you could rename the device file to something non-standard, so everything that tries to open /dev/ttyS0 won't step on your toes.


Assuming you are guarding against mistaken opens by "foreign" binaries: in your driver's open() method, match the name of the opening binary (current->comm). And allow opens only for your binary.

This can, of course be easily circumvented (by renaming a foreign binary.)


Or you can change the properties of the corresponding dev file, only granting access to a custom group you are a member of. If you want the serial port to be accessible to any user, this might not work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜