STATUS_ACCESS_DENIED while opening device

225 views
Skip to first unread message

Dinu

unread,
Sep 14, 2012, 4:30:09 PM9/14/12
to jfreesan...@googlegroups.com
Hello,
   First of all, thank you for sharing your work!

I'm trying to use jfreesane for a project and I keep getting "java.io.IOException: unexpected status 11 (STATUS_ACCESS_DENIED) while opening device"
when doing
            address = InetAddress.getByName("127.0.0.1");
            System.out.println("SaneTestApp  : address!"  + address); // Display the string.
            session = SaneSession.withRemoteSane(address);
            List<SaneDevice> devices = session.listDevices();
            System.out.println("SaneTestApp  : devices:"  + devices.get(0)); // Display the string.           
            SaneDevice device = devices.get(0);
            device.open();

the traces looks like this
SaneTestApp  : address!/127.0.0.1
SaneTestApp  : devices:SaneDevice [name=pixma:04A91728, vendor=CANON, model=Canon PIXMA MX310, type=multi-function peripheral]
SaneTestApp error : IOException!
java.io.IOException: unexpected status 11 (STATUS_ACCESS_DENIED) while opening device
    at au.com.southsky.jfreesane.SaneSession.openDevice(SaneSession.java:139)
    at au.com.southsky.jfreesane.SaneDevice.open(SaneDevice.java:76)

I read and re-read the wiki [ CommonOperations  ] / checked the sources but still I cannot figure out why.
I'm working on Ubuntu 12.04 (inetd / xinetd are not installed). /etc/sane.d/net.conf contains localhost in the saned hosts list
Can you please provide a hint ? Eventually extend the wiki to cover this case too ?
Thank you in advance!
Regards,
Dinu

James Ring

unread,
Sep 14, 2012, 4:44:41 PM9/14/12
to dinu.c...@gmail.com, jfreesan...@googlegroups.com

Hey Dinu,

My first guess is that your scanner requires a username and password on the SANE side. Is there an entry for pixma in /etc/sane.d/saned.conf?

At this moment JFreeSane doesn't support authorization but I think it could be added without too much trouble.

Thanks for getting in touch!

Regards,
James

James Ring

unread,
Sep 14, 2012, 5:12:23 PM9/14/12
to dinu.c...@gmail.com, jfreesan...@googlegroups.com
(forgot to reply all)

Sorry, that should be saned.users and not saned.conf.

Dinu

unread,
Sep 14, 2012, 6:06:41 PM9/14/12
to jfreesan...@googlegroups.com, dinu.c...@gmail.com
Hi James,
   thank you for the quick reply!
Unfortunately I don't have such a file (saned.users). Are you sure this should be the reason ?

James Ring

