mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-12 22:11:29 +02:00
agent: Extend the PINENTRY_LAUNCHED inquiry and status.
* agent/call-pinentry.c (start_pinentry): Get flavor and version and pass it to agent_inq_pinentry_launched. * agent/command.c (agent_inq_pinentry_launched): Add arg EXTRA. * g10/server.c (gpg_proxy_pinentry_notify): Print a new diagnostic. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
ab89164be0
commit
c1ea0b577a
@ -349,7 +349,8 @@ void agent_sighup_action (void);
|
|||||||
int map_pk_openpgp_to_gcry (int openpgp_algo);
|
int map_pk_openpgp_to_gcry (int openpgp_algo);
|
||||||
|
|
||||||
/*-- command.c --*/
|
/*-- command.c --*/
|
||||||
gpg_error_t agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid);
|
gpg_error_t agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid,
|
||||||
|
const char *extra);
|
||||||
gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...)
|
gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...)
|
||||||
GPGRT_ATTR_SENTINEL(0);
|
GPGRT_ATTR_SENTINEL(0);
|
||||||
gpg_error_t agent_print_status (ctrl_t ctrl, const char *keyword,
|
gpg_error_t agent_print_status (ctrl_t ctrl, const char *keyword,
|
||||||
|
@ -225,6 +225,7 @@ getinfo_pid_cb (void *opaque, const void *buffer, size_t length)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Fork off the pin entry if this has not already been done. Note,
|
/* Fork off the pin entry if this has not already been done. Note,
|
||||||
that this function must always be used to acquire the lock for the
|
that this function must always be used to acquire the lock for the
|
||||||
pinentry - we will serialize _all_ pinentry calls.
|
pinentry - we will serialize _all_ pinentry calls.
|
||||||
@ -243,6 +244,7 @@ start_pinentry (ctrl_t ctrl)
|
|||||||
unsigned long pinentry_pid;
|
unsigned long pinentry_pid;
|
||||||
const char *value;
|
const char *value;
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
|
char *flavor_version;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
npth_clock_gettime (&abstime);
|
npth_clock_gettime (&abstime);
|
||||||
@ -539,6 +541,25 @@ start_pinentry (ctrl_t ctrl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Ask the pinentry for its version and flavor and streo that as a
|
||||||
|
* string in MB. This information is useful for helping users to
|
||||||
|
* figure out Pinentry problems. */
|
||||||
|
{
|
||||||
|
membuf_t mb;
|
||||||
|
|
||||||
|
init_membuf (&mb, 256);
|
||||||
|
if (assuan_transact (entry_ctx, "GETINFO flavor",
|
||||||
|
put_membuf_cb, &mb, NULL, NULL, NULL, NULL))
|
||||||
|
put_membuf_str (&mb, "unknown");
|
||||||
|
put_membuf_str (&mb, " ");
|
||||||
|
if (assuan_transact (entry_ctx, "GETINFO version",
|
||||||
|
put_membuf_cb, &mb, NULL, NULL, NULL, NULL))
|
||||||
|
put_membuf_str (&mb, "unknown");
|
||||||
|
put_membuf (&mb, "", 1);
|
||||||
|
flavor_version = get_membuf (&mb, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Now ask the Pinentry for its PID. If the Pinentry is new enough
|
/* Now ask the Pinentry for its PID. If the Pinentry is new enough
|
||||||
it will send the pid back and we will use an inquire to notify
|
it will send the pid back and we will use an inquire to notify
|
||||||
our client. The client may answer the inquiry either with END or
|
our client. The client may answer the inquiry either with END or
|
||||||
@ -555,7 +576,7 @@ start_pinentry (ctrl_t ctrl)
|
|||||||
log_error ("pinentry did not return a PID\n");
|
log_error ("pinentry did not return a PID\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rc = agent_inq_pinentry_launched (ctrl, pinentry_pid);
|
rc = agent_inq_pinentry_launched (ctrl, pinentry_pid, flavor_version);
|
||||||
if (gpg_err_code (rc) == GPG_ERR_CANCELED
|
if (gpg_err_code (rc) == GPG_ERR_CANCELED
|
||||||
|| gpg_err_code (rc) == GPG_ERR_FULLY_CANCELED)
|
|| gpg_err_code (rc) == GPG_ERR_FULLY_CANCELED)
|
||||||
return unlock_pinentry (gpg_err_make (GPG_ERR_SOURCE_DEFAULT,
|
return unlock_pinentry (gpg_err_make (GPG_ERR_SOURCE_DEFAULT,
|
||||||
@ -563,6 +584,8 @@ start_pinentry (ctrl_t ctrl)
|
|||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xfree (flavor_version);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,14 +362,15 @@ agent_print_status (ctrl_t ctrl, const char *keyword, const char *format, ...)
|
|||||||
that might disturb some older clients, this is only done if enabled
|
that might disturb some older clients, this is only done if enabled
|
||||||
via an option. Returns an gpg error code. */
|
via an option. Returns an gpg error code. */
|
||||||
gpg_error_t
|
gpg_error_t
|
||||||
agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid)
|
agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid, const char *extra)
|
||||||
{
|
{
|
||||||
char line[100];
|
char line[256];
|
||||||
|
|
||||||
if (!ctrl || !ctrl->server_local
|
if (!ctrl || !ctrl->server_local
|
||||||
|| !ctrl->server_local->allow_pinentry_notify)
|
|| !ctrl->server_local->allow_pinentry_notify)
|
||||||
return 0;
|
return 0;
|
||||||
snprintf (line, DIM(line), "PINENTRY_LAUNCHED %lu", pid);
|
snprintf (line, DIM(line), "PINENTRY_LAUNCHED %lu%s%s",
|
||||||
|
pid, extra?" ":"", extra? extra:"");
|
||||||
return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0);
|
return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
g10/server.c
14
g10/server.c
@ -770,6 +770,20 @@ gpg_server (ctrl_t ctrl)
|
|||||||
gpg_error_t
|
gpg_error_t
|
||||||
gpg_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line)
|
gpg_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line)
|
||||||
{
|
{
|
||||||
|
if (opt.verbose)
|
||||||
|
{
|
||||||
|
char *linecopy = xtrystrdup (line);
|
||||||
|
char *fields[4];
|
||||||
|
|
||||||
|
if (linecopy
|
||||||
|
&& split_fields (linecopy, fields, DIM (fields)) >= 4
|
||||||
|
&& !strcmp (fields[0], "PINENTRY_LAUNCHED"))
|
||||||
|
log_info (_("pinentry launched (pid %s, flavor %s, version %s)\n"),
|
||||||
|
fields[1], fields[2], fields[3]);
|
||||||
|
|
||||||
|
xfree (linecopy);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ctrl || !ctrl->server_local
|
if (!ctrl || !ctrl->server_local
|
||||||
|| !ctrl->server_local->allow_pinentry_notify)
|
|| !ctrl->server_local->allow_pinentry_notify)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user