mathr / blog / #

USB digital camera as non-root user in Gentoo

Despite gphoto2's website saying udev is not necessary, on my system it most certainly is necessary. USB Scanner worked out of the box, but not so USB Camera. Here's the files I changed to fix it, modelled after the SANE files.


if [ -z "$DEVICE" ] ; then
  IF=`echo $DEVPATH | sed 's/\(bus\/usb\/devices\/\)\(.*\)-\(.*\)/\2/'`
  DEV=$(cat /sys/${DEVPATH}/devnum)
  DEVICE=`printf '/proc/bus/usb/%.03d/%.03d' $IF $DEV`

if [ "$ACTION" = "add" ] && [ -f "${DEVICE}" ]; then
  chown root:camera "$DEVICE"
  chmod 0660 "$DEVICE"


ACTION!="add", GOTO="usbcam_rules_end"
SUBSYSTEM!="usb_device", GOTO="usbcam_rules_end"
# Canon PowerShot A80
SYSFS{idVendor}=="04a9", SYSFS{idProduct}=="309a", MODE="660", GROUP="camera"

After these changes, and maybe some others (I was hacking for a while..) I can access my digital camera as non-root even between pluggings.

The problem was, that /proc/bus/usb/[whatever] was being set to the correct permissions out of the box, but that /dev/bus/usb/[whatever] wasn't - the udev rules correct this.