From: Nikos Mavrogiannopoulos Date: Wed, 2 Jul 2014 13:54:24 +0000 (+0200) Subject: p11tool: use GNUTLS_PIN and GNUTLS_SO_PIN when setting the PINs of an initialized... X-Git-Tag: gnutls_3_3_6~70 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=037107ee9200bfb023b9be30dc3f82ce9b277eaa;p=thirdparty%2Fgnutls.git p11tool: use GNUTLS_PIN and GNUTLS_SO_PIN when setting the PINs of an initialized token. --- diff --git a/src/p11tool-args.def b/src/p11tool-args.def index 043e187944..971009a84b 100644 --- a/src/p11tool-args.def +++ b/src/p11tool-args.def @@ -272,14 +272,14 @@ flag = { name = set-pin; arg-type = string; descrip = "Specify the PIN to use on token initialization"; - doc = ""; + doc = "Alternatively the GNUTLS_PIN environment variable may be used."; }; flag = { name = set-so-pin; arg-type = string; descrip = "Specify the Security Officer's PIN to use on token initialization"; - doc = ""; + doc = "Alternatively the GNUTLS_SO_PIN environment variable may be used."; }; flag = { diff --git a/src/pkcs11.c b/src/pkcs11.c index 8bfeb02294..5e6806b049 100644 --- a/src/pkcs11.c +++ b/src/pkcs11.c @@ -593,7 +593,9 @@ pkcs11_init(FILE * outfile, const char *url, const char *label, if (info->so_pin != NULL) pin = info->so_pin; else { - pin = getpass("Enter Security Officer's PIN: "); + pin = getenv("GNUTLS_SO_PIN"); + if (pin == NULL && info->batch == 0) + pin = getpass("Enter Security Officer's PIN: "); if (pin == NULL) exit(1); } @@ -603,10 +605,12 @@ pkcs11_init(FILE * outfile, const char *url, const char *label, strcpy(so_pin, pin); - if (info->so_pin != NULL) + if (info->so_pin != NULL) { pin = info->pin; - else { - pin = getpass("Enter new User's PIN: "); + } else { + pin = getenv("GNUTLS_PIN"); + if (pin == NULL && info->batch == 0) + pin = getpass("Enter new User's PIN: "); if (pin == NULL) exit(1); }