Thanks a lot for the udev tips.
On a ubuntu 14.04 system, I was able to prevent libgphoto from accessing my elph130 using modified /etc/udev/rules.d/40-libgphoto2-6.rules
My D10 and A540 however would still get accessed, no matter what I put in the rules. I verified that the rules were matching, but gphoto would still grab the cameras. After much headbanging, I realized these two cameras appear in /lib/udev/hwdb.d/20-libgphoto2-6.hwdb. Copying this to /etc/udev/hwdb.d/20-libgphoto2-6.hwdb, commenting out the section for each camera, and running udevadm hwdb --update seems to make them behave like the elph130. I'm not really clear why both exist, the rules are still run for the ones in hwdb. It seems like there should be a way to override the hwdb stuff in rules, but I wasn't able to find it.
A few other comments:
From my understanding of
http://www.reactivated.net/writing_udev_rules.html#syntax and testing the "," in rules is effectively an and so
ATTR{idVendor}!="04a9", ATTR{idProduct}!="3271",
will skip the rule if the camera is a Canon, or has the specified PID.
The modified rule will also skip setting the user and group, which may affect whether the device is accessible, though on my 14.04 system, my regular user account was able to access the camera.
If you want to skip all Canon's just the vendor ID should do it.
If you want to select specific PIDs, a rule like this before line 4
ATTR{idVendor}=="04a9", ATTR{idProduct}=="3265", GOTO="libgphoto2_rules_end"
seems to do the trick. You can also expand this to set the permissions, like
ATTR{idVendor}=="04a9", ATTR{idProduct}=="3265", MODE="0664", GROUP="plugdev", GOTO="libgphoto2_rules_end"
If you want to select specific cameras,
ATTR{serial}=="... serial number from chdkptp list or kernal log.."
seems to work.
One other thing is the ENV{ID_USB_INTERFACES}=="*:060101:*". I think this Identifies PTP capable devices. If you are matching by vendor, you might want to restrict to that so you don't affect say, canon printers.
What I ended up using was
ENV{ID_USB_INTERFACES}=="*:060101:*", ATTR{idVendor}=="04a9", MODE="0664", GROUP="plugdev", GOTO="libgphoto2_rules_end"
Which should catch any canon cameras.
Other useful commands
udevadm monitor --env
adding a rule to log when it's hit
ATTR{idVendor}=="04a9", PROGRAM="/root/foo.sh" ...
where you can use foo.sh to log verify that the match is hit or log environment variables.
edit:
I should add that overriding these entire files is sub-optimal, because if your distro updates the files in /lib/ you will probably have to update manually.
edit2:
A couple things I don't understand despite some hours of headbanging...
1) how does gvfs-gphoto2-volume-monitor ultimately get notified about a new device? The 40-libgphoto2-6.rules just sets ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="PTP" and the file permissions. I would expect a RUN somewhere later that actually does some thing with them, but the only other mentions are I see are
70-uaccess.rules:ENV{ID_GPHOTO2}=="*?", TAG+="uaccess"
95-cd-devices.rules:SUBSYSTEM=="usb", ENV{ID_GPHOTO2}!="", ENV{COLORD_DEVICE}="1", ENV{COLORD_KIND}="camera"
2) When do the values in hwdb get set and used in relation to the udev rules? I tried setting the ENV variables to empty in the rule, but that didn't seem to work.
edit:
Fixed missing comma in final rule