mirror of
git://git.gnupg.org/gnupg.git
synced 2024-10-29 19:48:43 +01:00
scd: New getinfo subcommand "manufacturer"
* scd/command.c (cmd_getinfo): Add subcommand "manufacturer".
* scd/app-openpgp.c (get_manufacturer): Rename to ...
(app_openpgp_manufacturer): this and make global.
--
Example:
$ gpg-connect-agent 'scd getinfo manufacturer 42' /bye
D Magrathea
OK
Backported-from-master: a8cef7ebc2
This commit is contained in:
parent
dfc400a2d9
commit
1d0874c3d2
@ -286,6 +286,7 @@ gpg_error_t app_check_pin (app_t app, ctrl_t ctrl, const char *keyidstr,
|
||||
|
||||
/*-- app-openpgp.c --*/
|
||||
gpg_error_t app_select_openpgp (app_t app);
|
||||
const char *app_openpgp_manufacturer (unsigned int no);
|
||||
|
||||
/*-- app-nks.c --*/
|
||||
gpg_error_t app_select_nks (app_t app);
|
||||
|
@ -279,8 +279,8 @@ static gpg_error_t change_keyattr_from_string
|
||||
|
||||
|
||||
/* Return the OpenPGP card manufacturer name. */
|
||||
static const char *
|
||||
get_manufacturer (unsigned int no)
|
||||
const char *
|
||||
app_openpgp_manufacturer (unsigned int no)
|
||||
{
|
||||
/* Note: Make sure that there is no colon or linefeed in the string. */
|
||||
switch (no)
|
||||
@ -1207,7 +1207,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
|
||||
return send_status_printf
|
||||
(ctrl, table[idx].name, "%u %s",
|
||||
app->app_local->manufacturer,
|
||||
get_manufacturer (app->app_local->manufacturer));
|
||||
app_openpgp_manufacturer (app->app_local->manufacturer));
|
||||
}
|
||||
if (table[idx].special == -9)
|
||||
{
|
||||
|
@ -1470,15 +1470,18 @@ static const char hlp_getinfo[] =
|
||||
" application per line, fields delimited by colons,\n"
|
||||
" first field is the name.\n"
|
||||
" card_list - Return a list of serial numbers of active cards,\n"
|
||||
" using a status response.";
|
||||
" using a status response."
|
||||
" manufacturer NUMBER\n"
|
||||
" - Return a description of the OpenPGP manufacturer id.\n";
|
||||
static gpg_error_t
|
||||
cmd_getinfo (assuan_context_t ctx, char *line)
|
||||
{
|
||||
int rc = 0;
|
||||
const char *s;
|
||||
|
||||
if (!strcmp (line, "version"))
|
||||
{
|
||||
const char *s = VERSION;
|
||||
s = VERSION;
|
||||
rc = assuan_send_data (ctx, s, strlen (s));
|
||||
}
|
||||
else if (!strcmp (line, "pid"))
|
||||
@ -1490,7 +1493,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
||||
}
|
||||
else if (!strcmp (line, "socket_name"))
|
||||
{
|
||||
const char *s = scd_get_socket_name ();
|
||||
s = scd_get_socket_name ();
|
||||
|
||||
if (s)
|
||||
rc = assuan_send_data (ctx, s, strlen (s));
|
||||
@ -1518,30 +1521,35 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
||||
}
|
||||
else if (!strcmp (line, "reader_list"))
|
||||
{
|
||||
char *s = apdu_get_reader_list ();
|
||||
if (s)
|
||||
rc = pretty_assuan_send_data (ctx, s, strlen (s));
|
||||
char *p = apdu_get_reader_list ();
|
||||
if (p)
|
||||
rc = pretty_assuan_send_data (ctx, p, strlen (p));
|
||||
else
|
||||
rc = gpg_error (GPG_ERR_NO_DATA);
|
||||
xfree (s);
|
||||
xfree (p);
|
||||
}
|
||||
else if (!strcmp (line, "deny_admin"))
|
||||
rc = opt.allow_admin? gpg_error (GPG_ERR_GENERAL) : 0;
|
||||
else if (!strcmp (line, "app_list"))
|
||||
{
|
||||
char *s = get_supported_applications ();
|
||||
if (s)
|
||||
rc = assuan_send_data (ctx, s, strlen (s));
|
||||
char *p = get_supported_applications ();
|
||||
if (p)
|
||||
rc = assuan_send_data (ctx, p, strlen (p));
|
||||
else
|
||||
rc = 0;
|
||||
xfree (s);
|
||||
xfree (p);
|
||||
}
|
||||
else if (!strcmp (line, "card_list"))
|
||||
{
|
||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||
|
||||
app_send_card_list (ctrl);
|
||||
}
|
||||
else if ((s=has_leading_keyword (line, "manufacturer")))
|
||||
{
|
||||
unsigned long ul = strtoul (s, NULL, 0);
|
||||
s = app_openpgp_manufacturer (ul);
|
||||
rc = assuan_send_data (ctx, s, strlen (s));
|
||||
}
|
||||
else
|
||||
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
|
||||
return rc;
|
||||
|
Loading…
Reference in New Issue
Block a user