From 9593dfd03a6ca085d649ca090b6ec5e5f0104e78 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 8 Sep 2020 18:23:30 +0200 Subject: Add --usb-path option to select device This patch adds the --usb-path option as an additional way to filter the Nitrokey device to connect to. While the serial number is a better identifier in theory, the Nitrokey Storage devices do not send their serial number in the USB device descriptor. Having the --usb-path options allows users to select one of multiple Nitrokey Storage devices. While we could directly call the nitrokey::Manager::connect_path function with the specified path, we integrate the --usb-path option into the existing find_device function for consistent error messages and to avoid having to duplicate the --model and --serial-number checks. --- src/config.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index a609189..6bb6efb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -32,6 +32,8 @@ pub struct Config { #[merge(strategy = merge::vec::overwrite_empty)] #[serde(default, deserialize_with = "deserialize_serial_number_vec")] pub serial_numbers: Vec, + /// The USB path of the device to connect to. + pub usb_path: Option, /// Whether to bypass the cache for all secrets or not. #[merge(strategy = merge::bool::overwrite_false)] #[serde(default)] @@ -74,6 +76,9 @@ impl Config { if !args.serial_numbers.is_empty() { self.serial_numbers = args.serial_numbers.clone(); } + if args.usb_path.is_some() { + self.usb_path = args.usb_path.clone(); + } if args.no_cache { self.no_cache = true; } -- cgit v1.2.1