Skip to content

Commit

Permalink
allow non-USB if FIDO_HID_ANY is defined
Browse files Browse the repository at this point in the history
with help and input from Fabian Henneke; thanks!
  • Loading branch information
martelletto committed Jun 26, 2020
1 parent b21162e commit 57c9c16
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hid_linux.c
Expand Up @@ -258,12 +258,18 @@ copy_info(fido_dev_info_t *di, struct udev *udev,
goto fail;

if ((uevent = get_parent_attr(dev, "hid", NULL, "uevent")) == NULL ||
parse_uevent(uevent, &bus, &di->vendor_id, &di->product_id) < 0 ||
bus != BUS_USB) {
parse_uevent(uevent, &bus, &di->vendor_id, &di->product_id) < 0) {
fido_log_debug("%s: uevent", __func__);
goto fail;
}

#ifndef FIDO_HID_ANY
if (bus != BUS_USB) {
fido_log_debug("%s: bus", __func__);
goto fail;
}
#endif

di->path = strdup(path);
di->manufacturer = get_usb_attr(dev, "manufacturer");
di->product = get_usb_attr(dev, "product");
Expand Down
2 changes: 2 additions & 0 deletions src/hid_osx.c
Expand Up @@ -193,10 +193,12 @@ is_fido(IOHIDDeviceRef dev)
return (false);
}

#ifndef FIDO_HID_ANY
if (strcasecmp(buf, "usb") != 0) {
fido_log_debug("%s: transport", __func__);
return (false);
}
#endif

return (true);
}
Expand Down
4 changes: 4 additions & 0 deletions src/hid_win.c
Expand Up @@ -227,6 +227,7 @@ get_path(HDEVINFO devinfo, SP_DEVICE_INTERFACE_DATA *ifdata)
return (path);
}

#ifndef FIDO_HID_ANY
static bool
hid_ok(HDEVINFO devinfo, DWORD idx)
{
Expand Down Expand Up @@ -269,6 +270,7 @@ hid_ok(HDEVINFO devinfo, DWORD idx)

return (ok);
}
#endif

static int
copy_info(fido_dev_info_t *di, HDEVINFO devinfo, DWORD idx,
Expand All @@ -286,10 +288,12 @@ copy_info(fido_dev_info_t *di, HDEVINFO devinfo, DWORD idx,

fido_log_debug("%s: path=%s", __func__, di->path);

#ifndef FIDO_HID_ANY
if (hid_ok(devinfo, idx) == false) {
fido_log_debug("%s: hid_ok", __func__);
goto fail;
}
#endif

dev = CreateFileA(di->path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
Expand Down

0 comments on commit 57c9c16

Please sign in to comment.