diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-08-25 15:56:49 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2017-08-27 15:58:28 +0200 |
commit | c81388aeb66802fe53b6eab6b2de65e1131c17e7 (patch) | |
tree | c5d04335490390ee0d1a07074680fce0eeb7c5dd | |
parent | 132191a48cf1fb97c8a7025592b4d8149cf52c7e (diff) | |
download | gnutls-c81388aeb66802fe53b6eab6b2de65e1131c17e7.tar.gz |
p11tool: allow obtaining PIN from command line on operations
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r-- | src/common.c | 12 | ||||
-rw-r--r-- | src/p11tool-args.def | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/common.c b/src/common.c index 931703ae21..8147d0a045 100644 --- a/src/common.c +++ b/src/common.c @@ -989,9 +989,13 @@ pin_callback(void *user, int attempt, const char *token_url, if (flags & GNUTLS_PIN_SO) { env = "GNUTLS_SO_PIN"; desc = "security officer"; + if (info) + password = info->so_pin; } else { env = "GNUTLS_PIN"; desc = "user"; + if (info) + password = info->pin; } if (flags & GNUTLS_PIN_FINAL_TRY) { @@ -1025,9 +1029,11 @@ pin_callback(void *user, int attempt, const char *token_url, } } - password = getenv(env); - if (password == NULL) /* compatibility */ - password = getenv("GNUTLS_PIN"); + if (password == NULL) { + password = getenv(env); + if (password == NULL) /* compatibility */ + password = getenv("GNUTLS_PIN"); + } if (password == NULL && (info == NULL || info->batch == 0)) { fprintf(stderr, "Token '%s' with URL '%s' ", token_label, token_url); diff --git a/src/p11tool-args.def b/src/p11tool-args.def index be97aeddc8..dce6225b4d 100644 --- a/src/p11tool-args.def +++ b/src/p11tool-args.def @@ -64,7 +64,7 @@ flag = { flag = { name = set-pin; arg-type = string; - descrip = "Specify the PIN to use on token initialization"; + descrip = "Specify the PIN to use on token operations"; doc = "Alternatively the GNUTLS_PIN environment variable may be used."; }; |