Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB Card Reader Redirection Issue #822

Open
outofsight opened this issue May 5, 2024 · 5 comments
Open

USB Card Reader Redirection Issue #822

outofsight opened this issue May 5, 2024 · 5 comments

Comments

@outofsight
Copy link

outofsight commented May 5, 2024

I'm trying to convert few old Windows 7 PC and some new minipc to ThinStation but I'm experiencing a problem with one of them because of the following periperhal not properly redirected.

              *-usb:2 UNCLAIMED
                   description: Generic USB device
                   product: Smart Card Reader USB
                   vendor: HID OMNIKEY
                   physical id: 5
                   bus info: usb@1:5
                   version: 5.31
                   serial: OKCM003060...
                   capabilities: usb-2.00
                   configuration: maxpower=250mA speed=12Mbit/s

This one is a Card Reader and Writer used to prepare cards that open doors in the building. It's not needed to log on to a Remote Windows Desktop but inside an app running on the remote desktop.

Under Windows 7 with proper legacy drivers is shown as "OMNIKEY 5x21", vid/pid 076b:5340, the pid suggests a "CardMan 5021 CL", and can be redirected to a remote desktop as "high level device" of smart card type.

From what I understand drivers are missing in ThinStation so is not recognized as smart card and can't be redirected in freerdp as a smart card. I tried to redirect in freerdp as a "low level usb device" with option /usb:dbg,076b:5340: device appear in device manager, drivers apparently load, but the device doens't work inside the app and can't read/write the cards.

Apparently no specific Linux drivers are available from HID Global so I think there is no way to redirect as a smart card.

Any idea of something else I can try?

@Doncuppjr
Copy link
Collaborator

Doncuppjr commented May 5, 2024 via email

@outofsight
Copy link
Author

outofsight commented May 5, 2024

Not sure if 5021 CL is covered, info are not consistent.
But I don't know ho to "adapt": any input? how hard is?

@outofsight
Copy link
Author

outofsight commented May 7, 2024

@Doncuppjr I found a discussion and your video tutorial at this link and I'm trying to follow it.

I was able to edit this Pkgfile:

# Creator: Peter Petrov <onestone at gmail dot com>
# Maintainer: Julian Xhokaxhiu <info at julianxhokaxhiu dot com>
_gitrel=a973c36ed296
_release=3
name=omnikey_ifdokccid
version=4.3.3
release=6
conflicts=('omnikey_ifdokccid-git')
source=("https://www.hidglobal.com/sites/default/files/drivers/omnikey_ccid_driver_for_8051_controller_based_readers_v.${version}.zip")
# /usr/bin/curl -A 'Mozilla' -fLC - --retry 3 --retry-delay 3 -o omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip https://www.hidglobal.com/sites/default/files/drivers/omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip

# Workaround to allow the package being downloaded
DLAGENTS=("https::/usr/bin/curl -A 'Mozilla' -fLC - --retry 3 --retry-delay 3 -o %o %u")
# DLAGENTS=("https::/usr/bin/curl -A 'Mozilla' -o %o %u")

