[sane-devel] Chained Network Sane?

Ralph Little skelband at gmail.com
Sun Aug 7 15:39:01 BST 2022


On 2022-08-02 12:46, Guy B wrote:
> I'm trying to determine if this setup can actually be made to function 
> (and Googling has given no obvious answer).
> Server A - connected to scanner via USB, exposed via network
>       ↓
> Server B - connected to A via the "net" interface, re-exposes scanner 
> to another net via "net" interface
>      ↓
> Server C - connects to B via "net"
> The reason that I'm trying to do this is because "A" in this use case 
> is actually a VM running an ancient version of Ubuntu because that's 
> the only place I can make the binary-only drivers work (and I don't 
> want a 10+ year old version of Ubuntu exposed to /any/ network). "B" 
> is then a real machine that I want to use to expose it to the rest of 
> the network.
> While I've had no trouble plumbing things through to "B", I can't 
> figure out how (or if it is possible) to re-share the network scanner 
> again.
> -Guy

So to summarise:
     - Server A (VM) will be running the binary driver and saned,
     - Server B will be running SANE with the "net" backend (configured 
to connect to Server A's saned) and also saned,
     - Server C will be running SANE with the "net" backend (configured 
to connect to Server B's saned).

Although this sounds reasonable, the only issue that I can see with this 
setup is that saned running on Server B will not pick up the devices 
through the "net" backend.
The reason for this is that saned is intended to advertise local devices 
only and when asking the "net" backend for local devices, it will simply 
return with an empty list.
Partly the reason for this is to stop deadly embrace loops where the 
"net" backend and saned could conceivably keep re-advertising each 
other's devices in an endless loop.

Without changing code, I don't see an obvious way around this 
restriction. However, there are two ways you could get around this in 
your circumstance if you are willing do some minor code changes and rebuild.

Do one of:

A. Rebuild saned with a small change to the code here around line 1851 
of saned.c:

       sane_get_devices ((const SANE_Device ***) &reply.device_list,


       sane_get_devices ((const SANE_Device ***) &reply.device_list,

This removes the restriction on local-only devices.


B. Rebuild the net backend with a small change to the code around line 
1223 of net.c:

   if (local_only)
       *device_list = empty_devlist;
       return SANE_STATUS_GOOD;

...by removing this code entirely.

If you are willing to give this a try, I would say that changing the net 
backend and using that is probably the easiest solution.
To give it a go, I would clone the backends repo, make the change, build 
it, take the built net backend files (libsane-net.*) and temporarily 
replace your regular ones on Server B with the built ones so that Server 
B's saned will see them.
Probably not a good permanent solution but a place to start at least.

Actually, since we have had this question come up a couple of times in 
the past, it might be an optional feature that we could add, switched 
off by default, to the core code.

Anyway, let us know if you need help giving that a try.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20220807/1db1f8a5/attachment.htm>

More information about the sane-devel mailing list