Sudo

理智,即使我添加了 udev 規則也找不到我的掃描器(權限問題),除非我使用 sudo

  • April 6, 2021

我的 AIO 列印機/掃描器是佳能 E400,但我無法以普通使用者身份找到我的掃描器,只能使用 sudo 和掃描也可以使用 sudo

~ cincinmasukmangkok@orangepizero
< sane-find-scanner                                                                                                       <<<

 # sane-find-scanner will now attempt to detect your scanner. If the
 # result is different from what you expected, first make sure your
 # scanner is powered up and properly connected to your computer.

 # No SCSI scanners found. If you expected something different, make sure that
 # you have loaded a kernel SCSI driver for your SCSI adapter.

could not open USB device 0x1d6b/0x0001 at 008:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 005:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 007:001: Access denied (insufficient permissions)
could not open USB device 0x04a9/0x177a at 004:007: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 004:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 006:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 003:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 002:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 001:001: Access denied (insufficient permissions)
 # No USB scanners found. If you expected something different, make sure that
 # you have loaded a kernel driver for your USB host controller and have setup
 # the USB system correctly. See man sane-usb for details.

 # Not checking for parallel port scanners.

 # Most Scanners connected to the parallel port or other proprietary ports
 # can't be detected by this program.

 # You may want to run this program as root to find all devices. Once you
 # found the scanner devices, be sure to adjust access permissions as
 # necessary.

~ cincinmasukmangkok@orangepizero
> scanimage -L

No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).

~ cincinmasukmangkok@orangepizero
< sudo sane-find-scanner                                                                                                  <<< [sudo] password for cincinmasukmangkok:

 # sane-find-scanner will now attempt to detect your scanner. If the
 # result is different from what you expected, first make sure your
 # scanner is powered up and properly connected to your computer.

 # No SCSI scanners found. If you expected something different, make sure that
 # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x04a9 [Canon], product=0x177a [E400 series]) at libusb:004:007
 # Your USB scanner was (probably) detected. It may or may not be supported by
 # SANE. Try scanimage -L and read the backend's manpage.

 # Not checking for parallel port scanners.

 # Most Scanners connected to the parallel port or other proprietary ports
 # can't be detected by this program.

~ cincinmasukmangkok@orangepizero
< sudo scanimage --format=png > test.png                                                                                  <<<

~ cincinmasukmangkok@orangepizero 33s
>

我還將它添加到 /lib/udev/rules.d/60-libsane.rules 但它仍然不起作用

SUBSYSTEM=="usb", ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="177a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

通過將此行添加到/lib/udev/rules.d/10-local.rules

ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="177a", MODE="0666"

我將帳戶添加到scanner, lp, saned。但僅此一項並沒有幫助。我沒有任何這些規則文件,所以我的解決方案是sudo chmod -R a+w /dev/bus/usb. 然後您可以檢查是否sane-find-scanner使用普通使用者帳戶找到它。

然後我添加/創建了rc.local包含以下內容的文件:

#!/bin/sh -e
chmod -R a+w /dev/bus/usb
exit 0

然後我設置sudo chmod +x rc.local

引用自:https://unix.stackexchange.com/questions/548579