How to load Linux kernel modules from C code?

后端 未结 5 1524
心在旅途
心在旅途 2020-12-05 14:39

I have an application that has both two external kernel modules and a userspace daemon. I want to load the modules from the daemon code, written in C, at startup, and unload

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 15:18

    I'd recommend against the use of system() in any daemon code that runs with root permissions as it's relatively easy to exploit from a security standpoint. modprobe and rmmod are, indeed, the right tools for the job. However, it'd be a bit cleaner and much more secure to use an explicit fork() + exec() to invoke them.

提交回复
热议问题