Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pws-cache extension #156

Draft
wants to merge 15 commits into
base: devel
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Pass on resolved USB path to extensions
To avoid reimplementing the device selection logic in extensions, we
introduce a new environment variable NITROCLI_RESOLVED_USB_PATH that is
set to the USB path of the single matching Nitrokey device. If no device
matches, or if there are multiple matching devices, the variable
is not set.
robinkrahl authored and d-e-s-o committed Apr 12, 2021

Verified

This commit was signed with the committer’s verified signature.
d-e-s-o Daniel Müller
commit c04ff249261561526187fbdfd4cd611f2acdbe10
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased
----------
- Enabled usage of empty PWS slot fields
- Added `NITROCLI_RESOLVED_USB_PATH` environment variable to be used by
extensions
- Allowed entering of `base32` encoded strings containing spaces
- Fixed pinentry dialog highlighting some messages incorrectly as errors
- Bumped `nitrokey` dependency to `0.9.0`
10 changes: 8 additions & 2 deletions doc/nitrocli.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH NITROCLI 1 2020-10-11
.TH NITROCLI 1 2021-04-14
.SH NAME
nitrocli \- access Nitrokey devices
.SH SYNOPSIS
@@ -427,12 +427,18 @@ The program conveys basic configuration information to any extension being
started this way. Specifically, it will set each environment variable as
described in the Configuration subsection of the Environment section above, if
the corresponding \fBnitrocli\fR program configuration was set. In addition, the
following variable will be set unconditionally:
following variable will be set:
.TP
.B NITROCLI_BINARY
The absolute path to the \fBnitrocli\fR binary through which the extension was
invoked. This path may be used to recursively invoke \fBnitrocli\fR to implement
certain functionality.
.TP
.B NITROCLI_RESOLVED_USB_PATH
The USB path of the device that \fBnitrocli\fR would connect to based on the
\fB\-\-model\fR, \fB\-\-serial-number\fR, and \fB\-\-usb-path\fR options.
If there is no matching Nitrokey device, or if multiple devices match the
options, the environment variable is not set.

.P
All other variables present in the environment will be passed through to the
Binary file modified doc/nitrocli.1.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
@@ -1170,6 +1170,10 @@ pub fn extension(ctx: &mut Context<'_>, args: Vec<ffi::OsString>) -> anyhow::Res
// a cargo test context.
let mut cmd = process::Command::new(&ext_path);

if let Ok(device_info) = find_device(&ctx.config) {
let _ = cmd.env(crate::NITROCLI_RESOLVED_USB_PATH, device_info.path);
}

if let Some(model) = ctx.config.model {
let _ = cmd.env(crate::NITROCLI_MODEL, model.to_string());
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ use structopt::clap::SubCommand;
use structopt::StructOpt;

const NITROCLI_BINARY: &str = "NITROCLI_BINARY";
const NITROCLI_RESOLVED_USB_PATH: &str = "NITROCLI_RESOLVED_USB_PATH";
const NITROCLI_MODEL: &str = "NITROCLI_MODEL";
const NITROCLI_USB_PATH: &str = "NITROCLI_USB_PATH";
const NITROCLI_VERBOSITY: &str = "NITROCLI_VERBOSITY";