How do I load a kernel module without root?

1.6k Views Asked by At

I'm making a program which requires a kernel module. I load this module with the following code:

cmd := exec.Command("sudo", "-S", "modprobe", "v4l2loopback")
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
err := cmd.Run()
if err != nil {
    log.Fatal("Error starting v4l2loopback: ", err.Error())
}

This works, but it requires the user to enter their password, meaning that the program has to be started in a terminal. I think there is a way to load this module, v4l2loopback, without the root password, because this program does it, but it ships with its own version of v4l2loopback and is written in C. Is there a way to do this conveniently without requiring the root password?

0

There are 0 best solutions below