HID Keylok device not functioning properly

Hi,

We’re using a Keylok HID device inside a docker container.
We tried to run it inside a docker container on an Ubuntu 14.04 host sytem.
This works using the following dockerfile:

FROM ubuntu:14.04
RUN apt-get update -y && apt-get install -y build-essential libudev1 libudev-dev

WORKDIR /home/root/code

ADD code .
RUN chmod +x /home/root/code/keylok_install/keylok_install
RUN cd /home/root/code/keylok_install && ./keylok_install
RUN cd /home/root/code/Demo && make

#run demo program manually inside the container, so just sleep for now
CMD /bin/bash -c 'while true; do sleep 86400; done'
#CMD /home/root/code/Demo/demoA

We execute following docker commands:

docker build -t testkeyimage .
docker run -d --name keytest --privileged  testkeyimage:latest

Inside the container we have the following permissions for our HID device:

root@6a6fd6dc3d4d:/home/root/code# ls -la /dev/usb/hiddev0 
crw-rw-rw- 1 root root 180, 0 Jun  7 11:09 /dev/usb/hiddev0

When we execute the demo program inside the container we get the following output:

root@6a6fd6dc3d4d:/home/root/code# ./Demo/demoA

                  KEY-LOK (TM) SECURITY SYSTEM DEMONSTRATION
                (C) Copyright 1982 - 2013 - All Rights Reserved
                                 By: KEYLOK
                         800-4-KEYLOK (800-453-9565)
 
                 What would you like to do?

                 A = Perform check for proper device.
                 M = Exit from program.
a

The proper KEY-LOK security device is attached.
Dongle Type = 2.

Depress ENTER key to continue.

This functions the same as outside the container.

In resin we run the docker container as a docker-compose service:

  keylok:
    build: ./device-core-keylok
    privileged: true

On the resin host OS we have the following permissions for our HID device:

root@82ea18a:~# ls -la /dev/usb/hiddev0
crw------- 1 root root 180, 96 Jun  7 11:25 /dev/usb/hiddev0

Inside the docker container on the resin host OS we have the same permissions for our HID device:

root@26e76214f1b6:/home/root/code# ls -la /dev/usb/hiddev0
crw------- 1 root root 180, 96 Jun  7 11:25 /dev/usb/hiddev0

These permissions are different than on the Ubuntu host pc, but this should not matter since we are root anyway. (root has rw access)

When we execute the demo program inside the container on the resin OS host we get the following output:

root@6a6fd6dc3d4d:/home/root/code# ./Demo/demoA

                  KEY-LOK (TM) SECURITY SYSTEM DEMONSTRATION
                (C) Copyright 1982 - 2013 - All Rights Reserved
                                 By: KEYLOK
                         800-4-KEYLOK (800-453-9565)
 
                 What would you like to do?

                 A = Perform check for proper device.
                 M = Exit from program.
a

No KEY-LOK or wrong KEY-LOK device attached.

Depress ENTER key to continue.

The demo program does not work in the docker container on the resin OS host.
What could be the cause for this?
Thanks in advance!

This issue is resolved: there was a difference in line endings, very silly…

Hi @ben.clerix
Would you be able to clarify what the difference in line endings was and what files the difference was in?
It would be useful for anyone else who hits this problem

We committed the code on a windows machine and the demo program didn’t work, we then committed the code on a unix machine (ubuntu) and then the demo program worked.
The only difference is the line endings LF on unix and CRLF on windows.
Git should take care of this as core.autocrlf was set to true, but apparently this didn’t work?
C doesn’t handle these changes correctly apparently?
We also find it very strange…

We contacted resin support (mail title: “HID Keylok device not functioning properly”).
There you can find all files to reproduce the issue if needed.