[Pcsclite-muscle] Support for file-descriptor based devices in pcsclite

Wiktor Kwapisiewicz wiktor at metacode.biz
Wed Jun 8 23:59:26 PDT 2022


Hi Ludovic,

On 8.06.2022 17:29, Ludovic Rousseau wrote:
> Any progress? :-)

Sorry for the delay. The project was my holiday thing and since I 
returned to work I can't spend this much time on it sadly :(

The additional difficulty is that I wasn't able to find out how to get 
the USB device file descriptor on desktop Linux (I think you mentioned 
that this should be possible) so my work was done only on a phone 
(including writing, compiling and testing). Sadly Android has a 
different file layout than a regular Linux and (from my understanding) 
running a daemon that listens on non-standard Unix socket path (*not* 
/var/run/pcscd/pcscd.comm) would require also to compile the client 
library to also reference that non-standard path.

> I propose to add a new function in the IFD Handler API.
> https://pcsclite.apdu.fr/api/group__IFDHandler.html
> 
> Something like:
> IFDHCreateChannelByFd(DWORD Lun, int FileDescriptor)
> 
> Then you can use libusb_get_device() to get a libusb device structure
> from the file descriptor.
> I expect some code refactoring in CCID src/ccid_usb.c to avoid
> duplicating a large part of OpenUSBByName()

Thanks for your pointers! I've been looking at the code but 
unfortunately got stuck in hotplug_libusb.c that, ultimately, I figured 
out would not be needed since hotplug manages device additions and 
removals and USB file descriptor represents a ready device.

One additional problem: at least on Android there's an utility program 
that grabs the device and passes the file descriptor to another program.

An example: termux-usb -e ./usbtest /dev/bus/usb/001/002

This runs "./usbtest" with one argument: numeric parameter representing 
the file descriptor (e.g. "./usbtest 7"). The question is should pcscd 
be extended with an argument that it would use?

Also, if you have an idea on how could I test that on a regular desktop 
Linux distribution it would be super-helpful as debugging it on a phone 
is really inconvenient.

So: sorry for the delays but I can't currently spend the amount of time 
I would like to on this :(

Kind regards,
Wiktor



More information about the pcsclite-muscle mailing list