build() {

    ### was prepare()

    # _ARCH=""

    # # Update the architecture name based on the current one running this PKGBUILD
    # if [ "$CARCH" == "i686" ]; then
    #     _ARCH="i686"
    # elif [ "$CARCH" == "x86_64" ]; then
        _ARCH="x86_64"
    # else
    #     _ARCH="arm"
    # fi

    cd $SRC/

    # Temporary variable
    _PACKAGE_NAME="ifdokccid_linux_${_ARCH}-${version}-${_release}-${_gitrel}"

    # Extract the platform package
    mkdir -p ${name}
    tar xzf ${_PACKAGE_NAME}.tar.gz

    # Move all the package files in a common diretory name
    mv ${_PACKAGE_NAME}/* ${name}

    # Rename the bundle directory
    mv ${name}/${_PACKAGE_NAME}.bundle ${name}/${name}.bundle


    ### was package()
    cd ${name}

    # Start to build the driver package
    mkdir -p $PKG/usr/lib/pcsc/drivers
    cp -r ${name}.bundle $PKG/usr/lib/pcsc/drivers
    mkdir -p $PKG/etc
    install -m0600 omnikey.ini $PKG/etc/omnikey.ini
    mkdir -p $PKG/usr/lib/udev/rules.d
    install -m0744 ok_pcscd_hotplug.sh $PKG/usr/lib/udev/ok_pcscd_hotplug.sh
    install -m0644 z98_omnikey.rules $PKG/usr/lib/udev/rules.d/z98_omnikey.rules
    mkdir -p $PKG/usr/share/licenses/$name
    install -Dm644 HID_OK_Drivers_EULA "$PKG/usr/share/licenses/$name/LICENSE"
}

But when i try pkgmk -d the script cannot download the zip file:

=======> Downloading 'https://www.hidglobal.com/sites/default/files/drivers/omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip'.
--2024-05-07 10:23:12--  https://www.hidglobal.com/sites/default/files/drivers/omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip
Resolving www.hidglobal.com (www.hidglobal.com)... 104.19.217.116, 104.19.216.116
Connecting to www.hidglobal.com (www.hidglobal.com)|104.19.217.116|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2024-05-07 10:23:12 ERROR 403: Forbidden.

As a temporary workaround I was able to manually download the zip with
/usr/bin/curl -A 'Mozilla' -o omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip https://www.hidglobal.com/sites/default/files/drivers/omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip
but now the script complain about the fact it's a zip. But also in the AUR package the source was a zip.

=======> WARNING: Signature file not found, falling back to old md5sum checking.
=======> Building '/ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz'.
bsdtar -p -o -C /ts/components/omnikey_ifdokccid/work/src -xf /ts/components/omnikey_ifdokccid/omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip
bsdtar: Error opening archive: Unrecognized archive format
=======> ERROR: Building '/ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz' failed.

Not sure how to move forward.

There is a way to easily test these drivers in thinstation after booting from network just to understand if the effort is justified?

@Thinstation
Copy link
Collaborator

Thinstation commented May 7, 2024 via email

@outofsight
Copy link
Author

outofsight commented May 7, 2024

You were right. There is something that prevent downloading the zip with curl/wget. I had to download with a browser and move in the package folder.

[root@TS_chroot]/ts/components/omnikey_ifdokccid# pkgmk
=======> WARNING: Signature file not found, falling back to old md5sum checking.
=======> WARNING: Md5sum not found, creating new.
=======> Building '/ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz'.
bsdtar -p -o -C /ts/components/omnikey_ifdokccid/work/src -xf /ts/components/omnikey_ifdokccid/omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip
+ build
+ _ARCH=x86_64
+ cd /ts/components/omnikey_ifdokccid/work/src/
+ _PACKAGE_NAME=ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296
+ mkdir -p omnikey_ifdokccid
+ tar xzf ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296.tar.gz
+ mv ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296/HID_OK_Drivers_EULA ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296/README.html ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296/ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296.bundle ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296/install ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296/ok_pcscd_hotplug.sh ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296/omnikey.ini ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296/z98_omnikey.rules omnikey_ifdokccid
+ mv omnikey_ifdokccid/ifdokccid_linux_x86_64-4.3.3-3-a973c36ed296.bundle omnikey_ifdokccid/omnikey_ifdokccid.bundle
+ cd omnikey_ifdokccid
+ mkdir -p /ts/components/omnikey_ifdokccid/work/pkg/usr/lib/pcsc/drivers
+ cp -r omnikey_ifdokccid.bundle /ts/components/omnikey_ifdokccid/work/pkg/usr/lib/pcsc/drivers
+ mkdir -p /ts/components/omnikey_ifdokccid/work/pkg/etc
+ install -m0600 omnikey.ini /ts/components/omnikey_ifdokccid/work/pkg/etc/omnikey.ini
+ mkdir -p /ts/components/omnikey_ifdokccid/work/pkg/usr/lib/udev/rules.d
+ install -m0744 ok_pcscd_hotplug.sh /ts/components/omnikey_ifdokccid/work/pkg/usr/lib/udev/ok_pcscd_hotplug.sh
+ install -m0644 z98_omnikey.rules /ts/components/omnikey_ifdokccid/work/pkg/usr/lib/udev/rules.d/z98_omnikey.rules
+ mkdir -p /ts/components/omnikey_ifdokccid/work/pkg/usr/share/licenses/omnikey_ifdokccid
+ install -Dm644 HID_OK_Drivers_EULA /ts/components/omnikey_ifdokccid/work/pkg/usr/share/licenses/omnikey_ifdokccid/LICENSE
=======> Build result:
drwxr-xr-x  0 root   root        0 May  7 14:47 etc/
-rw-------  0 root   root     1321 May  7 14:47 etc/omnikey.ini
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/share/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/pcsc/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/udev/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/udev/rules.d/
-rwxr--r--  0 root   root      229 May  7 14:47 usr/lib/udev/ok_pcscd_hotplug.sh
-rw-r--r--  0 root   root     9365 May  7 14:47 usr/lib/udev/rules.d/z98_omnikey.rules
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/pcsc/drivers/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/Contents/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/Contents/Linux/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/Contents/tools/
-rw-r--r--  0 root   root    10411 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/Contents/Info.plist
-rwx------  0 root   root     1376 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/Contents/tools/ifdok_bugreport
-rwx--x--x  0 root   root     7752 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/Contents/tools/ifdok_xmled
-rwxr-xr-x  0 root   root   243224 May  7 14:47 usr/lib/pcsc/drivers/omnikey_ifdokccid.bundle/Contents/Linux/ifdokccid.so
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/share/licenses/
drwxr-xr-x  0 root   root        0 May  7 14:47 usr/share/licenses/omnikey_ifdokccid/
-rw-r--r--  0 root   root    14588 May  7 14:47 usr/share/licenses/omnikey_ifdokccid/LICENSE
=======> WARNING: Footprint not found, creating new.
=======> Building '/ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz' succeeded.

[root@TS_chroot]/ts/components/omnikey_ifdokccid# pkgmk -i
=======> Package '/ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz' is up to date.
=======> Installing '/ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz'.
pkgadd /ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz
=======> Installing '/ts/components/omnikey_ifdokccid/omnikey_ifdokccid#4.3.3-6.pkg.tar.xz' succeeded.

[root@TS_chroot]/ts/components/omnikey_ifdokccid# ls -la
total 772
drwxr-xr-x 2 root root   4096 May  7 14:47 .
drwxr-xr-x 7 root root   4096 May  7 09:46 ..
-rw-r--r-- 1 root root   1272 May  7 14:47 .footprint
-rw-r--r-- 1 root root    100 May  7 14:47 .md5sum
-rw-r--r-- 1 root root   2091 May  7 10:23 Pkgfile
-rwxr--r-- 1 root root 658753 May  7 14:45 omnikey_ccid_driver_for_8051_controller_based_readers_v.4.3.3.zip
-rw-r--r-- 1 root root 107576 May  7 14:47 omnikey_ifdokccid#4.3.3-6.pkg.tar.xz

[root@TS_chroot]/ts/components/omnikey_ifdokccid# mkrepackage omnikey_ifdokccid

Now, everything seems fine to me.

Just what about the dependencies mentioned in AUR page? (libusb pcsclite). I suppose these are included in TS but should I declare somewhere?

But unfortunately image building fails.

Adding Package Dependencies
Adding 6.1.63TS module dependencies on other packages
Dependencies are clean!
Adding and install non-distributable binaries
Package 'omnikey_ifdokccid' not found
Error has occured while installing package
Build Aborted

New package appears in /build/packages.

[root@TS_chroot]/build/packages/omnikey_ifdokccid# ls -laR
.:
total 20
drwxr-xr-x   3 root root  4096 May  7 14:50 .
drwxr-xr-x 422 root root 12288 May  7 15:19 ..
-rw-r--r--   1 root root     0 May  7 14:50 .dna
drwxr-xr-x   2 root root  4096 May  7 14:50 build
-rw-r--r--   1 root root     0 May  7 14:50 dependencies

./build:
total 16
drwxr-xr-x 2 root root 4096 May  7 14:50 .
drwxr-xr-x 3 root root 4096 May  7 14:50 ..
-rwxr-xr-x 1 root root  110 May  7 14:50 install
-rwxr-xr-x 1 root root   57 May  7 14:50 remove

@Thinstation Am I missing some step?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants