I've been trying to make this work all day. I'm almost there but something is still missing. Here's the story so far:

  • Debian Jessie 8.3 headless home server
  • Canon MP140 MFP scanner/printer fully supported by SANE, via USB
  • SANE dll.conf configured and working (everything commented out except net and pixma)

scanimage -p --resolution 300 --format=tiff --mode Gray -x 210 -y 297 > test300.tiff ...scans an A4 paper in grayscale and saves it as tiff just fine.

sudo service scanbd status
● scanbd.service - Scanner button polling Service
   Loaded: loaded (/lib/systemd/system/scanbd.service; disabled)
   Active: active (running) since Fri 2016-02-19 19:24:03 CET; 23min ago
 Main PID: 1740 (scanbd)
   CGroup: /system.slice/scanbd.service
           └─1740 /usr/sbin/scanbd -f

Feb 19 19:24:03 server scanbd[1740]: /usr/sbin/scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'

It appears to be running but it does not react to the buttons at all.

I tried stopping the service and starting scanbd as root - AND IT WORKS!

sudo scanbd -f
scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'
scanbd: trigger action for button-1 for device pixma:04A9172B_ABCDEF with script example.script

So, my guess was it's some kind of a permissions problem. I tried to change /etc/scanbd.conf and replace

user = scand  
group = scanner  


user = root  
group = root

but then when I restart the scanbd service this is what I get, and the buttons don't work again:

● scanbd.service - Scanner button polling Service
   Loaded: loaded (/lib/systemd/system/scanbd.service; disabled)
   Active: active (running) since Fri 2016-02-19 20:07:11 CET; 4s ago
 Main PID: 2562 (scanbd)
   CGroup: /system.slice/scanbd.service
           └─2562 /usr/sbin/scanbd -f

Feb 19 20:07:11 server scanbd[2562]: /usr/sbin/scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'
Feb 19 20:07:11 server scanbd[2562]: /usr/sbin/scanbd: Not Primary Owner (-1)
Feb 19 20:07:11 server scanbd[2562]: /usr/sbin/scanbd: Name Error (Connection ":1.96" is not allowed to own the service "de.kmux.scanbd.server" due to security policies in the configuration file)

I'm probably overlooking some obvious detail, but I can't really figure out what it is. Any help would be greatly appreciated.

  • Have you seen this? sane.10972.n7.nabble.com/… – MariusMatutiae Feb 20 '16 at 10:35
  • @MariusMatutiae Yes, I've seen it. Looks similar but from what I can see it's another issue altogether. Different environment also - Debian 6, and an older sane / scanbd combo. And some missing files that are present in my case. – vto80 Feb 20 '16 at 14:11

I've finally got it all working...

The end goal for me was to get the scan buttons working. By the time I figured it out, I got the scan buttons working AND network scanning also.

Turns out I was looking at it the wrong way, and consequently going at it the wrong way.
I'm sorry I can't write down the exact sequence of commands to make this work as I've made quite a mess by the time I was done. But I hope I can at least help with the general logic of it.

So, either scanbd (the scanner button service) or saned (the scanner network server service) can access the scanner, but not both at same time. scanbd locks the scanner by constantly refreshing the button state, and saned locks it for use as a network scanner.

The way it works is by using ONLY scanbd as a service.
scanbd then gets to monitor the state of the buttons constantly, and fire some action if a button is pressed. But it also gets to listen on the sane-port 6566 (tcp). If it detects traffic, it stops monitoring the buttons and starts up the saned service that then takes over. When saned is done being a network scanner server, scanbd resumes to wait for a button press, or more network traffic on the sane-port.

In order for this to work, saned must be configured twice.
Both as server and client on the same machine. The server part gets started when scanbd detects network traffic and is described in the paragraph above.

The client part gets started either manually when you initiate a scan via scanimage, or when scanbd detects a button press. The saned client should be configured to connect to a network saned server (the same machine, so localhost, or host name, backend 'net') - NOT USB - thus avoiding conflicts with scanbd. scanbd then detects some network traffic on port 6566 and fires up saned as server, just as if it was really some network client.

The client config is in /etc/sane.d while the server config is in /etc/scanbd/sane.d. The server config must be copied there from /etc/sane.d (just copy the entire folder) and then modified to act as a server and communicate to the scanner via usb i.e. whatever backend the scanner actually uses. In /etc/scanbd/scanbd.conf the SANE_CONFIG_DIR should point to the saned server part: /etc/scanbd/sane.d

Edit: Also, if the machine is firewalled, open port 6566 and load kernel module nf_conntrack_sane:

sudo ufw allow 6566/tcp

sudo modprobe nf_conntrack_sane

and if it then works, add nf_conntrack_sane to /etc/modules

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.