SANE: The home directory "/var/lib/saned/" is missing

Bug #1944457 reported by Ramon Fischer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Raspbian
New
Undecided
Unassigned

Bug Description

Hello,

I would like to report a bug, where the home directory "/var/lib/saned/" in the Raspbian package "sane-utils_1.0.27-3.2_armhf.deb" is missing.

While I was investigating the USB bug "-1 EPIPE (Broken Pipe)" on my Raspberry Pi 4 (8 GB), which uses Raspbian (Debian Buster) as operating system, I analysed the "saned" process via "strace":

    $ while [[ true ]]; do strace -p $(pgrep sane) 2>&1 | tee strace_saned; sleep 1; done

I figured out, that the process tries to create the directory "/var/lib/saned/.sane/" while scanning:

    > mkdir("/var/lib/saned/.sane", 0700) = -1 ENOENT (No such file or directory)

It then tries to create the binary file "hewlett-packard-scanjet-2300c.cal" in that directory after the client detached from the "saned" process/socket:

    > openat(AT_FDCWD, "/var/lib/saned/.sane/hewlett-packard-scanjet-2300c.cal", O_RDONLY) = -1 ENOENT (No such file or directory)

With this knowledge, I created the home directory for "saned" like so:

    $ getent passwd saned
    saned:x:109:117::/var/lib/saned:/usr/sbin/nologin
    $ cd "/var/lib/"
    $ mkhomedir_helper saned
    $ ls -ld saned/
    drwxr-xr-x 2 saned saned 4096 Sep 21 18:12 saned/
    $ tree -augpsh saned/
    saned/
    ├── [-rw-r--r-- saned saned 220] .bash_logout
    ├── [-rw-r--r-- saned saned 3.4K] .bashrc
    ├── [-rw-r--r-- saned saned 807] .profile

    0 directories, 3 files

Then, I scanned one more time and found the above mentioned directory ".sane/" and the binary file "hewlett-packard-scanjet-2300c.cal":

    $ tree -augpsh saned/
    saned/
    ├── [-rw-r--r-- saned saned 220] .bash_logout
    ├── [-rw-r--r-- saned saned 3.4K] .bashrc
    ├── [-rw-r--r-- saned saned 807] .profile
    └── [drwx------ saned saned 4.0K] .sane
        └── [-rw-r--r-- saned saned 32K] hewlett-packard-scanjet-2300c.cal

After that, I did some more investigation, if creating the home directory has some impact and it does.

If the home directory is missing, it causes the "saned" process to initiate the scanner every time the client initiates a scan process. I always hear the servo motor adjusting for each initiated scan with a timeout of about three to five seconds. This timeout is hardware related. During tests with other hardware to investigate the USB bug, the following rule of thumb should apply: The less CPU power, the higher the timeout after initiating a scan.

If the home directory exists on the other hand, the process will look for a suiting ".cal" file in there first and then loads it. Initiating a scan with a pre-loaded ".cal" file will skip the servo motor adjustments and the scanner just scans.

Digging further and looking into the "postinst" file, I found the section, where the user is created via "adduser":

    $ cd $(mktemp -d)
    $ apt download sane-utils
    $ ar x sane-utils_1.0.27-3.2_armhf.deb
    $ tar -Jxvpf control.tar.xz
    $ less postinst
    [...]
    # Create saned user/group if they do not exist
    if ! getent passwd | grep -q "^saned:"; then
        echo "Adding saned group and user..."
        adduser --home /var/lib/saned --quiet --system --no-create-home --group saned || true
    fi
    [...]

The user "saned" is created and will use the home directory "/var/lib/saned/", but it is not created, since the parameter "--no-create-home" is used.

It would be nice, if this parameter could be removed in further updates.

-Ramon

Revision history for this message
Ramon Fischer (keks24) wrote :

Reported the bug at the correct place:

https://github.com/RPi-Distro/repo/issues/262

This ticket can be closed.

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.