mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
card: Add option --use-default-pin to command "login".
* tools/gpg-card.c (cmd_login): Add option.
This commit is contained in:
parent
964363e788
commit
73bad368da
@ -1600,15 +1600,20 @@ cmd_login (card_info_t info, char *argstr)
|
|||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
char *data;
|
char *data;
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
|
int use_default_pin;
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
return print_help
|
return print_help
|
||||||
("LOGIN [--clear] [< FILE]\n\n"
|
("LOGIN [--clear|--use-default-pin] [< FILE]\n\n"
|
||||||
"Set the login data object. If FILE is given the data is\n"
|
"Set the login data object. If FILE is given the data is\n"
|
||||||
"is read from that file. This allows for binary data.\n"
|
"is read from that file. This allows for binary data.\n"
|
||||||
"The option --clear deletes the login data.",
|
"The option --clear deletes the login data. --use-default-pin\n"
|
||||||
|
"tells the card to always use the default PIN (\"123456\").",
|
||||||
APP_TYPE_OPENPGP, 0);
|
APP_TYPE_OPENPGP, 0);
|
||||||
|
|
||||||
|
use_default_pin = has_leading_option (argstr, "--use-default-pin");
|
||||||
|
argstr = skip_options (argstr);
|
||||||
|
|
||||||
if (!strcmp (argstr, "--clear"))
|
if (!strcmp (argstr, "--clear"))
|
||||||
{
|
{
|
||||||
data = xstrdup (" "); /* kludge. */
|
data = xstrdup (" "); /* kludge. */
|
||||||
@ -1627,7 +1632,7 @@ cmd_login (card_info_t info, char *argstr)
|
|||||||
data = tty_get (_("Login data (account name): "));
|
data = tty_get (_("Login data (account name): "));
|
||||||
trim_spaces (data);
|
trim_spaces (data);
|
||||||
tty_kill_prompt ();
|
tty_kill_prompt ();
|
||||||
if (!*data || *data == CONTROL_D)
|
if ((!*data && !use_default_pin) || *data == CONTROL_D)
|
||||||
{
|
{
|
||||||
err = gpg_error (GPG_ERR_CANCELED);
|
err = gpg_error (GPG_ERR_CANCELED);
|
||||||
goto leave;
|
goto leave;
|
||||||
@ -1635,6 +1640,16 @@ cmd_login (card_info_t info, char *argstr)
|
|||||||
datalen = strlen (data);
|
datalen = strlen (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_default_pin)
|
||||||
|
{
|
||||||
|
char *tmpdata = xmalloc (datalen + 5);
|
||||||
|
memcpy (tmpdata, data, datalen);
|
||||||
|
memcpy (tmpdata+datalen, "\n\x14" "F=3", 5);
|
||||||
|
xfree (data);
|
||||||
|
data = tmpdata;
|
||||||
|
datalen += 5;
|
||||||
|
}
|
||||||
|
|
||||||
err = scd_setattr ("LOGIN-DATA", data, datalen);
|
err = scd_setattr ("LOGIN-DATA", data, datalen);
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user