Today I tried to run xsane as my normal account and it didn’t detect my scanner. I traced the problem to insufficient permissions because my account wasn’t a member of the “scanner” group, hence, because I didn’t have permission to the scanner devices xsane wouldn’t detect my scanner.

In my attempts to fault-find I ran sudo xsane to get the scanner going and everything worked fine. However after rectifying my standard user accounts lack of permissions using users-admin and selecting the “Use Scanners” option, and logging off/on, when I went to close xsane after it successfully running I got:

Finding out what was being denied:

Run xsane through strace to get information on what files it’s choking on and pipe the output to a file. “myout” in this case
strace /usr/bin/xsane 2>&1 | tee myout

Open myout in vi and search for “EACCES” or
cat myout | grep "EACCES" to get a list e.g.

open("/home/rupert/.sane/xsane/Hewlett-Packard:PSC__1600__series.drc", O_RDONLY) = -1 EACCES (Permission denied)
open("/home/rupert/.sane/xsane/batch-lists/default.xbl", O_RDONLY) = -1 EACCES (Permission denied)
open("/home/rupert/.sane/xsane/xsane.rc", O_WRONLY|O_CREAT|O_TRUNC, 0600) = -1 EACCES (Permission denied)
open("/home/rupert/.sane/xsane/xsane.mdf", O_WRONLY|O_CREAT|O_TRUNC, 0600) = -1 EACCES (Permission denied)
open("/home/rupert/.sane/xsane/Hewlett-Packard:PSC__1600__series.drc", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 EACCES (Permission denied)

The cause:
Things owned by root that shouldn’t be.

cd ~/.sane/xsane

ls -al
drwxrwx--- 2 root root 6 2008-09-20 08:08 batch-lists
-rw-rw---- 1 root root 1692 2008-09-20 08:23 Hewlett-Packard:PSC__1600__series.drc
-rw------- 1 root root 4263 2008-09-20 08:23 xsane.mdf
-rw------- 1 root root 5212 2008-09-20 08:23 xsane.rc

Quick and dirty fix:
cd get’s you back to your home dir
sudo rm -rf .sane

Then rerun xsane

This will recreate the files with the correct ownership (of course you could change perms on the originals but hey this works.

cd .sane/xsane
ls -al

total 20
drwxrwx--- 3 rupert rupert 99 2008-09-20 20:15 .
drwxrwx--- 3 rupert rupert 18 2008-09-20 20:15 ..
drwxrwx--- 2 rupert rupert 6 2008-09-20 20:15 batch-lists
-rw-rw---- 1 rupert rupert 1691 2008-09-20 20:15 Hewlett-Packard:PSC__1600__series.drc
-rw------- 1 rupert rupert 4263 2008-09-20 20:15 xsane.mdf
-rw------- 1 rupert rupert 5208 2008-09-20 20:15 xsane.rc

Note: doing the above will remove any settings you have configured in xsane but it’s quick and it works.