scanbd does not find scanner

Bug #1747115 reported by adasiko
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
scanbd (Ubuntu)
Confirmed
Undecided
Rolf Leggewie

Bug Description

Ubuntu 18.04

Install scanbd and run from root (no need any permisions troubles for now)

sudo apt-get install scanbd

root@ubuntu1804:~# SANE_CONFIG_DIR=/etc/sane.d scanbd -d7 -f
scanbd: foreground
scanbd: reading config file /etc/scanbd/scanbd.conf
scanbd: debug on: level: 7
scanbd: dropping privs to uid saned
scanbd: dropping privs to gid scanner
scanbd: group scanner has member:
scanbd: saned
scanbd: drop privileges to gid: 120
scanbd: Running as effective gid 120
scanbd: drop privileges to uid: 115
scanbd: Running as effective uid 115
scanbd: dbus_init
scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'
scanbd: SANE_CONFIG_DIR=/etc/sane.d
scanbd: sane version 1.0
scanbd: Scanning for local-only devices
scanbd: start_sane_threads
scanbd: no devices, not starting any polling thread
scanbd: start dbus thread

Something wrong. Scanbd can not find scanner.
Compile package by self.

sudo apt-get install build-essential checkinstall pkg-config libconfuse-dev libsane-dev libudev-dev libusb-dev libdbus-1-dev
./configure
make all
sudo checkinstall

root@ubuntu1804:~# SANE_CONFIG_DIR=/etc/sane.d scanbd -d7 -f
scanbd: foreground
scanbd: reading config file /usr/local/etc/scanbd/scanbd.conf
scanbd: debug on: level: 7
scanbd: dropping privs to uid saned
scanbd: dropping privs to gid lp
scanbd: drop privileges to gid: 7
scanbd: Running as effective gid 7
scanbd: drop privileges to uid: 115
scanbd: Running as effective uid 115
scanbd: dbus_init
scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'
scanbd: SANE_CONFIG_DIR=/etc/sane.d
scanbd: sane version 1.0
scanbd: Scanning for local-only devices
scanbd: found device: snapscan:libusb:001:002 EPSON EPSON Scanner flatbed scanner
scanbd: start_sane_threads

Success! Scanner has been found.

I think that key in this. From readme.txt:
"If you want to use the scanbuttond-backends instead of sane-backends, use
--enable-scanbuttond for configure."

PS: It's old prloblem https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=824450 - "I'm still wondering what's wrong with the Debian package itself."

adasiko (adasiko256)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in scanbd (Ubuntu):
status: New → Confirmed
Revision history for this message
Rolf Leggewie (r0lf) wrote :

Thank you for your report and sorry for your troubles. The Debian bug you referenced is not what you are experiencing, though, since Chris confirmed this was gone in the package that was eventually uploaded as 1.4.4-2

Changed in scanbd (Ubuntu):
assignee: nobody → Rolf Leggewie (r0lf)
Revision history for this message
Martin Heckenbach (heckie75) wrote :

I've just tried to configure scanbd under Ubuntu 18.10 and ran into same trouble.