unread,
Sep 14, 2012, 6:18:15 PM9/14/12
to dinu.c...@gmail.com
(bcc the mailing list, I'll post a summary once we figure this out)

Which version of sane are you using?

Is there anything in your syslog (/var/log/syslog)?

If there's nothing there, try:
- stopping saned (sudo /etc/init.d/saned stop)
- starting it directly using /usr/sbin/saned -d128
- running your test program and seeing what output saned produces on its STDOUT

Also take a quick look at
https://help.ubuntu.com/community/SettingScannerPermissions if you
haven't already.

Regards,
James

Dinu

unread,
Sep 14, 2012, 6:30:14 PM9/14/12
to jfreesan...@googlegroups.com, dinu.c...@gmail.com
Hi James,
  I'm using sane 1.0.22.
/var/log/syslog says :
Sep 15 01:16:55 UbuSystem saned[2033]: check_host: access by remote host: ::ffff:127.0.0.1
Sep 15 01:16:55 UbuSystem saned[2033]: init: access granted to dinu@::ffff:127.0.0.1
Sep 15 01:16:59 UbuSystem saned[2033]: process_request: bad status 104
Sep 15 01:16:59 UbuSystem saned[2033]: quit: exiting

  Anyway, thanks for the hint! It works if I do exactly what you mentioned ( stop / start directly / start my test program).
Looks like scanner permissions aren't set properly, right ?

Regards,
Dinu

James Ring

unread,
Sep 14, 2012, 6:32:35 PM9/14/12
to dinu.c...@gmail.com, jfreesan...@googlegroups.com
That is probably the issue, I think you should check out the
permissions on the /dev/bus/usb files and make sure the user that is
running saned has permission to read and write to those files.

Dinu

unread,
Sep 15, 2012, 7:25:08 AM9/15/12
to jfreesan...@googlegroups.com, dinu.c...@gmail.com
Hi James,
   I've used first shotgun approach from https://help.ubuntu.com/community/SettingScannerPermissions and it worked. Thanks again for the help!

Btw ... It looks like a small typo in the interface. Wiki suggests the use of 
List<String> validValues = option.getStringConstraints();
but the working variant is 
List<String> validValues = option.getStringContraints(); // 1st s character missing in the 'Constraints'
What do you think ?
Regards,
Dinu
P.S. You can delete the whole thread if this is not relevant for mailing list. I am not sure what's your email address that's why I kept writing here

James Ring

unread,
Sep 15, 2012, 10:33:19 AM9/15/12
to dinu.c...@gmail.com, jfreesan...@googlegroups.com

Hey Dinu,

Ah nuts, good find! I'll submit a patch to fix it later today. Eclipse makes it easy to promulgate errors like this!

Regards,
James

James Ring

unread,
Sep 15, 2012, 11:45:13 AM9/15/12
to dinu.c...@gmail.com, jfreesan...@googlegroups.com
This is now fixed in the latest source, if you're using mercurial you
should resync.

http://code.google.com/p/jfreesane/source/detail?r=30154d901eb87091929daeec9f07c429f2d60567#

Roland Quast

unread,
Jul 24, 2013, 1:29:48 AM7/24/13
to jfreesan...@googlegroups.com, dinu.c...@gmail.com
Hi James,

I had the same issue here. Dinu's shotgun fix worked for me too. Does sane require authentication to work? It's strange because other apps like Simple Scan work.. do they use authentication too?

Happy to try things out or hack around the code a bit.

Cheers.

Roland Quast

unread,
Jul 24, 2013, 1:31:08 AM7/24/13
to jfreesan...@googlegroups.com, dinu.c...@gmail.com
Forgot to mention that I'm using the latest code in mercurial.

James Ring

unread,
Jul 24, 2013, 1:49:26 AM7/24/13
to rqu...@ebstrada.com.au, jfreesane-discuss, Dinu Capatina
If I recall correctly the problem was that the sane daemon didn't have
permission to read the usb device. This should have been a problem
with any sane client, not just jfreesane. I'm not familiar with Simple
Scan so I wouldn't be able to guess why it worked when jfreesane
didn't.

Hope it all works for you now!
> --
> You received this message because you are subscribed to the Google Groups
> "jfreesane-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jfreesane-disc...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Roland Quast

unread,
Jul 24, 2013, 1:58:59 AM7/24/13
to jfreesan...@googlegroups.com, rqu...@ebstrada.com.au, Dinu Capatina
I might set the permissions back to what they were and see how Simple Scan manages to communicate with sane. There is one key difference from what I got and from what Dinu's issue was though - I didn't get an access denied error, I just got a timeout on connecting to the image port (it connected fine to port 6566 but not the image port). I went through syslog on the sane server and saw the "process_request: bad status 104" message. That's what brought me to this topic. I changed the permissions as per the post (https://help.ubuntu.com/community/SettingScannerPermissions - /etc/udev/rules.d/40-scanner-permissions.rules), restarted saned and it worked. It really is confusing because simple scan on my pc which uses the sane client on this pc to connect to the sane server on another pc, works. Maybe it's something to do with the sane client? Does it send a guest login? Does it send a sane user login? Are there any quick ways I can log the communication it sends to the sane server? Would that help?

Roland Quast

unread,
Jul 24, 2013, 2:01:35 AM7/24/13
to jfreesan...@googlegroups.com, rqu...@ebstrada.com.au, Dinu Capatina
Simple scan will use sane on the local computer, but I have sane on my local computer to connect to a remote sane server (I modified /etc/sane.d/net.conf and added 192.168.1.169 to it). That's all that's required to connect local sane requests to a remote sane server.


On Wednesday, July 24, 2013 3:49:26 PM UTC+10, James Ring wrote:

James Ring

unread,
Jul 24, 2013, 2:01:56 AM7/24/13
to rqu...@ebstrada.com.au, jfreesane-discuss, Dinu Capatina
sane does use a separate data port to transfer image data. Port 6566
is used to set up the scan parameters, then the daemon gives the
client a new port number to connect to. If there is some problem that
prevents the client from connecting to that port (e.g. a firewall)
then you may experience problems like this.

There are ways to capture this data, like using wireshark or tcpdump
for example.

Roland Quast

unread,
Jul 24, 2013, 2:04:47 AM7/24/13
to jfreesan...@googlegroups.com, rqu...@ebstrada.com.au, Dinu Capatina
I think it worked because it uses sane locally to connect to the remote sane server. My hunch is there's some kinda authentication magic going on there for guest users.


On Wednesday, July 24, 2013 3:49:26 PM UTC+10, James Ring wrote:

Roland Quast

unread,
Jul 24, 2013, 2:07:31 AM7/24/13
to jfreesan...@googlegroups.com, rqu...@ebstrada.com.au, Dinu Capatina
I have another idea - rather than trying to trawl through raw data from tcpdump and figure out what it means by going through the spec, I'll first have a look at the sane source code and figure out what it does to connect to a remote server.
Message has been deleted

James Ring

unread,
Jul 24, 2013, 11:48:52 AM7/24/13
to rqu...@ebstrada.com.au, jfreesane-discuss, Dinu Capatina
Does your sane daemon have some auth set up?

From http://www.sane-project.org/html/doc017.html#s5.2.1:
"The user_name argument is the name of the user on whose behalf this
call is being performed. If the network backend cannot determine a
user-name, it passes a NULL pointer for this argument. No trust should
be placed in the authenticity of this user-name. The intent of this
string is to provide more convenience to the user"

On Wed, Jul 24, 2013 at 6:25 AM, Roland Quast <rqu...@ebstrada.com.au> wrote:
> ok this is weird but... after poking around in the sane code and looking at
> the logs.. if you change line 242 of SaneSession.java to write "saned-user"
> rather than what's there, the bad status 104 goes away and it all works.

Roland Quast

unread,
Jul 24, 2013, 6:05:35 PM7/24/13
to jfreesan...@googlegroups.com, rqu...@ebstrada.com.au, Dinu Capatina
No it doesn't have any auth (I suppose this might be a necessary feature that needs adding if people have an /etc/sane.d/sane.users file). The username change didn't make any difference in the end (like it says in the spec), it would work with any username, but the bad status message is still there when you close the connection. I can't replicate the original problem I had anymore now. I changed the permissions for usb back to what they were and there's no problem. I'll have to format another computer and see if I can get the same problem to happen again. Next time I do this I'll put saned into debug mode so I can see more output of what's going on. 
Reply all
Reply to author
Forward
0 new messages