pkcs11-tool: allow non-interactive change of User/SO PIN
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5543 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
438cf4b2d4
commit
a479c368a6
|
@ -1150,6 +1150,7 @@ static int change_pin(CK_SLOT_ID slot, CK_SESSION_HANDLE sess)
|
|||
get_token_info(slot, &info);
|
||||
|
||||
if (!(info.flags & CKF_PROTECTED_AUTHENTICATION_PATH)) {
|
||||
if (!opt_pin && !opt_so_pin) {
|
||||
printf("Please enter the current PIN: ");
|
||||
r = util_getpass(&old_pin, &len, stdin);
|
||||
if (r < 0)
|
||||
|
@ -1158,7 +1159,15 @@ static int change_pin(CK_SLOT_ID slot, CK_SESSION_HANDLE sess)
|
|||
return 1;
|
||||
strcpy(old_buf, old_pin);
|
||||
old_pin = old_buf;
|
||||
}
|
||||
else {
|
||||
if (opt_so_pin)
|
||||
old_pin = opt_so_pin;
|
||||
else
|
||||
old_pin = opt_pin;
|
||||
}
|
||||
|
||||
if (!opt_new_pin) {
|
||||
printf("Please enter the new PIN: ");
|
||||
r = util_getpass(&new_pin, &len, stdin);
|
||||
if (r < 0)
|
||||
|
@ -1174,6 +1183,10 @@ static int change_pin(CK_SLOT_ID slot, CK_SESSION_HANDLE sess)
|
|||
if (!new_pin || !*new_pin || strcmp(new_buf, new_pin) != 0)
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
new_pin = opt_new_pin;
|
||||
}
|
||||
}
|
||||
|
||||
rv = p11->C_SetPIN(sess,
|
||||
(CK_UTF8CHAR *) old_pin, old_pin == NULL ? 0 : strlen(old_pin),
|
||||
|
|
Loading…
Reference in New Issue