xsane “Failed to create file: Permission Denied” error

Written by James McDonald

September 20, 2008

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.


  1. Jimmy

    I tip my hat to you, sir. HP printers have always worked the best for me in linux, but the infernal hplip print manager would always have some kind of permissions issue.

  2. John

    Another approach:

    cd ~/.sane
    sudo chown -R rupert:rupert *

    This preserves the previous settings.

    Thanks, in any case!

  3. Jon

    Thank you for posting this fix, recursive chown of homedir fixed it for me. (shakes fist at HP scanner setup)


Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…