rocketraman / sane-scan-pdf

Sane command-line scan-to-pdf script on Linux with OCR and deskew support
MIT License
137 stars 27 forks source link

units: cannot open file '/root/.units': Permission denied #45

Closed kleinarne closed 1 year ago

kleinarne commented 1 year ago

I'm trying to get scanbd to call sane-scan-pdf when pressing the scan button on my Fujitsu S1300i.

When I run scanbd with sudo SANE_CONFIG_DIR=/etc/scanbd scanbd -d7 -f and press the scan button, I get the following debug output. Note the two lines units: cannot open file '/root/.units': Permission denied.

I don't know how to fix this...

scanbd: value trigger: numerical
scanbd: trigger action for scan for device epjitsu:libusb:001:004 with script epjitsu.script
scanbd: get_sane_option_value
scanbd: Value of mode as string (len 7, hash -621353420): Lineart
scanbd: setting env: SCANBD_FUNCTION_MODE=Lineart
scanbd: setting env: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
scanbd: No PWD, setting env: PWD=/home/username
scanbd: setting env: USER=root
scanbd: setting env: HOME=/root
scanbd: setting env: SCANBD_DEVICE=epjitsu:libusb:001:004
scanbd: setting env: SCANBD_ACTION=scan
scanbd: append string epjitsu:libusb:001:004 to signal scan_begin
scanbd: now sending signal scan_begin
scanbd: Iteration on dbus call
scanbd: append string SCANBD_FUNCTION_MODE=Lineart to signal trigger
scanbd: append string PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin to signal trigger
scanbd: append string PWD=/home/username to signal trigger
scanbd: append string USER=root to signal trigger
scanbd: append string HOME=/root to signal trigger
scanbd: append string SCANBD_DEVICE=epjitsu:libusb:001:004 to signal trigger
scanbd: append string SCANBD_ACTION=scan to signal trigger
scanbd: now sending signal trigger
scanbd: now flushing the dbus
scanbd: unref the signal
scanbd: using relative script path: epjitsu.script, expanded to: /usr/share/scanbd/scripts/epjitsu.script
scanbd: waiting for child: /usr/share/scanbd/scripts/epjitsu.script
scanbd: setgid to gid=114
scanbd: setuid to uid=110
scanbd: exec for /usr/share/scanbd/scripts/epjitsu.script
scanbd: octal mode for /usr/share/scanbd/scripts/epjitsu.script: 100755
scanbd: file uid: 0, file gid: 0
units: cannot open file '/root/.units': Permission denied
units: cannot open file '/root/.units': Permission denied
Scanning...
scanadf: open of device fujitsu failed: Invalid argument
Found no scans.
scanbd: child /usr/share/scanbd/scripts/epjitsu.script exited with status: 0
scanbd: Iteration on dbus call
scanbd: append string epjitsu:libusb:001:004 to signal scan_end
scanbd: now sending signal scan_end
scanbd: reopen device epjitsu:libusb:001:004
kleinarne commented 1 year ago

Well, after posting this I found https://github.com/rocketraman/sane-scan-pdf/issues/16, which eventually solved it - I had to update the script that calls scan,

from

#!/bin/sh
now=`date +"%Y-%m-%d-%H%M"`
/home/username/sane-scan-pdf/scan -d -r 300 -v -m Lineart --skip-empty-pages -o /home/username/scans/scan-$now.pdf

to

#!/bin/sh
now=`date +"%Y-%m-%d-%H%M"`
/home/username/sane-scan-pdf/scan --device "" --no-default-size -d -r 300 -v -m Lineart --skip-empty-pages -o /home/username/scans/scan-$now.pdf

--device "" fixed the scanadf: open of device fujitsu failed: Invalid argument error, --no-default-size fixed the units: cannot open file '/root/.units': Permission denied error.

And then it scanned, albeit 15 seconds or so after pressing the button.

/edit: Your comment in https://github.com/rocketraman/sane-scan-pdf/issues/39#issuecomment-1013807529 about calling scanadf without the -d parameter fixed it for me too, I changed the --device "" parameter to --device "epjitsu" which also fixed the delay.

Anyway, I'll close this.

rocketraman commented 1 year ago

Glad you got it all working and thanks for updating the issue with your solution and issue references! Cheers.