我使用一个sudoers文件,其中(除了其他项目)包含以下几行:
homebridge ALL=(ALL) NOPASSWD: /sbin/modprobe -r bcm2835-v4l2, /sbin/modprobe bcm2835-v4l2, /sbin/reboot
%sudo ALL=(ALL) NOPASSWD: /sbin/modprobe -r bcm2835-v4l2, /sbin/modprobe bcm2835-v4l2, /sbin/reboot
Run Code Online (Sandbox Code Playgroud)
当我/usr/bin/sudo /sbin/modprobe -r bcm2835-v4l2使用普通用户执行以下命令时,无需输入密码即可正常工作。
当我也/usr/bin/sudo /sbin/modprobe -r bcm2835-v4l2使用sudoers 中提到的homebridge用户运行时,命令失败并输出:(modprobe: ERROR: ../libkmod/libkmod-module.c:793 kmod_module_remove_module() could not remove 'bcm2835_v4l2': Operation not permitted,但我也没有被要求输入密码)
我能够/usr/bin/sudo /sbin/reboot使用homebridge用户成功执行命令,并且不需要输入密码。
homebridge用户运行命令?更新 1:
不幸的是,dmesg使用homebridge用户尝试失败时不包含其他条目,但使用普通用户时包含以下内容:bcm2835-v4l2-0: unregistering video0
我切换到bcm2835_v4l2而不是bcm2835-v4l2,但这似乎对该问题没有影响。执行lsmod | grep …