aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
* doc: Remove options from synopsis in man pageRobin Krahl2020-01-29
| | | | | | | As it is no longer required to set the global options before the command and as we will probably introduce more global options with the next releases, this patch removes the global options from the synopsis line in the man page. See issue #102 for more details.
* Make --verbose and --model options globalRobin Krahl2020-01-26
| | | | | | | | | This patch adds the attribute 'global = true' for the top-level --verbose and --model options, which ensures that they can also be set for subcommands. For example: $ nitrocli status --model pro Instead of only: $ nitrocli --model pro status
* Provide correct mutual exclusion between config set -o and -O optionsDaniel Mueller2020-01-24
| | | | | | | | | | The -o/--otp-pin and -O/--no-otp-pin options to the config set command are supposed to be mutually exclusive, with wrong usage detected by structopt. That is not the case currently, however, because the argument to structopt's conflicts_with attribute is supposed to be the resulting option and not the name of the variable capturing the result. This change fixes the problem by changing the string accordingly.
* Add unit tests for the list commandRobin Krahl2020-01-14
|
* Document the list command in the manpageRobin Krahl2020-01-14
|
* Implement list commandRobin Krahl2020-01-14
| | | | | | | | | | | | | | | This patch implements the list command that lists all attached Nitrokey devices. Currently the Nitrokey Storage does not report its serial number during HID enumeration, see [0]. So if we detect a Nitrokey Storage device, we connect to it and use the get_serial_number function to query its serial number. This can be disabled using the --no-connect option. Note that even the get_serial_number function reports a wrong serial number for the Nitrokey Storage, see [1]. [0] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/88 [1] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/76
* Add scaffolding for the list commandRobin Krahl2020-01-14
| | | | | This patch adds the basic scaffolding for the list command which will list all attached Nitrokey devices.
* Bump nitrokey dependency to version 0.5.1Robin Krahl2020-01-14
| | | | | | This change updates the version of the nitrokey crate that we use to 0.5.1. As part of that, it replaces occurrences of Storage::get_status with Storage::get_storage_status as the method has been renamed.
* Use symbolic default values where possibleDaniel Mueller2020-01-08
| | | | | | | | | | With the switch to using structopt for argument parsing some of the default values have become mere strings, whereas one of our earlier objectives was to have symbolic values where that is possible. As structopt works with symbolic values equally well, this change makes it use those. As a bonus, also list the possible formats for the --format option to the otp set subcommand.
* Do not declare internally used types as pubDaniel Mueller2020-01-08
| | | | | | | | With the recent patch set moving us to using structopt over argparse we introduced all new structs and enums representing subcommands and the like as public. That is unnecessary, as they are not accessed from the outside. This change adjusts the visibility accordingly.
* Remove empty Args structs for simple (sub-)commandsRobin Krahl2020-01-08
| | | | | | Since we updated the Command! macro to also allow enum variants without fields, we no longer need the empty *Args structs for commands or subcommands without arguments or options.
* Move doc comments for (sub-)commands to their enumRobin Krahl2020-01-08
| | | | | | | Since we changed the Command! macro to also support doc comments, we can now document the commands directly in the enum. This makes the documentation more consistent when we remove the empty structs for commands without arguments.
* Handle doc comments and empty variants in the Command! macroRobin Krahl2020-01-08
| | | | | | | | This patch introduces two changes to the Command! macro: - We allow variants without fields so that we no longer have to define empty *Args structs just for the Command! macro. - We allow doc comments so that we can document commands without a separate *Args struct.
* Order members in args.rs by command hierarchyRobin Krahl2020-01-08
| | | | | | | | | | | | | | | Currently, the ordering in the args.rs file is inconsistent and arbitrary. This patch orders the members by command hierarchy: - common data structures - for each command C: - CArgs - CCommand - for each subcommand S: - SArgs - custom data structures - custom functions - main argument handling function
* Set possible values for all enum options and argumentsRobin Krahl2020-01-07
| | | | | | | This patch adds the possible_values method to the structopt attributes for all enum options and arguments using the all_str function added in the previous patch. Therefore, the help messages now also list the possible values for these options.
* Add all_str function to enums generated by Enum! macroRobin Krahl2020-01-07
| | | | | | | | | To make it easier to list all possible values for a command-line option mapped to an enum, we add the all_str function to the Enum! macro that returns an array of the string representations of all variants. We also use this new function to simplify the generation of the error message in the FromStr implementation in Enum!.
* Use closures instead of command functionsRobin Krahl2020-01-07
| | | | | To simplify the code, this patch replaces the one-line argument handling functions with closures.
* Remove str argument from Command! macroRobin Krahl2020-01-07
| | | | | | | As we no longer have to implement the Display and AsRef traits for the enums generated with the Command! macro, we don’t have to set a string representation either. So we can drop this argument from the Command! macro.
* Remove unused code after structopt transitionRobin Krahl2020-01-07
| | | | | | In the previous patches, we replaced argparse with structopt and removed the argparse dependency. This patch removes the code that was only needed for argparse.
* Remove argparse dependencyRobin Krahl2020-01-07
| | | | | | As we have replaced argparse with structopt, we no longer need it as a dependency. This patch removes the dependency from Cargo.toml and deletes the included copy.
* Replace argparse with structoptRobin Krahl2020-01-07
| | | | | | | | | | | | This patch changes the argument handling code to use structopt instead of argparse using the data structures we introduced in the last patch. As part of that transition we replace the old Error::ArgparseError variant with ClapError that stores a structopt::clap::Error. Because of that replacement, the format of the help messages changed, breaking some of the tests. Hence, this change adapts them accordingly. Also clap currently prints the version output to stdout, so we ignore the version_option test case for now.
* Add data structures for the options and argumentsRobin Krahl2020-01-07
| | | | | | This patch introduces new structs that can be used with structopt to store the options and arguments parsed from the command line. These structs use the existing enums and command structs.
* Derive structopt::StructOpt in Command!Robin Krahl2020-01-07
| | | | | | As a preparation for the structopt transition, we derive StructOpt for the enums generated by Command! so that they can be used as a subcommand.
* Implement Default in the Enum! and Command! macrosRobin Krahl2020-01-07
| | | | | | | For the transition to structopt, we have to be able to easily construct enum variants once we have added fields to them. Therefore we implement the Default trait in the generated macros by choosing the first variant as the default.
* Allow adding fields to an enum variant in Command!Robin Krahl2020-01-07
| | | | | | To be able to use the enums generated by Command! with structopt, we have to be able to add fields to them. This patch adds a new variant to the Command! macro that supports fields.
* Factor out Enum! and Command! macros in arg_utilRobin Krahl2020-01-07
| | | | | For easier refactoring, we remove the internal enum_int! macro and instead copy its code to the Enum! and Command! macros.
* Use strings instead of Command variantsRobin Krahl2020-01-07
| | | | | | | | | In one of the next patches, we will add fields to some Command variants to be able to use them with structopt. Then we will no longer be able to instantiate them directly, so we replace these instances for the transition. This patch also removes the cmd_help! macro that is no longer needed.
* arg_util: Change Err type in FromStr implementationRobin Krahl2020-01-07
| | | | | structopt requires that FromStr::Err implements std::fmt::Display. Therefore we now return a String that contains a list of allowed values.
* Refactor the Enum! macro into Enum! and Command!Robin Krahl2020-01-07
| | | | | | For an easier transition to structopt, this patch splits the two cases of the Enum! macro into two separate macros (that internally both call the new enum_int! macro).
* Add structopt dependency in version 0.3.7Daniel Mueller2020-04-04
| | | | | This patch series replaces argparse with structopt in the argument handling code. As a first step, we need structopt as a dependency.
* Move nitrocli source code into repository rootDaniel Mueller2020-04-04
| | | | | | Now that all vendored dependencies have been removed, this change moves the program's source code from the nitrocli/ directory into the root of the repository.
* Remove vendored dependenciesDaniel Mueller2020-04-04
| | | | | | | | | | | | | | | | | | | | | | | | While it appears that by now we actually can get successful builds without Cargo insisting on Internet access by virtue of using the --frozen flag, maintaining vendored dependencies is somewhat of a pain point. This state will also get worse with upcoming changes that replace argparse in favor of structopt and pull in a slew of new dependencies by doing so. Then there is also the repository structure aspect, which is non-standard due to the way we vendor dependencies and a potential source of confusion. In order to fix these problems, this change removes all the vendored dependencies we have. Delete subrepo argparse/:argparse Delete subrepo base32/:base32 Delete subrepo cc/:cc Delete subrepo cfg-if/:cfg-if Delete subrepo getrandom/:getrandom Delete subrepo lazy-static/:lazy-static Delete subrepo libc/:libc Delete subrepo nitrokey-sys/:nitrokey-sys Delete subrepo nitrokey/:nitrokey Delete subrepo rand/:rand
* Update packaging instruction for Debian and UbuntuRobin Krahl2020-01-04
| | | | | | | | | This patch updates the packaging instruction for Debian: Instead of updating the TODO.rst file, we now have to create a RFS file in the source directory. This patch also adds links to the trackers for the Debian and Ubuntu packages.
* Update links to Debian & Ubuntu packagesDaniel Mueller2020-01-03
| | | | | | | | | | This change updates the links to the Debian & Ubuntu packages in the README. The previously used links were release-specific, which makes them prone to becoming outdated over time. The new Debian link now is to "stable", which is updated automatically as time goes on and new releases are made. For Ubuntu, there is no such meta release and so we link the search results instead, which fulfill a similar purpose.
* Bump version to 0.3.1v0.3.1Daniel Mueller2020-01-03
| | | | | | | | | | | This change bumps the version of the crate to 0.3.1. The following notable changes have been made since 0.3.0: - Added note about interaction with GnuPG to README file - Bumped nitrokey dependency to 0.4.0 - Bumped nitrokey-sys dependency to 3.5.0 - Added lazy_static dependency in version 1.4.0 - Added cfg-if dependency in version 0.1.10 - Added getrandom dependency in version 0.1.13
* Update nitrokey crate to 0.4.0Daniel Mueller2020-01-02
| | | | | | | | | | | | | This change finally updates the version of the nitrokey crate that we consume to 0.4.0. Along with that we update rand_core, one of its dependencies, to 0.5.1. Further more we add cfg-if in version 0.1.10 and getrandom in version 0.1.13, both of which are now new (non-development) dependencies. Import subrepo nitrokey/:nitrokey at e81057037e9b4f370b64c0a030a725bc6bdfb870 Import subrepo cfg-if/:cfg-if at 4484a6faf816ff8058088ad857b0c6bb2f4b02b2 Import subrepo getrandom/:getrandom at d661aa7e1b8cc80b47dabe3d2135b3b47d2858af Import subrepo rand/:rand at d877ed528248b52d947e0484364a4e1ae59ca502
* Update various pinned cratesDaniel Mueller2020-01-01
| | | | | | | This change updates two development-only crates that have received upstream updates: - nitrokey-test is updated to 0.3.2 - regex is updated to 1.3.1
* Update minimum required Rust version to 1.35.0Daniel Mueller2019-12-31
| | | | | | | | | This change updates the minimum required version of Rust to 1.35.0. The motivation for doing so is at least two fold. First, next we want to bump the nitrokey crate to version 0.4.0 and it requires Rust 1.34.0 as a minimum. Second, and perhaps more importantly, though, in 1.34.0 a clippy lint regressed, breaking our pipeline. That is the reason why we are going to 1.35.0 instead.
* Remove unions_with_drop_fields lintDaniel Mueller2019-12-30
| | | | | With Rust 1.40 the unions_with_drop_fields lint has been removed. This change removes it from our list of lints as well.
* Update lazy_static crate to 1.4.0Daniel Mueller2019-12-29
| | | | | | This change updates the lazy_static crate version to 1.4.0. Import subrepo lazy-static/:lazy-static at 421669662b35fcb455f2902daed2e20bbbba79b6
* Add note about interaction with GnuPG to READMEDaniel Mueller2019-12-19
| | | | | | | | | | | | Applications accessing the Nitrokey device through libnitrokey apparently lock the device. This lock may not be released in time, causing GnuPG operations performed shortly afterwards to fail (or, the other way around, when accessing the GPG smart card through GnuPG and then using nitrocli, the latter program may fail the interaction). Unfortunately there is nothing we can do directly about this problem on the nitrocli side of things, as the problem seemingly needs to be fixed in the firmware. Hence, with this change we add a note about this problem including a reference to the upstream issue to the README.
* Update program description in Cargo.tomlDaniel Mueller2019-12-19
| | | | | | | For a while now the program has not only supported Nitrokey Storage but also Nitrokey Pro devices. Back when we added support for the latter we missed updating the program's description inside Cargo.toml. This change takes care of this oversight.
* Update nitrokey crate to 0.4.0-alpha.3Daniel Mueller2019-08-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change updates the version of the nitrokey crate that we use to 0.4.0-alpha.3. This version is the supposedly last pre-release before 0.4.0, with no further major anticipated changes. In order to integrate with this new version we have to adjust the way we connect to a Nitrokey device by funneling those connection requests through a global manager object. The rationale behind that step being that the underlying libnitrokey actually cannot handle access of multiple devices at the same time, and so the manager object is used to prevent accidental wrong concurrent usage. Because a device object now effectively keeps a reference to the manager, we need to provide an additional lifetime to that and derived objects. Lastly, the use of a manager is also the reason why the tests had to be adjusted to no longer accept device objects in their signatures, but only the respective model for which to invoke the test. That is required because, as elaborated earlier on, having a device object implies having taken a reference to a manager (in that case owned by nitrokey-test), and that reference clashes with the nitrocli code itself attempting to take the manager. We side step this problem by merely accepting a Model object, which can be passed around independently of the manager itself, meaning that nitrokey-test does not need to hold such a reference while the test is run. Import subrepo nitrokey/:nitrokey at f150d59410eefdec2ae69b2422906a3d1d88aa07 Import subrepo nitrokey-sys/:nitrokey-sys at 8695e2c762807e033a86c8d03974b686d20cdd72 Import subrepo lazy-static/:lazy-static at b4b2b16aaa79dd7548e288455a0dbe4065bf4e1a
* Update nitrokey crate to 0.4.0-alpha.2Daniel Mueller2019-08-12
| | | | | | | | | | This change updates the dependency to nitrokey to version 0.4.0-alpha.2. In addition to minor interface changes for the get_*_firmware_version and get_*_retry_count functions, several functions that change the device state now require a mutable handle to the nitrokey. Hence, this patch a number of function signatures to accept mutable device objects. Import subrepo nitrokey/:nitrokey at 34efcfadf1436102e42144f710edabaa2c4b55cd
* Use nitrokey::DEFAULT_{ADMIN,USER}_PIN constantsRobin Krahl2019-12-16
| | | | | | Since version 0.4.0, nitrokey provides the default admin and user PIN as constants. This patch removes the constants from nitrocli and uses nitrokey's constant instead.
* Remove hack required for having device tests in different modulesDaniel Mueller2019-07-17
| | | | | | | | With nitrokey-test up to version 0.2.0 we required a work around to make device tests work across different modules. With this patch we bump the consumed version of the crate to 0.2.1, as part which the underlying problem got fixed. Hence, with this change we remove this hack as it is no longer needed.
* Update nitrokey crate to 0.4.0-alpha.0Daniel Mueller2019-07-17
| | | | | | | | | | | This is patch marks the first step in the process of updating the nitrokey dependency to version 0.4. In particular, it integrates with the first alpha version. The main change on the nitrocli side accompanying the version bump is that the nitrokey::CommandError got replaced by a more general nitrokey::Error which includes the former variant. Import subrepo nitrokey/:nitrokey at d433189caefe6bd6c88da7fbb1d6e9304353eb83
* Bump version to 0.3.0v0.3.0Daniel Mueller2019-12-16
| | | | | | | | | | | | | | | | This change bumps the version of the crate to 0.3.0. The following notable changes have been made since 0.2.4: - Added unencrypted command with set subcommand for changing the unencrypted volume's read-write mode - Changed storage hidden subcommand to hidden top-level command - Renamed storage command to encrypted - Removed storage status subcommand - Moved its output into status command - Removed previously deprecated --ascii option from otp set command - Fixed wrong hexadecimal conversion used in otp set command - Bumped nitrokey dependency to 0.3.5 - Bumped libc dependency to 0.2.66 - Bumped cc dependency to 1.0.48
* Update nitrokey crate to 0.3.5Daniel Mueller2019-12-16
| | | | | | | | | | This change updates the nitrokey crate to version 0.3.5. The main reason for this new version of the crate is a build fix due to a backwards compatibility breaking change in upstream libnitrokey. For that reason, we also have to bump the minimum required version to avoid build failures. Import subrepo nitrokey/:nitrokey at f2cc7fdf081340b0b812f0b212537ba2b55d382e
* Update cc crate to 1.0.48Daniel Mueller2019-11-01
| | | | | | This change updates the cc crate to version 1.0.48. Import subrepo cc/:cc at be9f2c1ae05b336aa3d07a4cbefdc1d88a3d8a91