Scanner device is available:
# scanimage -L
device `plustek:libusb:002:007' is a Canon CanoScan LiDE25 flatbed scanner

But after starting scanbd it terminates with message that it is not available:

# scanbd -f -d 7 -c /etc/scanbd/scanbd.conf
scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'
scanbd: SANE_CONFIG_DIR not set
scanbd: no devices, not starting any polling thread

I come from Ubuntu 16.04.5 where it worked perfectly.

Revision history for this message
Martin Heckenbach (heckie75) wrote :

I made the next step.

After I have changed the user from saned to root in scanbd.conf I am able to start scanbd and it starts polling the usb device.

scanbd.conf looks like this now:

# drop priviliges to this user
#=============================
# Linux (most distributions use the saned user):
# user = saned
# ArchLinux (ArchLinux doesn't have saned user)
# user = daemon
# *BSD
# user = root
# user = saned
user = root

I have started scanbd from command line and it works well.

$ scanbd -c /etc/scanbd/scanbd.conf -d7 -f
scanbd: foreground
scanbd: reading config file /etc/scanbd/scanbd.conf
scanbd: debug on: level: 7
scanbd: dropping privs to uid root
scanbd: dropping privs to gid scanner
scanbd: group scanner has member:
scanbd: saned
scanbd: drop privileges to gid: 124
scanbd: Running as effective gid 124
scanbd: drop privileges to uid: 0
scanbd: Running as effective uid 0
scanbd: dbus_init
scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'
scanbd: SANE_CONFIG_DIR not set
scanbd: sane version 1.0
scanbd: Scanning for local-only devices
scanbd: found device: plustek:libusb:002:008 Canon CanoScan LiDE25 flatbed scanner
scanbd: start_sane_threads
scanbd: Starting poll thread for plustek:libusb:002:008

After I have pressed one of the buttons, scanbd calls my script - let's say scan.sh - in order to finally run the scanimage command. Perfect!

Nevertheless, I said one step. The normal case is to start scanbd via systemd. But in this case my scan.sh-script with scanimage does not find devices. In this case I find the following messages in syslog:

Dec 8 13:41:28 my-desktop dbus-daemon[617]: [system] Activating via systemd: service name='de.kmux.scanbd.server' unit='dbus-de.kmux.scanbd.server.service' requested by ':1.270' (uid=1 pid=14081 comm="/usr/sbin/scanbm -c /etc/scanbd/scanbd.conf " label="unconfined")
Dec 8 13:41:53 my-desktop saned[14110]: saned (AF-indep+IPv6) from sane-backends 1.0.27 starting up
Dec 8 13:41:53 my-desktop saned[14110]: check_host: access by remote host: ::ffff:127.0.0.1
Dec 8 13:41:53 my-desktop saned[14110]: init: access granted to saned-user@::ffff:127.0.0.1
Dec 8 13:41:54 my-desktop scanbd[12422]: scanimage: no SANE devices found
Dec 8 13:41:54 my-desktop saned[14110]: saned exiting
Dec 8 13:41:54 my-desktop dbus-daemon[617]: [system] Activating via systemd: service name='de.kmux.scanbd.server' unit='dbus-de.kmux.scanbd.server.service' requested by ':1.270' (uid=1 pid=14081 comm="/usr/sbin/scanbm -c /etc/scanbd/scanbd.conf " label="unconfined")
Dec 8 13:42:01 my-desktop systemd-resolved[496]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Dec 8 13:42:01 my-desktop systemd-resolved[496]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.

I haven't solved it yet.

In general I guess that all this is related to permissions and roles.

Revision history for this message
Martin Heckenbach (heckie75) wrote :

Finally, the following is what works for me:

It seems that there is the need to change users to root at several places:

1. /etc/scanbd/scanbd.conf

Change user so that it is 'root' instead of 'saned'

        # drop priviliges to this user
        #=============================
        # Linux (most distributions use the saned user):
        # user = saned
        # ArchLinux (ArchLinux doesn't have saned user)
        # user = daemon
        # *BSD
        # user = root
        # user = saned
        user = root

2. /lib/systemd/system/scanbm@.service

Change User from 'User=daemon' to 'User=root'.

Since if it is 'daemon' after you have pressd a button scanbd tries to start the saned process with user 'daemon'. But then saned does not find any scanner device. It just seem to work with user 'root'

[Unit]
Description=Scanner Service
Requires=scanbm.socket

[Service]
ExecStart=/usr/sbin/scanbm -c /etc/scanbd/scanbd.conf
#User=daemon
User=root
Group=scanner
StandardInput=socket
Environment=SANE_CONFIG_DIR=/etc/scanbd

3. /etc/dbus-1/system.d/scanbd_dbus.conf

Here I also changed the user. It was 'saned' before, but I changed it to 'root' as well.
Don't forget to run systemctl daemon-reload

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
        <policy user="root"> <!-- Arch Linux user="daemon" -->
        <allow own="de.kmux.scanbd.server"/>
        <allow send_interface="de.kmux.scanbd.server"/>
        <allow receive_interface="de.kmux.scanbd.server"/>
        <allow send_destination="de.kmux.scanbd.server"/>
    </policy>
    <policy context="default">
        <allow send_interface="de.kmux.scanbd.server"/>
        <allow send_destination="de.kmux.scanbd.server"/>
    </policy>
</busconfig>

In my case everything works as before in Ubuntu 16.04.
I expect that it is just a workaround to run all these processes with root priviledges. The root cause is probably related to the way of access to the usb device. (libusb?)

Revision history for this message
Martin Heckenbach (heckie75) wrote :

Remote access does not work as well e.g. by using the Windows client SaneTwain

I'm uncertain if this is related to previuos issue. But it worked in Ubuntu 16.04.

Error message in syslog is:

Mar 17 08:18:00 my-desktop saned[26802]: saned (AF-indep+IPv6) from sane-backends 1.0.27 starting up
Mar 17 08:18:00 my-desktop saned[26802]: check_host: access by remote host: ::ffff:192.168.178.34
Mar 17 08:18:00 my-desktop saned[26802]: init: access granted to myuser@::ffff:192.168.178.34
Mar 17 08:18:00 my-desktop saned[26802]: process_request: (control_option) error while decoding args h=0 (Cannot allocate memory)
Mar 17 08:18:00 my-desktop saned[26802]: process_request: bad status 12
Mar 17 08:18:00 my-desktop saned[26802]: saned exiting

Revision history for this message
Francis Hauber (francis-hauber-s) wrote :

Hi,
having the same issue here I found out that the rule in /lib/udev/rules.d/99-saned.rules should set the GROUP to "scanner" rather than "saned"
e.g. replace
ENV{libsane_matched}=="yes", GROUP="saned"
by
ENV{libsane_matched}=="yes", GROUP="scanner"
It solve the problem on my system.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.