mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
Remove trailing white space from some files
--
This commit is contained in:
parent
d5c46ac6f4
commit
c0a20d6124
File diff suppressed because it is too large
Load Diff
170
scd/command.c
170
scd/command.c
@ -76,7 +76,7 @@ static int reader_disabled;
|
|||||||
|
|
||||||
|
|
||||||
/* This structure is used to keep track of open readers (slots). */
|
/* This structure is used to keep track of open readers (slots). */
|
||||||
struct slot_status_s
|
struct slot_status_s
|
||||||
{
|
{
|
||||||
int valid; /* True if the other objects are valid. */
|
int valid; /* True if the other objects are valid. */
|
||||||
int slot; /* Slot number of the reader or -1 if not open. */
|
int slot; /* Slot number of the reader or -1 if not open. */
|
||||||
@ -93,11 +93,11 @@ struct slot_status_s
|
|||||||
|
|
||||||
/* Data used to associate an Assuan context with local server data.
|
/* Data used to associate an Assuan context with local server data.
|
||||||
This object describes the local properties of one session. */
|
This object describes the local properties of one session. */
|
||||||
struct server_local_s
|
struct server_local_s
|
||||||
{
|
{
|
||||||
/* We keep a list of all active sessions with the anchor at
|
/* We keep a list of all active sessions with the anchor at
|
||||||
SESSION_LIST (see below). This field is used for linking. */
|
SESSION_LIST (see below). This field is used for linking. */
|
||||||
struct server_local_s *next_session;
|
struct server_local_s *next_session;
|
||||||
|
|
||||||
/* This object is usually assigned to a CTRL object (which is
|
/* This object is usually assigned to a CTRL object (which is
|
||||||
globally visible). While enumerating all sessions we sometimes
|
globally visible). While enumerating all sessions we sometimes
|
||||||
@ -113,10 +113,10 @@ struct server_local_s
|
|||||||
#else
|
#else
|
||||||
int event_signal; /* Or 0 if not used. */
|
int event_signal; /* Or 0 if not used. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* True if the card has been removed and a reset is required to
|
/* True if the card has been removed and a reset is required to
|
||||||
continue operation. */
|
continue operation. */
|
||||||
int card_removed;
|
int card_removed;
|
||||||
|
|
||||||
/* Flag indicating that the application context needs to be released
|
/* Flag indicating that the application context needs to be released
|
||||||
at the next opportunity. */
|
at the next opportunity. */
|
||||||
@ -127,7 +127,7 @@ struct server_local_s
|
|||||||
|
|
||||||
/* If set to true we will be terminate ourself at the end of the
|
/* If set to true we will be terminate ourself at the end of the
|
||||||
this session. */
|
this session. */
|
||||||
int stopme;
|
int stopme;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ hex_to_buffer (const char *string, size_t *r_length)
|
|||||||
return NULL;
|
return NULL;
|
||||||
for (s=string, n=0; *s; s++)
|
for (s=string, n=0; *s; s++)
|
||||||
{
|
{
|
||||||
if (spacep (s) || *s == ':')
|
if (spacep (s) || *s == ':')
|
||||||
continue;
|
continue;
|
||||||
if (hexdigitp (s) && hexdigitp (s+1))
|
if (hexdigitp (s) && hexdigitp (s+1))
|
||||||
{
|
{
|
||||||
@ -297,7 +297,7 @@ do_reset (ctrl_t ctrl, int send_reset)
|
|||||||
if (send_reset)
|
if (send_reset)
|
||||||
{
|
{
|
||||||
struct server_local_s *sl;
|
struct server_local_s *sl;
|
||||||
|
|
||||||
for (sl=session_list; sl; sl = sl->next_session)
|
for (sl=session_list; sl; sl = sl->next_session)
|
||||||
if (sl->ctrl_backlink
|
if (sl->ctrl_backlink
|
||||||
&& sl->ctrl_backlink->reader_slot == slot)
|
&& sl->ctrl_backlink->reader_slot == slot)
|
||||||
@ -357,7 +357,7 @@ do_reset (ctrl_t ctrl, int send_reset)
|
|||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
reset_notify (assuan_context_t ctx, char *line)
|
reset_notify (assuan_context_t ctx, char *line)
|
||||||
{
|
{
|
||||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||||
|
|
||||||
(void) line;
|
(void) line;
|
||||||
|
|
||||||
@ -503,7 +503,7 @@ open_card (ctrl_t ctrl, const char *apptype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_serialno[] =
|
static const char hlp_serialno[] =
|
||||||
"SERIALNO [<apptype>]\n"
|
"SERIALNO [<apptype>]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Return the serial number of the card using a status reponse. This\n"
|
"Return the serial number of the card using a status reponse. This\n"
|
||||||
@ -565,7 +565,7 @@ cmd_serialno (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_learn[] =
|
static const char hlp_learn[] =
|
||||||
"LEARN [--force] [--keypairinfo]\n"
|
"LEARN [--force] [--keypairinfo]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Learn all useful information of the currently inserted card. When\n"
|
"Learn all useful information of the currently inserted card. When\n"
|
||||||
@ -653,7 +653,7 @@ cmd_learn (assuan_context_t ctx, char *line)
|
|||||||
char *serial_and_stamp;
|
char *serial_and_stamp;
|
||||||
char *serial;
|
char *serial;
|
||||||
time_t stamp;
|
time_t stamp;
|
||||||
|
|
||||||
rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp);
|
rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
@ -664,11 +664,11 @@ cmd_learn (assuan_context_t ctx, char *line)
|
|||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
rc = 0;
|
rc = 0;
|
||||||
assuan_write_status (ctx, "SERIALNO", serial_and_stamp);
|
assuan_write_status (ctx, "SERIALNO", serial_and_stamp);
|
||||||
|
|
||||||
if (!has_option (line, "--force"))
|
if (!has_option (line, "--force"))
|
||||||
{
|
{
|
||||||
char *command;
|
char *command;
|
||||||
|
|
||||||
rc = estream_asprintf (&command, "KNOWNCARDP %s", serial_and_stamp);
|
rc = estream_asprintf (&command, "KNOWNCARDP %s", serial_and_stamp);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
@ -676,7 +676,7 @@ cmd_learn (assuan_context_t ctx, char *line)
|
|||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
}
|
}
|
||||||
rc = 0;
|
rc = 0;
|
||||||
rc = assuan_inquire (ctx, command, NULL, NULL, 0);
|
rc = assuan_inquire (ctx, command, NULL, NULL, 0);
|
||||||
xfree (command);
|
xfree (command);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
@ -684,13 +684,13 @@ cmd_learn (assuan_context_t ctx, char *line)
|
|||||||
log_error ("inquire KNOWNCARDP failed: %s\n",
|
log_error ("inquire KNOWNCARDP failed: %s\n",
|
||||||
gpg_strerror (rc));
|
gpg_strerror (rc));
|
||||||
xfree (serial_and_stamp);
|
xfree (serial_and_stamp);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
/* Not canceled, so we have to proceeed. */
|
/* Not canceled, so we have to proceeed. */
|
||||||
}
|
}
|
||||||
xfree (serial_and_stamp);
|
xfree (serial_and_stamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the application print out its collection of useful status
|
/* Let the application print out its collection of useful status
|
||||||
information. */
|
information. */
|
||||||
if (!rc)
|
if (!rc)
|
||||||
@ -736,7 +736,7 @@ cmd_readcert (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_readkey[] =
|
static const char hlp_readkey[] =
|
||||||
"READKEY <keyid>\n"
|
"READKEY <keyid>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Return the public key for the given cert or key ID as a standard\n"
|
"Return the public key for the given cert or key ID as a standard\n"
|
||||||
@ -774,7 +774,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||||||
|
|
||||||
if (gpg_err_code (rc) != GPG_ERR_UNSUPPORTED_OPERATION)
|
if (gpg_err_code (rc) != GPG_ERR_UNSUPPORTED_OPERATION)
|
||||||
log_error ("app_readkey failed: %s\n", gpg_strerror (rc));
|
log_error ("app_readkey failed: %s\n", gpg_strerror (rc));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rc = app_readcert (ctrl->app_ctx, line, &cert, &ncert);
|
rc = app_readcert (ctrl->app_ctx, line, &cert, &ncert);
|
||||||
if (rc)
|
if (rc)
|
||||||
@ -784,7 +784,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||||||
line = NULL;
|
line = NULL;
|
||||||
if (rc)
|
if (rc)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
rc = ksba_cert_new (&kc);
|
rc = ksba_cert_new (&kc);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
@ -819,7 +819,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_setdata[] =
|
static const char hlp_setdata[] =
|
||||||
"SETDATA <hexstring> \n"
|
"SETDATA <hexstring> \n"
|
||||||
"\n"
|
"\n"
|
||||||
"The client should use this command to tell us the data he want to sign.";
|
"The client should use this command to tell us the data he want to sign.";
|
||||||
@ -857,7 +857,7 @@ cmd_setdata (assuan_context_t ctx, char *line)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
pin_cb (void *opaque, const char *info, char **retstr)
|
pin_cb (void *opaque, const char *info, char **retstr)
|
||||||
{
|
{
|
||||||
assuan_context_t ctx = opaque;
|
assuan_context_t ctx = opaque;
|
||||||
@ -877,14 +877,14 @@ pin_cb (void *opaque, const char *info, char **retstr)
|
|||||||
rc = estream_asprintf (&command, "POPUPKEYPADPROMPT %s", info);
|
rc = estream_asprintf (&command, "POPUPKEYPADPROMPT %s", info);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return gpg_error (gpg_err_code_from_errno (errno));
|
return gpg_error (gpg_err_code_from_errno (errno));
|
||||||
rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN);
|
rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN);
|
||||||
xfree (command);
|
xfree (command);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_debug ("dismiss keypad entry prompt\n");
|
log_debug ("dismiss keypad entry prompt\n");
|
||||||
rc = assuan_inquire (ctx, "DISMISSKEYPADPROMPT",
|
rc = assuan_inquire (ctx, "DISMISSKEYPADPROMPT",
|
||||||
&value, &valuelen, MAXLEN_PIN);
|
&value, &valuelen, MAXLEN_PIN);
|
||||||
}
|
}
|
||||||
if (!rc)
|
if (!rc)
|
||||||
xfree (value);
|
xfree (value);
|
||||||
@ -900,8 +900,8 @@ pin_cb (void *opaque, const char *info, char **retstr)
|
|||||||
|
|
||||||
/* Fixme: Write an inquire function which returns the result in
|
/* Fixme: Write an inquire function which returns the result in
|
||||||
secure memory and check all further handling of the PIN. */
|
secure memory and check all further handling of the PIN. */
|
||||||
rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN);
|
rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN);
|
||||||
xfree (command);
|
xfree (command);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -916,7 +916,7 @@ pin_cb (void *opaque, const char *info, char **retstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_pksign[] =
|
static const char hlp_pksign[] =
|
||||||
"PKSIGN [--hash=[rmd160|sha{1,224,256,384,512}|md5]] <hexified_id>\n"
|
"PKSIGN [--hash=[rmd160|sha{1,224,256,384,512}|md5]] <hexified_id>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"The --hash option is optional; the default is SHA1.";
|
"The --hash option is optional; the default is SHA1.";
|
||||||
@ -945,7 +945,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
|
|||||||
else if (has_option (line, "--hash=md5"))
|
else if (has_option (line, "--hash=md5"))
|
||||||
hash_algo = GCRY_MD_MD5;
|
hash_algo = GCRY_MD_MD5;
|
||||||
else if (!strstr (line, "--"))
|
else if (!strstr (line, "--"))
|
||||||
hash_algo = GCRY_MD_SHA1;
|
hash_algo = GCRY_MD_SHA1;
|
||||||
else
|
else
|
||||||
return set_error (GPG_ERR_ASS_PARAMETER, "invalid hash algorithm");
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid hash algorithm");
|
||||||
|
|
||||||
@ -963,7 +963,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
|
|||||||
keyidstr = xtrystrdup (line);
|
keyidstr = xtrystrdup (line);
|
||||||
if (!keyidstr)
|
if (!keyidstr)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
|
|
||||||
rc = app_sign (ctrl->app_ctx,
|
rc = app_sign (ctrl->app_ctx,
|
||||||
keyidstr, hash_algo,
|
keyidstr, hash_algo,
|
||||||
pin_cb, ctx,
|
pin_cb, ctx,
|
||||||
@ -988,7 +988,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_pkauth[] =
|
static const char hlp_pkauth[] =
|
||||||
"PKAUTH <hexified_id>";
|
"PKAUTH <hexified_id>";
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
cmd_pkauth (assuan_context_t ctx, char *line)
|
cmd_pkauth (assuan_context_t ctx, char *line)
|
||||||
@ -1014,7 +1014,7 @@ cmd_pkauth (assuan_context_t ctx, char *line)
|
|||||||
keyidstr = xtrystrdup (line);
|
keyidstr = xtrystrdup (line);
|
||||||
if (!keyidstr)
|
if (!keyidstr)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
|
|
||||||
rc = app_auth (ctrl->app_ctx,
|
rc = app_auth (ctrl->app_ctx,
|
||||||
keyidstr,
|
keyidstr,
|
||||||
pin_cb, ctx,
|
pin_cb, ctx,
|
||||||
@ -1038,7 +1038,7 @@ cmd_pkauth (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_pkdecrypt[] =
|
static const char hlp_pkdecrypt[] =
|
||||||
"PKDECRYPT <hexified_id>";
|
"PKDECRYPT <hexified_id>";
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
cmd_pkdecrypt (assuan_context_t ctx, char *line)
|
cmd_pkdecrypt (assuan_context_t ctx, char *line)
|
||||||
@ -1059,7 +1059,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
|
|||||||
if (!keyidstr)
|
if (!keyidstr)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
rc = app_decipher (ctrl->app_ctx,
|
rc = app_decipher (ctrl->app_ctx,
|
||||||
keyidstr,
|
keyidstr,
|
||||||
pin_cb, ctx,
|
pin_cb, ctx,
|
||||||
ctrl->in_data.value, ctrl->in_data.valuelen,
|
ctrl->in_data.value, ctrl->in_data.valuelen,
|
||||||
&outdata, &outdatalen);
|
&outdata, &outdatalen);
|
||||||
@ -1082,7 +1082,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_getattr[] =
|
static const char hlp_getattr[] =
|
||||||
"GETATTR <name>\n"
|
"GETATTR <name>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"This command is used to retrieve data from a smartcard. The\n"
|
"This command is used to retrieve data from a smartcard. The\n"
|
||||||
@ -1121,7 +1121,7 @@ cmd_getattr (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_setattr[] =
|
static const char hlp_setattr[] =
|
||||||
"SETATTR <name> <value> \n"
|
"SETATTR <name> <value> \n"
|
||||||
"\n"
|
"\n"
|
||||||
"This command is used to store data on a a smartcard. The allowed\n"
|
"This command is used to store data on a a smartcard. The allowed\n"
|
||||||
@ -1174,7 +1174,7 @@ cmd_setattr (assuan_context_t ctx, char *orig_line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_writecert[] =
|
static const char hlp_writecert[] =
|
||||||
"WRITECERT <hexified_certid>\n"
|
"WRITECERT <hexified_certid>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"This command is used to store a certifciate on a smartcard. The\n"
|
"This command is used to store a certifciate on a smartcard. The\n"
|
||||||
@ -1226,7 +1226,7 @@ cmd_writecert (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write the certificate to the card. */
|
/* Write the certificate to the card. */
|
||||||
rc = app_writecert (ctrl->app_ctx, ctrl, certid,
|
rc = app_writecert (ctrl->app_ctx, ctrl, certid,
|
||||||
pin_cb, ctx, certdata, certdatalen);
|
pin_cb, ctx, certdata, certdatalen);
|
||||||
xfree (certid);
|
xfree (certid);
|
||||||
xfree (certdata);
|
xfree (certdata);
|
||||||
@ -1236,7 +1236,7 @@ cmd_writecert (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_writekey[] =
|
static const char hlp_writekey[] =
|
||||||
"WRITEKEY [--force] <keyid> \n"
|
"WRITEKEY [--force] <keyid> \n"
|
||||||
"\n"
|
"\n"
|
||||||
"This command is used to store a secret key on a a smartcard. The\n"
|
"This command is used to store a secret key on a a smartcard. The\n"
|
||||||
@ -1303,7 +1303,7 @@ cmd_writekey (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_genkey[] =
|
static const char hlp_genkey[] =
|
||||||
"GENKEY [--force] [--timestamp=<isodate>] <no>\n"
|
"GENKEY [--force] [--timestamp=<isodate>] <no>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Generate a key on-card identified by NO, which is application\n"
|
"Generate a key on-card identified by NO, which is application\n"
|
||||||
@ -1381,7 +1381,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_random[] =
|
static const char hlp_random[] =
|
||||||
"RANDOM <nbytes>\n"
|
"RANDOM <nbytes>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Get NBYTES of random from the card and send them back as data.\n"
|
"Get NBYTES of random from the card and send them back as data.\n"
|
||||||
@ -1398,7 +1398,7 @@ cmd_random (assuan_context_t ctx, char *line)
|
|||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
|
|
||||||
if (!*line)
|
if (!*line)
|
||||||
return set_error (GPG_ERR_ASS_PARAMETER,
|
return set_error (GPG_ERR_ASS_PARAMETER,
|
||||||
"number of requested bytes missing");
|
"number of requested bytes missing");
|
||||||
nbytes = strtoul (line, NULL, 0);
|
nbytes = strtoul (line, NULL, 0);
|
||||||
|
|
||||||
@ -1464,7 +1464,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
|
|||||||
|
|
||||||
if (!ctrl->app_ctx)
|
if (!ctrl->app_ctx)
|
||||||
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
|
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
|
||||||
|
|
||||||
chvnostr = xtrystrdup (chvnostr);
|
chvnostr = xtrystrdup (chvnostr);
|
||||||
if (!chvnostr)
|
if (!chvnostr)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
@ -1478,7 +1478,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_checkpin[] =
|
static const char hlp_checkpin[] =
|
||||||
"CHECKPIN <idstr>\n"
|
"CHECKPIN <idstr>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Perform a VERIFY operation without doing anything else. This may\n"
|
"Perform a VERIFY operation without doing anything else. This may\n"
|
||||||
@ -1532,7 +1532,7 @@ cmd_checkpin (assuan_context_t ctx, char *line)
|
|||||||
idstr = xtrystrdup (line);
|
idstr = xtrystrdup (line);
|
||||||
if (!idstr)
|
if (!idstr)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
|
|
||||||
rc = app_check_pin (ctrl->app_ctx, idstr, pin_cb, ctx);
|
rc = app_check_pin (ctrl->app_ctx, idstr, pin_cb, ctx);
|
||||||
xfree (idstr);
|
xfree (idstr);
|
||||||
if (rc)
|
if (rc)
|
||||||
@ -1543,7 +1543,7 @@ cmd_checkpin (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_lock[] =
|
static const char hlp_lock[] =
|
||||||
"LOCK [--wait]\n"
|
"LOCK [--wait]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Grant exclusive card access to this session. Note that there is\n"
|
"Grant exclusive card access to this session. Note that there is\n"
|
||||||
@ -1580,14 +1580,14 @@ cmd_lock (assuan_context_t ctx, char *line)
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
#endif /*USE_GNU_PTH*/
|
#endif /*USE_GNU_PTH*/
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
log_error ("cmd_lock failed: %s\n", gpg_strerror (rc));
|
log_error ("cmd_lock failed: %s\n", gpg_strerror (rc));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_unlock[] =
|
static const char hlp_unlock[] =
|
||||||
"UNLOCK\n"
|
"UNLOCK\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Release exclusive card access.";
|
"Release exclusive card access.";
|
||||||
@ -1615,7 +1615,7 @@ cmd_unlock (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_getinfo[] =
|
static const char hlp_getinfo[] =
|
||||||
"GETINFO <what>\n"
|
"GETINFO <what>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Multi purpose command to return certain information. \n"
|
"Multi purpose command to return certain information. \n"
|
||||||
@ -1677,7 +1677,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
if (!ctrl->server_local->card_removed && slot != -1)
|
if (!ctrl->server_local->card_removed && slot != -1)
|
||||||
{
|
{
|
||||||
struct slot_status_s *ss;
|
struct slot_status_s *ss;
|
||||||
|
|
||||||
if (!(slot >= 0 && slot < DIM(slot_table)))
|
if (!(slot >= 0 && slot < DIM(slot_table)))
|
||||||
BUG ();
|
BUG ();
|
||||||
|
|
||||||
@ -1695,7 +1695,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
#else
|
#else
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
rc = assuan_send_data (ctx, s, strlen (s));
|
rc = assuan_send_data (ctx, s, strlen (s));
|
||||||
else
|
else
|
||||||
@ -1719,7 +1719,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_restart[] =
|
static const char hlp_restart[] =
|
||||||
"RESTART\n"
|
"RESTART\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Restart the current connection; this is a kind of warm reset. It\n"
|
"Restart the current connection; this is a kind of warm reset. It\n"
|
||||||
@ -1750,7 +1750,7 @@ cmd_restart (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_disconnect[] =
|
static const char hlp_disconnect[] =
|
||||||
"DISCONNECT\n"
|
"DISCONNECT\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Disconnect the card if it is not any longer used by other\n"
|
"Disconnect the card if it is not any longer used by other\n"
|
||||||
@ -1761,14 +1761,14 @@ cmd_disconnect (assuan_context_t ctx, char *line)
|
|||||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||||
|
|
||||||
(void)line;
|
(void)line;
|
||||||
|
|
||||||
ctrl->server_local->disconnect_allowed = 1;
|
ctrl->server_local->disconnect_allowed = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_apdu[] =
|
static const char hlp_apdu[] =
|
||||||
"APDU [--atr] [--more] [--exlen[=N]] [hexstring]\n"
|
"APDU [--atr] [--more] [--exlen[=N]] [hexstring]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Send an APDU to the current reader. This command bypasses the high\n"
|
"Send an APDU to the current reader. This command bypasses the high\n"
|
||||||
@ -1825,7 +1825,7 @@ cmd_apdu (assuan_context_t ctx, char *line)
|
|||||||
unsigned char *atr;
|
unsigned char *atr;
|
||||||
size_t atrlen;
|
size_t atrlen;
|
||||||
char hexbuf[400];
|
char hexbuf[400];
|
||||||
|
|
||||||
atr = apdu_get_atr (ctrl->reader_slot, &atrlen);
|
atr = apdu_get_atr (ctrl->reader_slot, &atrlen);
|
||||||
if (!atr || atrlen > sizeof hexbuf - 2 )
|
if (!atr || atrlen > sizeof hexbuf - 2 )
|
||||||
{
|
{
|
||||||
@ -1867,7 +1867,7 @@ cmd_apdu (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_killscd[] =
|
static const char hlp_killscd[] =
|
||||||
"KILLSCD\n"
|
"KILLSCD\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Commit suicide.";
|
"Commit suicide.";
|
||||||
@ -1901,8 +1901,8 @@ register_commands (assuan_context_t ctx)
|
|||||||
{ "PKSIGN", cmd_pksign, hlp_pksign },
|
{ "PKSIGN", cmd_pksign, hlp_pksign },
|
||||||
{ "PKAUTH", cmd_pkauth, hlp_pkauth },
|
{ "PKAUTH", cmd_pkauth, hlp_pkauth },
|
||||||
{ "PKDECRYPT", cmd_pkdecrypt,hlp_pkdecrypt },
|
{ "PKDECRYPT", cmd_pkdecrypt,hlp_pkdecrypt },
|
||||||
{ "INPUT", NULL },
|
{ "INPUT", NULL },
|
||||||
{ "OUTPUT", NULL },
|
{ "OUTPUT", NULL },
|
||||||
{ "GETATTR", cmd_getattr, hlp_getattr },
|
{ "GETATTR", cmd_getattr, hlp_getattr },
|
||||||
{ "SETATTR", cmd_setattr, hlp_setattr },
|
{ "SETATTR", cmd_setattr, hlp_setattr },
|
||||||
{ "WRITECERT", cmd_writecert,hlp_writecert },
|
{ "WRITECERT", cmd_writecert,hlp_writecert },
|
||||||
@ -1928,7 +1928,7 @@ register_commands (assuan_context_t ctx)
|
|||||||
table[i].help);
|
table[i].help);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
assuan_set_hello_line (ctx, "GNU Privacy Guard's Smartcard server ready");
|
assuan_set_hello_line (ctx, "GNU Privacy Guard's Smartcard server ready");
|
||||||
|
|
||||||
assuan_register_reset_notify (ctx, reset_notify);
|
assuan_register_reset_notify (ctx, reset_notify);
|
||||||
@ -1946,7 +1946,7 @@ scd_command_handler (ctrl_t ctrl, int fd)
|
|||||||
int rc;
|
int rc;
|
||||||
assuan_context_t ctx = NULL;
|
assuan_context_t ctx = NULL;
|
||||||
int stopme;
|
int stopme;
|
||||||
|
|
||||||
rc = assuan_new (&ctx);
|
rc = assuan_new (&ctx);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
@ -2014,7 +2014,7 @@ scd_command_handler (ctrl_t ctrl, int fd)
|
|||||||
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
|
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = assuan_process (ctx);
|
rc = assuan_process (ctx);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
@ -2024,7 +2024,7 @@ scd_command_handler (ctrl_t ctrl, int fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup. We don't send an explicit reset to the card. */
|
/* Cleanup. We don't send an explicit reset to the card. */
|
||||||
do_reset (ctrl, 0);
|
do_reset (ctrl, 0);
|
||||||
|
|
||||||
/* Release the server object. */
|
/* Release the server object. */
|
||||||
if (session_list == ctrl->server_local)
|
if (session_list == ctrl->server_local)
|
||||||
@ -2032,7 +2032,7 @@ scd_command_handler (ctrl_t ctrl, int fd)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct server_local_s *sl;
|
struct server_local_s *sl;
|
||||||
|
|
||||||
for (sl=session_list; sl->next_session; sl = sl->next_session)
|
for (sl=session_list; sl->next_session; sl = sl->next_session)
|
||||||
if (sl->next_session == ctrl->server_local)
|
if (sl->next_session == ctrl->server_local)
|
||||||
break;
|
break;
|
||||||
@ -2067,10 +2067,10 @@ send_status_info (ctrl_t ctrl, const char *keyword, ...)
|
|||||||
char buf[950], *p;
|
char buf[950], *p;
|
||||||
size_t n;
|
size_t n;
|
||||||
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
||||||
|
|
||||||
va_start (arg_ptr, keyword);
|
va_start (arg_ptr, keyword);
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
n = 0;
|
n = 0;
|
||||||
while ( (value = va_arg (arg_ptr, const unsigned char *)) )
|
while ( (value = va_arg (arg_ptr, const unsigned char *)) )
|
||||||
{
|
{
|
||||||
@ -2120,17 +2120,17 @@ static void
|
|||||||
send_client_notifications (void)
|
send_client_notifications (void)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
#else
|
#else
|
||||||
int signo;
|
int signo;
|
||||||
#endif
|
#endif
|
||||||
} killed[50];
|
} killed[50];
|
||||||
int killidx = 0;
|
int killidx = 0;
|
||||||
int kidx;
|
int kidx;
|
||||||
struct server_local_s *sl;
|
struct server_local_s *sl;
|
||||||
|
|
||||||
for (sl=session_list; sl; sl = sl->next_session)
|
for (sl=session_list; sl; sl = sl->next_session)
|
||||||
{
|
{
|
||||||
if (sl->event_signal && sl->assuan_ctx)
|
if (sl->event_signal && sl->assuan_ctx)
|
||||||
@ -2138,9 +2138,9 @@ send_client_notifications (void)
|
|||||||
pid_t pid = assuan_get_pid (sl->assuan_ctx);
|
pid_t pid = assuan_get_pid (sl->assuan_ctx);
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
HANDLE handle = (void *)sl->event_signal;
|
HANDLE handle = (void *)sl->event_signal;
|
||||||
|
|
||||||
for (kidx=0; kidx < killidx; kidx++)
|
for (kidx=0; kidx < killidx; kidx++)
|
||||||
if (killed[kidx].pid == pid
|
if (killed[kidx].pid == pid
|
||||||
&& killed[kidx].handle == handle)
|
&& killed[kidx].handle == handle)
|
||||||
break;
|
break;
|
||||||
if (kidx < killidx)
|
if (kidx < killidx)
|
||||||
@ -2162,11 +2162,11 @@ send_client_notifications (void)
|
|||||||
}
|
}
|
||||||
#else /*!HAVE_W32_SYSTEM*/
|
#else /*!HAVE_W32_SYSTEM*/
|
||||||
int signo = sl->event_signal;
|
int signo = sl->event_signal;
|
||||||
|
|
||||||
if (pid != (pid_t)(-1) && pid && signo > 0)
|
if (pid != (pid_t)(-1) && pid && signo > 0)
|
||||||
{
|
{
|
||||||
for (kidx=0; kidx < killidx; kidx++)
|
for (kidx=0; kidx < killidx; kidx++)
|
||||||
if (killed[kidx].pid == pid
|
if (killed[kidx].pid == pid
|
||||||
&& killed[kidx].signo == signo)
|
&& killed[kidx].signo == signo)
|
||||||
break;
|
break;
|
||||||
if (kidx < killidx)
|
if (kidx < killidx)
|
||||||
@ -2217,7 +2217,7 @@ update_reader_status_file (int set_card_removed_flag)
|
|||||||
|
|
||||||
if (!ss->valid || ss->slot == -1)
|
if (!ss->valid || ss->slot == -1)
|
||||||
continue; /* Not valid or reader not yet open. */
|
continue; /* Not valid or reader not yet open. */
|
||||||
|
|
||||||
sw_apdu = apdu_get_status (ss->slot, 0, &status, &changed);
|
sw_apdu = apdu_get_status (ss->slot, 0, &status, &changed);
|
||||||
if (sw_apdu == SW_HOST_NO_READER)
|
if (sw_apdu == SW_HOST_NO_READER)
|
||||||
{
|
{
|
||||||
@ -2231,7 +2231,7 @@ update_reader_status_file (int set_card_removed_flag)
|
|||||||
else if (sw_apdu)
|
else if (sw_apdu)
|
||||||
{
|
{
|
||||||
/* Get status failed. Ignore that. */
|
/* Get status failed. Ignore that. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ss->any || ss->status != status || ss->changed != changed )
|
if (!ss->any || ss->status != status || ss->changed != changed )
|
||||||
@ -2260,14 +2260,14 @@ update_reader_status_file (int set_card_removed_flag)
|
|||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
xfree (fname);
|
xfree (fname);
|
||||||
|
|
||||||
/* If a status script is executable, run it. */
|
/* If a status script is executable, run it. */
|
||||||
{
|
{
|
||||||
const char *args[9], *envs[2];
|
const char *args[9], *envs[2];
|
||||||
char numbuf1[30], numbuf2[30], numbuf3[30];
|
char numbuf1[30], numbuf2[30], numbuf3[30];
|
||||||
char *homestr, *envstr;
|
char *homestr, *envstr;
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
|
|
||||||
homestr = make_filename (opt.homedir, NULL);
|
homestr = make_filename (opt.homedir, NULL);
|
||||||
if (estream_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0)
|
if (estream_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0)
|
||||||
log_error ("out of core while building environment\n");
|
log_error ("out of core while building environment\n");
|
||||||
@ -2280,16 +2280,16 @@ update_reader_status_file (int set_card_removed_flag)
|
|||||||
sprintf (numbuf2, "0x%04X", ss->status);
|
sprintf (numbuf2, "0x%04X", ss->status);
|
||||||
sprintf (numbuf3, "0x%04X", status);
|
sprintf (numbuf3, "0x%04X", status);
|
||||||
args[0] = "--reader-port";
|
args[0] = "--reader-port";
|
||||||
args[1] = numbuf1;
|
args[1] = numbuf1;
|
||||||
args[2] = "--old-code";
|
args[2] = "--old-code";
|
||||||
args[3] = numbuf2;
|
args[3] = numbuf2;
|
||||||
args[4] = "--new-code";
|
args[4] = "--new-code";
|
||||||
args[5] = numbuf3;
|
args[5] = numbuf3;
|
||||||
args[6] = "--status";
|
args[6] = "--status";
|
||||||
args[7] = ((status & 1)? "USABLE":
|
args[7] = ((status & 1)? "USABLE":
|
||||||
(status & 4)? "ACTIVE":
|
(status & 4)? "ACTIVE":
|
||||||
(status & 2)? "PRESENT": "NOCARD");
|
(status & 2)? "PRESENT": "NOCARD");
|
||||||
args[8] = NULL;
|
args[8] = NULL;
|
||||||
|
|
||||||
fname = make_filename (opt.homedir, "scd-event", NULL);
|
fname = make_filename (opt.homedir, "scd-event", NULL);
|
||||||
err = gnupg_spawn_process_detached (fname, args, envs);
|
err = gnupg_spawn_process_detached (fname, args, envs);
|
||||||
@ -2307,19 +2307,19 @@ update_reader_status_file (int set_card_removed_flag)
|
|||||||
SERIALNO request must be done in any case. */
|
SERIALNO request must be done in any case. */
|
||||||
if (ss->any && set_card_removed_flag)
|
if (ss->any && set_card_removed_flag)
|
||||||
update_card_removed (idx, 1);
|
update_card_removed (idx, 1);
|
||||||
|
|
||||||
ss->any = 1;
|
ss->any = 1;
|
||||||
|
|
||||||
/* Send a signal to all clients who applied for it. */
|
/* Send a signal to all clients who applied for it. */
|
||||||
send_client_notifications ();
|
send_client_notifications ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether a disconnect is pending. */
|
/* Check whether a disconnect is pending. */
|
||||||
if (opt.card_timeout)
|
if (opt.card_timeout)
|
||||||
{
|
{
|
||||||
for (sl=session_list; sl; sl = sl->next_session)
|
for (sl=session_list; sl; sl = sl->next_session)
|
||||||
if (!sl->disconnect_allowed)
|
if (!sl->disconnect_allowed)
|
||||||
break;
|
break;
|
||||||
if (session_list && !sl)
|
if (session_list && !sl)
|
||||||
{
|
{
|
||||||
/* FIXME: Use a real timeout. */
|
/* FIXME: Use a real timeout. */
|
||||||
@ -2328,7 +2328,7 @@ update_reader_status_file (int set_card_removed_flag)
|
|||||||
apdu_disconnect (ss->slot);
|
apdu_disconnect (ss->slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user