break;
}
}
- if (j == pids_len) {
+ if (j != pids_len) {
+ rc = YK_EUSBERR;
+ ykl_errno = libusb_open(dev, &h);
+ if (ykl_errno != 0)
+ goto done;
+ ykl_errno = libusb_detach_kernel_driver(h, 0);
+ if (ykl_errno != 0)
+ goto done;
+ /* This is needed for yubikey-personalization to work inside virtualbox virtualization. */
+ ykl_errno = libusb_set_configuration(h, 1);
goto done;
}
-
- rc = YK_EUSBERR;
- ykl_errno = libusb_open(dev, &h);
- if (ykl_errno != 0)
- goto done;
- ykl_errno = libusb_detach_kernel_driver(h, 0);
- if (ykl_errno != 0)
- goto done;
- /* This is needed for yubikey-personalization to work inside virtualbox virtualization. */
- ykl_errno = libusb_set_configuration(h, 1);
- goto done;
}
}
done:
break;
}
}
- if(j == pids_len) {
- goto done;
- }
-
- rc = YK_EUSBERR;
- h = usb_open(dev);
+ if(j != pids_len) {
+ rc = YK_EUSBERR;
+ h = usb_open(dev);
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
- if (h != NULL)
- usb_detach_kernel_driver_np(h, 0);
+ if (h != NULL)
+ usb_detach_kernel_driver_np(h, 0);
#endif
- /* This is needed for yubikey-personalization to work inside virtualbox virtualization. */
- if (h != NULL)
- usb_set_configuration(h, 1);
- goto done;
+ /* This is needed for yubikey-personalization to work inside virtualbox virtualization. */
+ if (h != NULL)
+ usb_set_configuration(h, 1);
+ goto done;
+ }
}
}
done: