1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

The big Assuan error code removal.

This commit is contained in:
Werner Koch 2006-09-06 16:35:52 +00:00
parent 7b9fa9da99
commit eef036df23
54 changed files with 671 additions and 603 deletions

View File

@ -1,3 +1,8 @@
2006-09-06 Werner Koch <wk@g10code.com>
* configure.ac: Define _ASSUAN_ONLY_GPG_ERRORS. Require Assuan
0.9 and libgpg-error 1.4
2006-08-31 Werner Koch <wk@g10code.com>
* configure.ac: Require libksba 1.0 and added API check for it.

View File

@ -1,3 +1,18 @@
2006-09-06 Werner Koch <wk@g10code.com>
* query.c: Renamed to ..
* call-pinentry.c: .. this.
* agent.h (out_of_core): Removed.
(CTRL): Removed and changed everywhere to ctrl_t.
Replaced all Assuan error codes by libgpg-error codes. Removed
all map_to_assuan_status and map_assuan_err.
* gpg-agent.c (main): Call assuan_set_assuan_err_source to have Assuan
switch to gpg-error codes.
* command.c (set_error): Adjusted.
2006-09-04 Werner Koch <wk@g10code.com>
* command.c (percent_plus_unescape): New.
@ -13,7 +28,7 @@
2006-07-31 Werner Koch <wk@g10code.com>
* preset-passphrase.c (make_hexstring): For conistency use
* preset-passphrase.c (make_hexstring): For consistency use
xtrymalloc and changed caller to use xfree. Fixed function
comment.

View File

@ -32,7 +32,7 @@ AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS)
gpg_agent_SOURCES = \
gpg-agent.c agent.h \
command.c command-ssh.c \
query.c \
call-pinentry.c \
cache.c \
trans.c \
findkey.c \

View File

@ -36,18 +36,12 @@
#include "../common/errors.h"
#include "membuf.h"
/* Convenience function to be used instead of returning the old
GNUPG_Out_Of_Core. */
static inline gpg_error_t
out_of_core (void)
{
return gpg_error (gpg_err_code_from_errno (errno));
}
#define MAX_DIGEST_LEN 24
/* A large struct name "opt" to keep global flags */
struct {
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE) */
int verbose; /* Verbosity level */
int quiet; /* Be as quiet as possible */
@ -136,11 +130,12 @@ struct server_control_s
int use_auth_call; /* Hack to send the PKAUTH command instead of the
PKSIGN command to the scdaemon. */
};
typedef struct server_control_s *CTRL;
typedef struct server_control_s *ctrl_t;
struct pin_entry_info_s {
struct pin_entry_info_s
{
int min_digits; /* min. number of digits required or 0 for freeform entry */
int max_digits; /* max. number of allowed digits allowed*/
int max_tries;

View File

@ -1,4 +1,4 @@
/* query.c - fork of the pinentry to query stuff from the user
/* call-pinnetry.c - fork of the pinentry to query stuff from the user
* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
@ -32,10 +32,10 @@
#include <sys/wait.h>
#endif
#include <pth.h>
#include <assuan.h>
#include "agent.h"
#include "i18n.h"
#include <assuan.h>
#ifdef _POSIX_OPEN_MAX
#define MAX_OPEN_FDS _POSIX_OPEN_MAX
@ -176,7 +176,7 @@ start_pinentry (ctrl_t ctrl)
{
int rc;
const char *pgmname;
ASSUAN_CONTEXT ctx;
assuan_context_t ctx;
const char *argv[5];
int no_close_list[3];
int i;
@ -238,12 +238,12 @@ start_pinentry (ctrl_t ctrl)
no_close_list[i] = -1;
/* Connect to the pinentry and perform initial handshaking */
rc = assuan_pipe_connect2 (&ctx, opt.pinentry_program, (char**)argv,
rc = assuan_pipe_connect2 (&ctx, opt.pinentry_program, argv,
no_close_list, atfork_cb, NULL);
if (rc)
{
log_error ("can't connect to the PIN entry module: %s\n",
assuan_strerror (rc));
gpg_strerror (rc));
return unlock_pinentry (gpg_error (GPG_ERR_NO_PIN_ENTRY));
}
entry_ctx = ctx;
@ -255,7 +255,7 @@ start_pinentry (ctrl_t ctrl)
opt.no_grab? "OPTION no-grab":"OPTION grab",
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
if (ctrl->ttyname)
{
char *optstr;
@ -265,7 +265,7 @@ start_pinentry (ctrl_t ctrl)
NULL);
free (optstr);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
if (ctrl->ttytype)
{
@ -275,7 +275,7 @@ start_pinentry (ctrl_t ctrl)
rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
if (ctrl->lc_ctype)
{
@ -285,7 +285,7 @@ start_pinentry (ctrl_t ctrl)
rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
if (ctrl->lc_messages)
{
@ -295,13 +295,13 @@ start_pinentry (ctrl_t ctrl)
rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
return 0;
}
static AssuanError
static int
getpin_cb (void *opaque, const void *buffer, size_t length)
{
struct entry_parm_s *parm = opaque;
@ -311,7 +311,7 @@ getpin_cb (void *opaque, const void *buffer, size_t length)
/* we expect the pin to fit on one line */
if (parm->lines || length >= parm->size)
return ASSUAN_Too_Much_Data;
return gpg_error (GPG_ERR_ASS_TOO_MUCH_DATA);
/* fixme: we should make sure that the assuan buffer is allocated in
secure memory or read the response byte by byte */
@ -372,14 +372,14 @@ agent_askpin (ctrl_t ctrl,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
snprintf (line, DIM(line)-1, "SETPROMPT %s",
prompt_text? prompt_text : is_pin? "PIN:" : "Passphrase:");
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
if (initial_errtext)
@ -389,7 +389,7 @@ agent_askpin (ctrl_t ctrl,
rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
for (;pininfo->failed_tries < pininfo->max_tries; pininfo->failed_tries++)
@ -407,17 +407,17 @@ agent_askpin (ctrl_t ctrl,
rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
errtext = NULL;
}
rc = assuan_transact (entry_ctx, "GETPIN", getpin_cb, &parm,
NULL, NULL, NULL, NULL);
if (rc == ASSUAN_Too_Much_Data)
if (gpg_err_code (rc) == GPG_ERR_ASS_TOO_MUCH_DATA)
errtext = is_pin? _("PIN too long")
: _("Passphrase too long");
else if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
if (!errtext && pininfo->min_digits)
{
@ -443,7 +443,7 @@ agent_askpin (ctrl_t ctrl,
errtext = (is_pin? _("Bad PIN")
: _("Bad Passphrase"));
else if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
if (!errtext)
@ -491,13 +491,13 @@ agent_get_passphrase (ctrl_t ctrl,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
snprintf (line, DIM(line)-1, "SETPROMPT %s", prompt);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
if (errtext)
{
@ -505,7 +505,7 @@ agent_get_passphrase (ctrl_t ctrl,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
memset (&parm, 0, sizeof parm);
@ -519,7 +519,7 @@ agent_get_passphrase (ctrl_t ctrl,
if (rc)
{
xfree (parm.buffer);
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
hexstring = gcry_malloc_secure (strlen ((char*)parm.buffer)*2+1);
@ -562,7 +562,7 @@ agent_get_confirmation (ctrl_t ctrl,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
if (ok)
{
@ -570,7 +570,7 @@ agent_get_confirmation (ctrl_t ctrl,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
if (cancel)
{
@ -578,11 +578,11 @@ agent_get_confirmation (ctrl_t ctrl,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
rc = assuan_transact (entry_ctx, "CONFIRM", NULL, NULL, NULL, NULL, NULL, NULL);
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
@ -621,7 +621,7 @@ agent_popup_message_start (ctrl_t ctrl, const char *desc,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
if (ok_btn)
{
@ -629,7 +629,7 @@ agent_popup_message_start (ctrl_t ctrl, const char *desc,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL,NULL,NULL,NULL,NULL,NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
if (cancel_btn)
{
@ -637,7 +637,7 @@ agent_popup_message_start (ctrl_t ctrl, const char *desc,
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL,NULL,NULL,NULL,NULL,NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
return unlock_pinentry (rc);
}
tattr = pth_attr_new();

View File

@ -266,7 +266,7 @@ start_scd (ctrl_t ctrl)
if (rc)
{
log_error ("can't connect to socket `%s': %s\n",
socket_name, assuan_strerror (rc));
socket_name, gpg_strerror (rc));
err = gpg_error (GPG_ERR_NO_SCDAEMON);
goto leave;
}
@ -315,12 +315,12 @@ start_scd (ctrl_t ctrl)
no_close_list[i] = -1;
/* Connect to the pinentry and perform initial handshaking */
rc = assuan_pipe_connect2 (&ctx, opt.scdaemon_program, (char**)argv,
rc = assuan_pipe_connect2 (&ctx, opt.scdaemon_program, argv,
no_close_list, atfork_cb, NULL);
if (rc)
{
log_error ("can't connect to the SCdaemon: %s\n",
assuan_strerror (rc));
gpg_strerror (rc));
err = gpg_error (GPG_ERR_NO_SCDAEMON);
goto leave;
}
@ -554,7 +554,7 @@ unescape_status_string (const unsigned char *s)
static AssuanError
static int
learn_status_cb (void *opaque, const char *line)
{
struct learn_parm_s *parm = opaque;
@ -610,14 +610,14 @@ agent_card_learn (ctrl_t ctrl,
NULL, NULL, NULL, NULL,
learn_status_cb, &parm);
if (rc)
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
return unlock_scd (ctrl, 0);
}
static AssuanError
static int
get_serialno_cb (void *opaque, const char *line)
{
char **serialno = opaque;
@ -633,14 +633,14 @@ get_serialno_cb (void *opaque, const char *line)
if (keywordlen == 8 && !memcmp (keyword, "SERIALNO", keywordlen))
{
if (*serialno)
return ASSUAN_Unexpected_Status;
return gpg_error (GPG_ERR_CONFLICT); /* Unexpected status line. */
for (n=0,s=line; hexdigitp (s); s++, n++)
;
if (!n || (n&1)|| !(spacep (s) || !*s) )
return ASSUAN_Invalid_Status;
return gpg_error (GPG_ERR_ASS_PARAMETER);
*serialno = xtrymalloc (n+1);
if (!*serialno)
return ASSUAN_Out_Of_Core;
return out_of_core ();
memcpy (*serialno, line, n);
(*serialno)[n] = 0;
}
@ -666,7 +666,7 @@ agent_card_serialno (ctrl_t ctrl, char **r_serialno)
if (rc)
{
xfree (serialno);
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
}
*r_serialno = serialno;
return unlock_scd (ctrl, 0);
@ -675,7 +675,7 @@ agent_card_serialno (ctrl_t ctrl, char **r_serialno)
static AssuanError
static int
membuf_data_cb (void *opaque, const void *buffer, size_t length)
{
membuf_t *data = opaque;
@ -686,7 +686,7 @@ membuf_data_cb (void *opaque, const void *buffer, size_t length)
}
/* Handle the NEEDPIN inquiry. */
static AssuanError
static int
inq_needpin (void *opaque, const char *line)
{
struct inq_needpin_s *parm = opaque;
@ -703,11 +703,9 @@ inq_needpin (void *opaque, const char *line)
pinlen = 90;
pin = gcry_malloc_secure (pinlen);
if (!pin)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = parm->getpin_cb (parm->getpin_cb_arg, line, pin, pinlen);
if (rc)
rc = ASSUAN_Canceled;
if (!rc)
rc = assuan_send_data (parm->ctx, pin, pinlen);
xfree (pin);
@ -723,13 +721,11 @@ inq_needpin (void *opaque, const char *line)
line++;
rc = parm->getpin_cb (parm->getpin_cb_arg, line, NULL, code);
if (rc)
rc = ASSUAN_Canceled;
}
else
{
log_error ("unsupported inquiry `%s'\n", line);
rc = ASSUAN_Inquire_Unknown;
rc = gpg_error (GPG_ERR_ASS_UNKNOWN_INQUIRE);
}
return rc;
@ -769,7 +765,7 @@ agent_card_pksign (ctrl_t ctrl,
rc = assuan_transact (ctrl->scd_local->ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
init_membuf (&data, 1024);
inqparm.ctx = ctrl->scd_local->ctx;
@ -785,7 +781,7 @@ agent_card_pksign (ctrl_t ctrl,
if (rc)
{
xfree (get_membuf (&data, &len));
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
}
sigbuf = get_membuf (&data, &sigbuflen);
@ -839,7 +835,7 @@ agent_card_pkdecrypt (ctrl_t ctrl,
rc = assuan_transact (ctrl->scd_local->ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
init_membuf (&data, 1024);
inqparm.ctx = ctrl->scd_local->ctx;
@ -854,7 +850,7 @@ agent_card_pkdecrypt (ctrl_t ctrl,
if (rc)
{
xfree (get_membuf (&data, &len));
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
}
*r_buf = get_membuf (&data, r_buflen);
if (!*r_buf)
@ -890,7 +886,7 @@ agent_card_readcert (ctrl_t ctrl,
if (rc)
{
xfree (get_membuf (&data, &len));
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
}
*r_buf = get_membuf (&data, r_buflen);
if (!*r_buf)
@ -926,7 +922,7 @@ agent_card_readkey (ctrl_t ctrl, const char *id, unsigned char **r_buf)
if (rc)
{
xfree (get_membuf (&data, &len));
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
}
*r_buf = get_membuf (&data, &buflen);
if (!*r_buf)
@ -1008,9 +1004,9 @@ agent_card_getattr (ctrl_t ctrl, const char *name, char **result)
if (err)
return err;
err = map_assuan_err (assuan_transact (ctrl->scd_local->ctx, line,
NULL, NULL, NULL, NULL,
card_getattr_cb, &parm));
err = assuan_transact (ctrl->scd_local->ctx, line,
NULL, NULL, NULL, NULL,
card_getattr_cb, &parm);
if (!err && parm.error)
err = gpg_error_from_errno (parm.error);
@ -1028,10 +1024,10 @@ agent_card_getattr (ctrl_t ctrl, const char *name, char **result)
static AssuanError
static int
pass_status_thru (void *opaque, const char *line)
{
ASSUAN_CONTEXT ctx = opaque;
assuan_context_t ctx = opaque;
char keyword[200];
int i;
@ -1048,10 +1044,10 @@ pass_status_thru (void *opaque, const char *line)
return 0;
}
static AssuanError
static int
pass_data_thru (void *opaque, const void *buffer, size_t length)
{
ASSUAN_CONTEXT ctx = opaque;
assuan_context_t ctx = opaque;
assuan_send_data (ctx, buffer, length);
return 0;
@ -1083,7 +1079,7 @@ agent_card_scd (ctrl_t ctrl, const char *cmdline,
pass_status_thru, assuan_context);
if (rc)
{
return unlock_scd (ctrl, map_assuan_err (rc));
return unlock_scd (ctrl, rc);
}
return unlock_scd (ctrl, 0);

View File

@ -41,7 +41,7 @@
/* maximum allowed size of the key parameters */
#define MAXLEN_KEYPARAM 1024
#define set_error(e,t) assuan_set_error (ctx, ASSUAN_ ## e, (t))
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
#if MAX_DIGEST_LEN < 20
@ -103,16 +103,16 @@ write_and_clear_outbuf (assuan_context_t ctx, membuf_t *mb)
p = get_membuf (mb, &n);
if (!p)
return gpg_error (GPG_ERR_ENOMEM);
return out_of_core ();
ae = assuan_send_data (ctx, p, n);
memset (p, 0, n);
xfree (p);
return map_assuan_err (ae);
return ae;
}
static void
reset_notify (ASSUAN_CONTEXT ctx)
reset_notify (assuan_context_t ctx)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@ -187,7 +187,7 @@ percent_plus_unescape (char *string)
/* Parse a hex string. Return an Assuan error code or 0 on success and the
length of the parsed string in LEN. */
static int
parse_hexstring (ASSUAN_CONTEXT ctx, const char *string, size_t *len)
parse_hexstring (assuan_context_t ctx, const char *string, size_t *len)
{
const char *p;
size_t n;
@ -196,9 +196,9 @@ parse_hexstring (ASSUAN_CONTEXT ctx, const char *string, size_t *len)
for (p=string, n=0; hexdigitp (p); p++, n++)
;
if (*p != ' ' && *p != '\t' && *p)
return set_error (Parameter_Error, "invalid hexstring");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid hexstring");
if ((n&1))
return set_error (Parameter_Error, "odd number of digits");
return set_error (GPG_ERR_ASS_PARAMETER, "odd number of digits");
*len = n;
return 0;
}
@ -207,7 +207,7 @@ parse_hexstring (ASSUAN_CONTEXT ctx, const char *string, size_t *len)
provide space for 20 bytes. BUF is not changed if the fucntions
returns an error. */
static int
parse_keygrip (ASSUAN_CONTEXT ctx, const char *string, unsigned char *buf)
parse_keygrip (assuan_context_t ctx, const char *string, unsigned char *buf)
{
int rc;
size_t n;
@ -218,7 +218,7 @@ parse_keygrip (ASSUAN_CONTEXT ctx, const char *string, unsigned char *buf)
return rc;
n /= 2;
if (n != 20)
return set_error (Parameter_Error, "invalid length of keygrip");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid length of keygrip");
for (p=(const unsigned char*)string, n=0; n < 20; p += 2, n++)
buf[n] = xtoi_2 (p);
@ -234,7 +234,7 @@ parse_keygrip (ASSUAN_CONTEXT ctx, const char *string, unsigned char *buf)
Return OK when we have an entry with this fingerprint in our
trustlist */
static int
cmd_istrusted (ASSUAN_CONTEXT ctx, char *line)
cmd_istrusted (assuan_context_t ctx, char *line)
{
int rc, n, i;
char *p;
@ -244,7 +244,7 @@ cmd_istrusted (ASSUAN_CONTEXT ctx, char *line)
for (p=line,n=0; hexdigitp (p); p++, n++)
;
if (*p || !(n == 40 || n == 32))
return set_error (Parameter_Error, "invalid fingerprint");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid fingerprint");
i = 0;
if (n==32)
{
@ -255,14 +255,14 @@ cmd_istrusted (ASSUAN_CONTEXT ctx, char *line)
fpr[i] = *p >= 'a'? (*p & 0xdf): *p;
fpr[i] = 0;
rc = agent_istrusted (fpr);
if (!rc)
return 0;
else if (rc == -1)
return ASSUAN_Not_Trusted;
if (!rc || gpg_err_code (rc) == GPG_ERR_NOT_TRUSTED)
return rc;
else if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF )
return gpg_error (GPG_ERR_NOT_TRUSTED);
else
{
log_error ("command is_trusted failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
}
@ -270,12 +270,12 @@ cmd_istrusted (ASSUAN_CONTEXT ctx, char *line)
List all entries from the trustlist */
static int
cmd_listtrusted (ASSUAN_CONTEXT ctx, char *line)
cmd_listtrusted (assuan_context_t ctx, char *line)
{
int rc = agent_listtrusted (ctx);
if (rc)
log_error ("command listtrusted failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -283,7 +283,7 @@ cmd_listtrusted (ASSUAN_CONTEXT ctx, char *line)
Store a new key in into the trustlist*/
static int
cmd_marktrusted (ASSUAN_CONTEXT ctx, char *line)
cmd_marktrusted (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc, n, i;
@ -295,7 +295,7 @@ cmd_marktrusted (ASSUAN_CONTEXT ctx, char *line)
for (p=line,n=0; hexdigitp (p); p++, n++)
;
if (!spacep (p) || !(n == 40 || n == 32))
return set_error (Parameter_Error, "invalid fingerprint");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid fingerprint");
i = 0;
if (n==32)
{
@ -310,14 +310,14 @@ cmd_marktrusted (ASSUAN_CONTEXT ctx, char *line)
p++;
flag = *p++;
if ( (flag != 'S' && flag != 'P') || !spacep (p) )
return set_error (Parameter_Error, "invalid flag - must be P or S");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid flag - must be P or S");
while (spacep (p))
p++;
rc = agent_marktrusted (ctrl, p, fpr, flag);
if (rc)
log_error ("command marktrusted failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -327,7 +327,7 @@ cmd_marktrusted (ASSUAN_CONTEXT ctx, char *line)
Return success when the secret key is available */
static int
cmd_havekey (ASSUAN_CONTEXT ctx, char *line)
cmd_havekey (assuan_context_t ctx, char *line)
{
int rc;
unsigned char buf[20];
@ -337,7 +337,7 @@ cmd_havekey (ASSUAN_CONTEXT ctx, char *line)
return rc;
if (agent_key_available (buf))
return ASSUAN_No_Secret_Key;
return gpg_error (GPG_ERR_NO_SECKEY);
return 0;
}
@ -348,7 +348,7 @@ cmd_havekey (ASSUAN_CONTEXT ctx, char *line)
Set the key used for a sign or decrypt operation */
static int
cmd_sigkey (ASSUAN_CONTEXT ctx, char *line)
cmd_sigkey (assuan_context_t ctx, char *line)
{
int rc;
ctrl_t ctrl = assuan_get_pointer (ctx);
@ -389,7 +389,7 @@ cmd_setkeydesc (assuan_context_t ctx, char *line)
*p = 0; /* We ignore any garbage; we might late use it for other args. */
if (!desc || !*desc)
return set_error (Parameter_Error, "no description given");
return set_error (GPG_ERR_ASS_PARAMETER, "no description given");
/* Note, that we only need to replace the + characters and should
leave the other escaping in place because the escaped string is
@ -400,7 +400,7 @@ cmd_setkeydesc (assuan_context_t ctx, char *line)
xfree (ctrl->server_local->keydesc);
ctrl->server_local->keydesc = xtrystrdup (desc);
if (!ctrl->server_local->keydesc)
return map_to_assuan_status (gpg_error_from_errno (errno));
return out_of_core ();
return 0;
}
@ -410,7 +410,7 @@ cmd_setkeydesc (assuan_context_t ctx, char *line)
The client can use this command to tell the server about the data
(which usually is a hash) to be signed. */
static int
cmd_sethash (ASSUAN_CONTEXT ctx, char *line)
cmd_sethash (assuan_context_t ctx, char *line)
{
int rc;
size_t n;
@ -425,7 +425,7 @@ cmd_sethash (ASSUAN_CONTEXT ctx, char *line)
for (line = endp; *line == ' ' || *line == '\t'; line++)
;
if (!algo || gcry_md_test_algo (algo))
return set_error (Unsupported_Algorithm, NULL);
return set_error (GPG_ERR_UNSUPPORTED_ALGORITHM, NULL);
ctrl->digest.algo = algo;
/* parse the hash value */
@ -434,9 +434,9 @@ cmd_sethash (ASSUAN_CONTEXT ctx, char *line)
return rc;
n /= 2;
if (n != 16 && n != 20 && n != 24 && n != 32)
return set_error (Parameter_Error, "unsupported length of hash");
return set_error (GPG_ERR_ASS_PARAMETER, "unsupported length of hash");
if (n > MAX_DIGEST_LEN)
return set_error (Parameter_Error, "hash value to long");
return set_error (GPG_ERR_ASS_PARAMETER, "hash value to long");
buf = ctrl->digest.value;
ctrl->digest.valuelen = n;
@ -453,7 +453,7 @@ cmd_sethash (ASSUAN_CONTEXT ctx, char *line)
Perform the actual sign operation. Neither input nor output are
sensitive to eavesdropping. */
static int
cmd_pksign (ASSUAN_CONTEXT ctx, char *line)
cmd_pksign (assuan_context_t ctx, char *line)
{
int rc;
cache_mode_t cache_mode = CACHE_MODE_NORMAL;
@ -477,7 +477,7 @@ cmd_pksign (ASSUAN_CONTEXT ctx, char *line)
log_error ("command pksign failed: %s\n", gpg_strerror (rc));
xfree (ctrl->server_local->keydesc);
ctrl->server_local->keydesc = NULL;
return map_to_assuan_status (rc);
return rc;
}
/* PKDECRYPT <options>
@ -485,7 +485,7 @@ cmd_pksign (ASSUAN_CONTEXT ctx, char *line)
Perform the actual decrypt operation. Input is not
sensitive to eavesdropping */
static int
cmd_pkdecrypt (ASSUAN_CONTEXT ctx, char *line)
cmd_pkdecrypt (assuan_context_t ctx, char *line)
{
int rc;
ctrl_t ctrl = assuan_get_pointer (ctx);
@ -512,7 +512,7 @@ cmd_pkdecrypt (ASSUAN_CONTEXT ctx, char *line)
log_error ("command pkdecrypt failed: %s\n", gpg_strerror (rc));
xfree (ctrl->server_local->keydesc);
ctrl->server_local->keydesc = NULL;
return map_to_assuan_status (rc);
return rc;
}
@ -531,7 +531,7 @@ cmd_pkdecrypt (ASSUAN_CONTEXT ctx, char *line)
*/
static int
cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
cmd_genkey (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
@ -554,7 +554,7 @@ cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
rc = write_and_clear_outbuf (ctx, &outbuf);
if (rc)
log_error ("command genkey failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -591,7 +591,6 @@ cmd_readkey (assuan_context_t ctx, char *line)
len = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, buf, len);
assert (len);
rc = assuan_send_data (ctx, buf, len);
rc = map_assuan_err (rc);
xfree (buf);
}
gcry_sexp_release (s_pkey);
@ -599,7 +598,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
if (rc)
log_error ("command readkey failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -619,7 +618,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
*/
static int
cmd_get_passphrase (ASSUAN_CONTEXT ctx, char *line)
cmd_get_passphrase (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
@ -661,9 +660,9 @@ cmd_get_passphrase (ASSUAN_CONTEXT ctx, char *line)
}
}
if (!cacheid || !*cacheid || strlen (cacheid) > 50)
return set_error (Parameter_Error, "invalid length of cacheID");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid length of cacheID");
if (!desc)
return set_error (Parameter_Error, "no description given");
return set_error (GPG_ERR_ASS_PARAMETER, "no description given");
if (!strcmp (cacheid, "X"))
cacheid = NULL;
@ -709,7 +708,7 @@ cmd_get_passphrase (ASSUAN_CONTEXT ctx, char *line)
if (rc)
log_error ("command get_passphrase failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -720,7 +719,7 @@ cmd_get_passphrase (ASSUAN_CONTEXT ctx, char *line)
*/
static int
cmd_clear_passphrase (ASSUAN_CONTEXT ctx, char *line)
cmd_clear_passphrase (assuan_context_t ctx, char *line)
{
char *cacheid = NULL;
char *p;
@ -733,7 +732,7 @@ cmd_clear_passphrase (ASSUAN_CONTEXT ctx, char *line)
if (p)
*p = 0; /* ignore garbage */
if (!cacheid || !*cacheid || strlen (cacheid) > 50)
return set_error (Parameter_Error, "invalid length of cacheID");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid length of cacheID");
agent_put_cache (cacheid, CACHE_MODE_USER, NULL, 0);
return 0;
@ -753,7 +752,7 @@ cmd_clear_passphrase (ASSUAN_CONTEXT ctx, char *line)
*/
static int
cmd_get_confirmation (ASSUAN_CONTEXT ctx, char *line)
cmd_get_confirmation (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
@ -769,7 +768,7 @@ cmd_get_confirmation (ASSUAN_CONTEXT ctx, char *line)
*p = 0; /* We ignore any garbage -may be later used for other args. */
if (!desc || !*desc)
return set_error (Parameter_Error, "no description given");
return set_error (GPG_ERR_ASS_PARAMETER, "no description given");
if (!strcmp (desc, "X"))
desc = NULL;
@ -784,7 +783,7 @@ cmd_get_confirmation (ASSUAN_CONTEXT ctx, char *line)
rc = agent_get_confirmation (ctrl, desc, NULL, NULL);
if (rc)
log_error ("command get_confirmation failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -794,7 +793,7 @@ cmd_get_confirmation (ASSUAN_CONTEXT ctx, char *line)
Learn something about the currently inserted smartcard. With
--send the new certificates are send back. */
static int
cmd_learn (ASSUAN_CONTEXT ctx, char *line)
cmd_learn (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
@ -802,7 +801,7 @@ cmd_learn (ASSUAN_CONTEXT ctx, char *line)
rc = agent_handle_learn (ctrl, has_option (line, "--send")? ctx : NULL);
if (rc)
log_error ("command learn failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -811,7 +810,7 @@ cmd_learn (ASSUAN_CONTEXT ctx, char *line)
Change the passphrase/PID for the key identified by keygrip in LINE. */
static int
cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
cmd_passwd (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
@ -842,7 +841,7 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
xfree (shadow_info);
if (rc)
log_error ("command passwd failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
/* PRESET_PASSPHRASE <hexstring_with_keygrip> <timeout> <hexstring>
@ -853,7 +852,7 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
to never expire it). If passwd is not provided, ask for it via the
pinentry module. */
static int
cmd_preset_passphrase (ASSUAN_CONTEXT ctx, char *line)
cmd_preset_passphrase (assuan_context_t ctx, char *line)
{
int rc;
unsigned char grip[20];
@ -874,7 +873,7 @@ cmd_preset_passphrase (ASSUAN_CONTEXT ctx, char *line)
while (*line && (*line != ' ' && *line != '\t'))
line++;
if (!*line)
return map_to_assuan_status (gpg_error (GPG_ERR_MISSING_VALUE));
return gpg_error (GPG_ERR_MISSING_VALUE);
*line = '\0';
line++;
while (*line && (*line == ' ' || *line == '\t'))
@ -883,7 +882,7 @@ cmd_preset_passphrase (ASSUAN_CONTEXT ctx, char *line)
/* Currently, only infinite timeouts are allowed. */
ttl = -1;
if (line[0] != '-' || line[1] != '1')
return map_to_assuan_status (gpg_error (GPG_ERR_NOT_IMPLEMENTED));
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
line++;
line++;
while (!(*line != ' ' && *line != '\t'))
@ -900,14 +899,14 @@ cmd_preset_passphrase (ASSUAN_CONTEXT ctx, char *line)
if (*line)
passphrase = line;
else
return map_to_assuan_status (gpg_error (GPG_ERR_NOT_IMPLEMENTED));
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
rc = agent_put_cache (grip_clear, CACHE_MODE_ANY, passphrase, ttl);
if (rc)
log_error ("command preset_passwd failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -916,14 +915,14 @@ cmd_preset_passphrase (ASSUAN_CONTEXT ctx, char *line)
This is a general quote command to redirect everything to the
SCDAEMON. */
static int
cmd_scd (ASSUAN_CONTEXT ctx, char *line)
cmd_scd (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
rc = divert_generic_cmd (ctrl, line, ctx);
return map_to_assuan_status (rc);
return rc;
}
@ -951,10 +950,10 @@ cmd_getval (assuan_context_t ctx, char *line)
for (; *p == ' '; p++)
;
if (*p)
return set_error (Parameter_Error, "too many arguments");
return set_error (GPG_ERR_ASS_PARAMETER, "too many arguments");
}
if (!key || !*key)
return set_error (Parameter_Error, "no key given");
return set_error (GPG_ERR_ASS_PARAMETER, "no key given");
for (vl=putval_list; vl; vl = vl->next)
@ -962,17 +961,13 @@ cmd_getval (assuan_context_t ctx, char *line)
break;
if (vl) /* Got an entry. */
{
rc = assuan_send_data (ctx, vl->d+vl->off, vl->len);
if (rc)
rc = map_assuan_err (rc);
}
rc = assuan_send_data (ctx, vl->d+vl->off, vl->len);
else
return gpg_error (GPG_ERR_NO_DATA);
if (rc)
log_error ("command getval failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -1023,7 +1018,7 @@ cmd_putval (assuan_context_t ctx, char *line)
}
}
if (!key || !*key)
return set_error (Parameter_Error, "no key given");
return set_error (GPG_ERR_ASS_PARAMETER, "no key given");
for (vl=putval_list,vlprev=NULL; vl; vlprev=vl, vl = vl->next)
@ -1057,7 +1052,7 @@ cmd_putval (assuan_context_t ctx, char *line)
if (rc)
log_error ("command putval failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -1097,7 +1092,7 @@ cmd_updatestartuptty (assuan_context_t ctx, char *line)
static int
option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
option_handler (assuan_context_t ctx, const char *key, const char *value)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@ -1107,7 +1102,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (ctrl->display);
ctrl->display = strdup (value);
if (!ctrl->display)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "ttyname"))
{
@ -1117,7 +1112,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (ctrl->ttyname);
ctrl->ttyname = strdup (value);
if (!ctrl->ttyname)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
}
else if (!strcmp (key, "ttytype"))
@ -1128,7 +1123,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (ctrl->ttytype);
ctrl->ttytype = strdup (value);
if (!ctrl->ttytype)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
}
else if (!strcmp (key, "lc-ctype"))
@ -1137,7 +1132,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (ctrl->lc_ctype);
ctrl->lc_ctype = strdup (value);
if (!ctrl->lc_ctype)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "lc-messages"))
{
@ -1145,12 +1140,12 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (ctrl->lc_messages);
ctrl->lc_messages = strdup (value);
if (!ctrl->lc_messages)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "use-cache-for-signing"))
ctrl->server_local->use_cache_for_signing = *value? atoi (value) : 0;
else
return ASSUAN_Invalid_Option;
return gpg_error (GPG_ERR_UNKNOWN_OPTION);
return 0;
}
@ -1158,11 +1153,11 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
/* Tell the assuan library about our commands */
static int
register_commands (ASSUAN_CONTEXT ctx)
register_commands (assuan_context_t ctx)
{
static struct {
const char *name;
int (*handler)(ASSUAN_CONTEXT, char *line);
int (*handler)(assuan_context_t, char *line);
} table[] = {
{ "ISTRUSTED", cmd_istrusted },
{ "HAVEKEY", cmd_havekey },
@ -1210,7 +1205,7 @@ void
start_command_handler (int listen_fd, int fd)
{
int rc;
ASSUAN_CONTEXT ctx;
assuan_context_t ctx;
struct server_control_s ctrl;
memset (&ctrl, 0, sizeof ctrl);
@ -1236,14 +1231,14 @@ start_command_handler (int listen_fd, int fd)
if (rc)
{
log_error ("failed to initialize the server: %s\n",
assuan_strerror(rc));
gpg_strerror(rc));
agent_exit (2);
}
rc = register_commands (ctx);
if (rc)
{
log_error ("failed to register commands with Assuan: %s\n",
assuan_strerror(rc));
gpg_strerror(rc));
agent_exit (2);
}
@ -1266,14 +1261,14 @@ start_command_handler (int listen_fd, int fd)
}
else if (rc)
{
log_info ("Assuan accept problem: %s\n", assuan_strerror (rc));
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
break;
}
rc = assuan_process (ctx);
if (rc)
{
log_info ("Assuan processing failed: %s\n", assuan_strerror (rc));
log_info ("Assuan processing failed: %s\n", gpg_strerror (rc));
continue;
}
}

View File

@ -35,7 +35,7 @@
static int
ask_for_card (CTRL ctrl, const unsigned char *shadow_info, char **r_kid)
ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info, char **r_kid)
{
int rc, i;
const unsigned char *s;
@ -309,7 +309,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
int
divert_pksign (CTRL ctrl,
divert_pksign (ctrl_t ctrl,
const unsigned char *digest, size_t digestlen, int algo,
const unsigned char *shadow_info, unsigned char **r_sig)
{
@ -344,7 +344,7 @@ divert_pksign (CTRL ctrl,
key identified by SHADOW_INFO and return the plaintext in an
allocated buffer in R_BUF. */
int
divert_pkdecrypt (CTRL ctrl,
divert_pkdecrypt (ctrl_t ctrl,
const unsigned char *cipher,
const unsigned char *shadow_info,
char **r_buf, size_t *r_len)
@ -407,7 +407,7 @@ divert_pkdecrypt (CTRL ctrl,
int
divert_generic_cmd (CTRL ctrl, const char *cmdline, void *assuan_context)
divert_generic_cmd (ctrl_t ctrl, const char *cmdline, void *assuan_context)
{
return agent_card_scd (ctrl, cmdline, getpin_cb, ctrl, assuan_context);
}

View File

@ -88,7 +88,7 @@ reenter_compare_cb (struct pin_entry_info_s *pi)
/* Generate a new keypair according to the parameters given in
KEYPARAM */
int
agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
agent_genkey (ctrl_t ctrl, const char *keyparam, size_t keyparamlen,
membuf_t *outbuf)
{
gcry_sexp_t s_keyparam, s_key, s_private, s_public;
@ -209,7 +209,7 @@ agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
/* Apply a new passpahrse to the key S_SKEY and store it. */
int
agent_protect_and_store (CTRL ctrl, gcry_sexp_t s_skey)
agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey)
{
struct pin_entry_info_s *pi, *pi2;
int rc;

View File

@ -509,6 +509,7 @@ main (int argc, char **argv )
assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
assuan_set_assuan_log_stream (log_get_stream ());
assuan_set_assuan_log_prefix (log_get_prefix (NULL));
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
gcry_set_log_handler (my_gcry_logger, NULL);
gcry_set_outofcore_handler (my_gcry_outofcore_handler, NULL);
@ -1697,7 +1698,7 @@ check_for_running_agent (int mode)
return 0; /* Okay, its running on the standard socket. */
if (!mode)
log_error ("can't connect to the agent: %s\n", assuan_strerror (rc));
log_error ("can't connect to the agent: %s\n", gpg_strerror (rc));
return -1;
}

View File

@ -265,8 +265,8 @@ send_cert_back (ctrl_t ctrl, const char *id, void *assuan_context)
if (rc)
{
log_error ("sending certificate failed: %s\n",
assuan_strerror (rc));
return map_assuan_err (rc);
gpg_strerror (rc));
return rc;
}
return 0;
}

View File

@ -36,7 +36,7 @@
Try to get the key from CTRL and write the decoded stuff back to
OUTFP. */
int
agent_pkdecrypt (CTRL ctrl, const char *desc_text,
agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
const unsigned char *ciphertext, size_t ciphertextlen,
membuf_t *outbuf)
{

View File

@ -94,7 +94,7 @@ open_list (int append)
buffer of at least 41 characters. KEYFLAG does return either 'P',
'S' or '*'.
Reading a valid entry return 0, EOF returns -1 any other error
Reading a valid entry returns 0, EOF returns -1 any other error
returns the appropriate error code. */
static int
read_list (char *key, int *keyflag)
@ -246,7 +246,7 @@ agent_listtrusted (void *assuan_context)
whether this is actual wants he want to do.
*/
int
agent_marktrusted (CTRL ctrl, const char *name, const char *fpr, int flag)
agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
{
int rc;
static char key[41];

View File

@ -1,3 +1,9 @@
2006-09-06 Werner Koch <wk@g10code.com>
* maperror.c: Removed.
* util.h (out_of_core): New.
2006-09-04 Werner Koch <wk@g10code.com>
* http.c (http_get_header): New.

View File

@ -34,7 +34,6 @@ libcommon_a_SOURCES = \
keyserver.h \
sexp-parse.h \
sexputil.c \
maperror.c \
sysutils.c sysutils.h \
homedir.c \
gettime.c \

View File

@ -47,10 +47,7 @@ send_one_option (assuan_context_t ctx, gpg_err_source_t errsource,
err = gpg_error_from_errno (errno);
else
{
assuan_error_t ae;
ae = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL);
err = ae? map_assuan_err_with_source (errsource, ae) : 0;
err = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL);
free (optstr);
}

View File

@ -19,6 +19,8 @@
* USA.
*/
#error This file is not anymore used.
#include <config.h>
#include <errno.h>
#include <stdio.h>
@ -33,6 +35,7 @@
#include "errors.h"
/* Map Assuan error code ERR to an GPG_ERR_ code. We need to
distinguish between genuine (and legacy) Assuan error codes and
application error codes shared with all GnuPG modules. The rule is

View File

@ -24,7 +24,8 @@
#include <gcrypt.h> /* We need this for the memory function protos. */
#include <time.h> /* We need time_t. */
#include <gpg-error.h> /* we need gpg-error_t. */
#include <errno.h> /* We need errno. */
#include <gpg-error.h> /* We need gpg_error_t. */
/* Common GNUlib includes (-I ../gl/). */
#include "strpbrk.h"
@ -64,17 +65,22 @@
#define xmalloc_clear(a) gcry_xcalloc (1, (a))
#define xmalloc_secure_clear(a) gcry_xcalloc_secure (1, (a))
/* Convenience function to return a gpg-error code for memory
allocation failures. This function makes sure that an error will
be returned even if accidently ERRNO is not set. */
static inline gpg_error_t
out_of_core (void)
{
return gpg_error (errno
? gpg_err_code_from_errno(errno)
: GPG_ERR_MISSING_ERRNO);
}
/* A type to hold the ISO time. Note that this this is the same as
the the KSBA type ksba_isotime_t. */
typedef char gnupg_isotime_t[16];
/*-- maperror.c --*/
int map_kbx_err (int err);
gpg_error_t map_assuan_err_with_source (int source, int err);
int map_to_assuan_status (int rc);
/*-- gettime.c --*/
time_t gnupg_get_time (void);
void gnupg_get_isotime (gnupg_isotime_t timebuf);

View File

@ -39,12 +39,12 @@ AC_INIT([gnupg], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]),
# sufficient.
development_version=yes
NEED_GPG_ERROR_VERSION=1.2
NEED_GPG_ERROR_VERSION=1.4
NEED_LIBGCRYPT_API=1
NEED_LIBGCRYPT_VERSION=1.1.94
NEED_LIBASSUAN_VERSION=0.6.10
NEED_LIBASSUAN_VERSION=0.9.0
NEED_KSBA_API=1
NEED_KSBA_VERSION=1.0.0
@ -417,6 +417,8 @@ AH_BOTTOM([
/* We always include support for the OpenPGP card. */
#define ENABLE_CARD_SUPPORT 1
/* We don't want the old assuan codes anymore. */
#define _ASSUAN_ONLY_GPG_ERRORS 1
#endif /*GNUPG_CONFIG_H_INCLUDED*/
])

View File

@ -1,3 +1,8 @@
2006-09-06 Werner Koch <wk@g10code.com>
* gpg.c (main): Enable new assuan API.
* call-agent.c: Changed to new Assuan API.
2006-09-01 Werner Koch <wk@g10code.com>
* call-agent.c: Do not force using the pipe server.

View File

@ -80,7 +80,7 @@ start_agent (void)
{
int rc = 0;
char *infostr, *p;
ASSUAN_CONTEXT ctx;
assuan_context_t ctx;
char *dft_display = NULL;
char *dft_ttyname = NULL;
char *dft_ttytype = NULL;
@ -127,7 +127,7 @@ start_agent (void)
no_close_list[i] = -1;
/* connect to the agent and perform initial handshaking */
rc = assuan_pipe_connect (&ctx, opt.agent_program, (char**)argv,
rc = assuan_pipe_connect (&ctx, opt.agent_program, argv,
no_close_list);
}
else
@ -159,7 +159,7 @@ start_agent (void)
rc = assuan_socket_connect (&ctx, infostr, pid);
xfree (infostr);
if (rc == ASSUAN_Connect_Failed)
if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED)
{
log_error (_("can't connect to the agent - trying fall back\n"));
force_pipe_server = 1;
@ -169,7 +169,7 @@ start_agent (void)
if (rc)
{
log_error ("can't connect to the agent: %s\n", assuan_strerror (rc));
log_error ("can't connect to the agent: %s\n", gpg_strerror (rc));
return gpg_error (GPG_ERR_NO_AGENT);
}
agent_ctx = ctx;
@ -179,7 +179,7 @@ start_agent (void)
rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
#ifdef __GNUC__
#warning put this code into common/asshelp.c
@ -196,7 +196,7 @@ start_agent (void)
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
return rc;
}
if (!opt.ttyname)
{
@ -214,7 +214,7 @@ start_agent (void)
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
return rc;
}
dft_ttytype = getenv ("TERM");
if (opt.ttytype || (dft_ttyname && dft_ttytype))
@ -227,7 +227,7 @@ start_agent (void)
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
return rc;
}
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
old_lc = setlocale (LC_CTYPE, NULL);
@ -251,8 +251,6 @@ start_agent (void)
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
if (rc)
rc = map_assuan_err (rc);
}
}
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
@ -285,8 +283,6 @@ start_agent (void)
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
if (rc)
rc = map_assuan_err (rc);
}
}
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
@ -379,11 +375,11 @@ store_serialno (const char *line)
#if 0
/* Handle a KEYPARMS inquiry. Note, we only send the data,
assuan_transact takes care of flushing and writing the end */
static AssuanError
static int
inq_genkey_parms (void *opaque, const char *keyword)
{
struct genkey_parm_s *parm = opaque;
AssuanError rc;
int rc;
rc = assuan_send_data (parm->ctx, parm->sexp, parm->sexplen);
return rc;
@ -409,7 +405,7 @@ agent_genkey (KsbaConstSexp keyparms, KsbaSexp *r_pubkey)
rc = assuan_transact (agent_ctx, "RESET", NULL, NULL,
NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
init_membuf (&data, 1024);
gk_parm.ctx = agent_ctx;
@ -423,7 +419,7 @@ agent_genkey (KsbaConstSexp keyparms, KsbaSexp *r_pubkey)
if (rc)
{
xfree (get_membuf (&data, &len));
return map_assuan_err (rc);
return rc;
}
buf = get_membuf (&data, &len);
if (!buf)
@ -459,7 +455,7 @@ agent_havekey (const char *hexkeygrip)
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}
@ -479,7 +475,7 @@ agent_release_card_info (struct agent_card_info_s *info)
info->fpr1valid = info->fpr2valid = info->fpr3valid = 0;
}
static AssuanError
static int
learn_status_cb (void *opaque, const char *line)
{
struct agent_card_info_s *parm = opaque;
@ -605,7 +601,7 @@ agent_learn (struct agent_card_info_s *info)
NULL, NULL, NULL, NULL,
learn_status_cb, info);
return map_assuan_err (rc);
return rc;
}
/* Call the agent to retrieve a data object. This function returns
@ -632,7 +628,7 @@ agent_scd_getattr (const char *name, struct agent_card_info_s *info)
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL,
learn_status_cb, info);
return map_assuan_err (rc);
return rc;
}
@ -678,7 +674,7 @@ agent_scd_setattr (const char *name,
return rc;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}
@ -718,14 +714,14 @@ agent_scd_writekey (int keyno, const char *serialno,
rc = assuan_transact (agent_ctx, line, NULL, NULL,
inq_writekey_parms, &parms, NULL, NULL);
return map_assuan_err (rc);
return rc;
}
/* Status callback for the SCD GENKEY command. */
static AssuanError
static int
scd_genkey_cb (void *opaque, const char *line)
{
struct agent_card_genkey_s *parm = opaque;
@ -797,11 +793,11 @@ agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force,
NULL, NULL, NULL, NULL,
scd_genkey_cb, info);
return map_assuan_err (rc);
return rc;
}
static AssuanError
static int
membuf_data_cb (void *opaque, const void *buffer, size_t length)
{
membuf_t *data = opaque;
@ -841,7 +837,7 @@ agent_scd_pksign (const char *serialno, int hashalgo,
sprintf (p, "%02X", indata[i]);
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
init_membuf (&data, 1024);
#if 0
@ -856,7 +852,7 @@ agent_scd_pksign (const char *serialno, int hashalgo,
if (rc)
{
xfree (get_membuf (&data, &len));
return map_assuan_err (rc);
return rc;
}
*r_buf = get_membuf (&data, r_buflen);
@ -895,7 +891,7 @@ agent_scd_pkdecrypt (const char *serialno,
sprintf (p, "%02X", indata[i]);
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
init_membuf (&data, 1024);
snprintf (line, DIM(line)-1, "SCD PKDECRYPT %s", serialno);
@ -906,7 +902,7 @@ agent_scd_pkdecrypt (const char *serialno,
if (rc)
{
xfree (get_membuf (&data, &len));
return map_assuan_err (rc);
return rc;
}
*r_buf = get_membuf (&data, r_buflen);
if (!*r_buf)
@ -943,7 +939,7 @@ agent_scd_change_pin (int chvno, const char *serialno)
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL,
NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}

View File

@ -1899,6 +1899,7 @@ main (int argc, char **argv )
/* malloc hooks go here ... */
assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
set_native_charset (NULL); /* Try to auto set the character set */

View File

@ -4,7 +4,7 @@ agent/gpg-agent.c
agent/protect-tool.c
agent/divert-scd.c
agent/genkey.c
agent/query.c
agent/call-pinentry.c
agent/trustlist.c
common/sysutils.c

180
po/de.po
View File

@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnupg2 1.9.18\n"
"Report-Msgid-Bugs-To: translations@gnupg.org\n"
"POT-Creation-Date: 2006-07-24 16:19+0200\n"
"POT-Creation-Date: 2006-09-06 17:28+0200\n"
"PO-Revision-Date: 2006-06-20 20:04+0200\n"
"Last-Translator: Werner Koch <wk@gnupg.org>\n"
"Language-Team: de\n"
@ -137,123 +137,133 @@ msgstr ""
"Syntax: gpg-agent [Optionen] [Kommando [Argumente]]\n"
"Verwaltung von geheimen Schlüssel für GnuPG\n"
#: agent/gpg-agent.c:312 scd/scdaemon.c:262 sm/gpgsm.c:642
#: agent/gpg-agent.c:300
#, c-format
msgid "out of core in secure memory while allocating %lu bytes"
msgstr ""
#: agent/gpg-agent.c:303
#, c-format
msgid "out of core while allocating %lu bytes"
msgstr ""
#: agent/gpg-agent.c:334 scd/scdaemon.c:262 sm/gpgsm.c:642
#, c-format
msgid "invalid debug-level `%s' given\n"
msgstr "ungültige Debugebene `%s' angegeben\n"
#: agent/gpg-agent.c:483 agent/protect-tool.c:1073 kbx/kbxutil.c:432
#: agent/gpg-agent.c:505 agent/protect-tool.c:1073 kbx/kbxutil.c:432
#: scd/scdaemon.c:354 sm/gpgsm.c:763
#, c-format
msgid "libgcrypt is too old (need %s, have %s)\n"
msgstr ""
"Die Bibliothek \"libgcrypt\" is zu alt (benötigt wird %s, vorhanden ist %s)\n"
#: agent/gpg-agent.c:575 scd/scdaemon.c:429 sm/gpgsm.c:864
#: agent/gpg-agent.c:599 scd/scdaemon.c:431 sm/gpgsm.c:865
#, c-format
msgid "NOTE: no default option file `%s'\n"
msgstr "Notiz: Voreingestellte Konfigurationsdatei `%s' fehlt\n"
#: agent/gpg-agent.c:580 agent/gpg-agent.c:1091 scd/scdaemon.c:434
#: sm/gpgsm.c:868
#: agent/gpg-agent.c:604 agent/gpg-agent.c:1115 scd/scdaemon.c:436
#: sm/gpgsm.c:869
#, c-format
msgid "option file `%s': %s\n"
msgstr "Konfigurationsdatei `%s': %s\n"
#: agent/gpg-agent.c:588 scd/scdaemon.c:442 sm/gpgsm.c:875
#: agent/gpg-agent.c:612 scd/scdaemon.c:444 sm/gpgsm.c:876
#, c-format
msgid "reading options from `%s'\n"
msgstr "Optionen werden aus `%s' gelesen\n"
#: agent/gpg-agent.c:885
#: agent/gpg-agent.c:909
#, c-format
msgid "error creating `%s': %s\n"
msgstr "Fehler beim Erstellen von `%s': %s\n"
#: agent/gpg-agent.c:1141 agent/gpg-agent.c:1244 agent/gpg-agent.c:1248
#: agent/gpg-agent.c:1284 agent/gpg-agent.c:1288 scd/scdaemon.c:909
#: agent/gpg-agent.c:1165 agent/gpg-agent.c:1268 agent/gpg-agent.c:1272
#: agent/gpg-agent.c:1308 agent/gpg-agent.c:1312 scd/scdaemon.c:911
#, c-format
msgid "can't create directory `%s': %s\n"
msgstr "Das Verzeichniss `%s' kann nicht erstellt werden: %s\n"
#: agent/gpg-agent.c:1155 scd/scdaemon.c:923
#: agent/gpg-agent.c:1179 scd/scdaemon.c:925
msgid "name of socket too long\n"
msgstr "Der Name des Sockets ist zu lang\n"
#: agent/gpg-agent.c:1181 scd/scdaemon.c:949
#: agent/gpg-agent.c:1205 scd/scdaemon.c:951
#, c-format
msgid "can't create socket: %s\n"
msgstr "Socket kann nicht erzeugt werden: %s\n"
#: agent/gpg-agent.c:1210 scd/scdaemon.c:978
#: agent/gpg-agent.c:1234 scd/scdaemon.c:980
#, c-format
msgid "error binding socket to `%s': %s\n"
msgstr "Der Socket kann nicht an `%s' gebunden werden: %s\n"
#: agent/gpg-agent.c:1218 scd/scdaemon.c:986
#: agent/gpg-agent.c:1242 scd/scdaemon.c:988
#, c-format
msgid "listen() failed: %s\n"
msgstr "Der listen() Aufruf ist fehlgeschlagen: %s\n"
#: agent/gpg-agent.c:1224 scd/scdaemon.c:992
#: agent/gpg-agent.c:1248 scd/scdaemon.c:994
#, c-format
msgid "listening on socket `%s'\n"
msgstr "Es wird auf Socket `%s' gehört\n"
#: agent/gpg-agent.c:1252 agent/gpg-agent.c:1294
#: agent/gpg-agent.c:1276 agent/gpg-agent.c:1318
#, c-format
msgid "directory `%s' created\n"
msgstr "Verzeichniss `%s' wurde erstellt\n"
#: agent/gpg-agent.c:1300
#: agent/gpg-agent.c:1324
#, c-format
msgid "stat() failed for `%s': %s\n"
msgstr "stat() Aufruf für `%s' fehlgeschlagen: %s\n"
#: agent/gpg-agent.c:1304
#: agent/gpg-agent.c:1328
#, c-format
msgid "can't use `%s' as home directory\n"
msgstr "Die Datei `%s' kann nicht als Home-Verzeichniss benutzt werden\n"
#: agent/gpg-agent.c:1403
#: agent/gpg-agent.c:1427
#, c-format
msgid "handler 0x%lx for fd %d started\n"
msgstr "Handhabungsroutine 0x%lx für fd %d gestartet\n"
#: agent/gpg-agent.c:1413
#: agent/gpg-agent.c:1437
#, c-format
msgid "handler 0x%lx for fd %d terminated\n"
msgstr "Handhabungsroutine 0x%lx für den fd %d beendet\n"
#: agent/gpg-agent.c:1427
#: agent/gpg-agent.c:1451
#, c-format
msgid "ssh handler 0x%lx for fd %d started\n"
msgstr "SSH Handhabungsroutine 0x%lx für fd %d gestartet\n"
#: agent/gpg-agent.c:1434
#: agent/gpg-agent.c:1458
#, c-format
msgid "ssh handler 0x%lx for fd %d terminated\n"
msgstr "SSH Handhabungsroutine 0x%lx für fd %d beendet\n"
#: agent/gpg-agent.c:1528 scd/scdaemon.c:1108
#: agent/gpg-agent.c:1552 scd/scdaemon.c:1110
#, c-format
msgid "pth_select failed: %s - waiting 1s\n"
msgstr "pth_select() Aufruf fehlgeschlagen: %s - warte 1s\n"
#: agent/gpg-agent.c:1612 scd/scdaemon.c:1165
#: agent/gpg-agent.c:1636 scd/scdaemon.c:1167
#, c-format
msgid "%s %s stopped\n"
msgstr "%s %s angehalten\n"
#: agent/gpg-agent.c:1633
#: agent/gpg-agent.c:1657
msgid "no gpg-agent running in this session\n"
msgstr "Der gpg-agent läuft nicht für diese Session\n"
#: agent/gpg-agent.c:1643 common/simple-pwquery.c:324 sm/call-agent.c:144
#: agent/gpg-agent.c:1667 common/simple-pwquery.c:324 sm/call-agent.c:144
msgid "malformed GPG_AGENT_INFO environment variable\n"
msgstr "Die Variable GPG_AGENT_INFO ist fehlerhaft\n"
#: agent/gpg-agent.c:1655 common/simple-pwquery.c:336 sm/call-agent.c:156
#: agent/gpg-agent.c:1679 common/simple-pwquery.c:336 sm/call-agent.c:156
#, c-format
msgid "gpg-agent protocol version %d is not supported\n"
msgstr "Das gpg-agent Protocol %d wird nicht unterstützt\n"
@ -343,12 +353,12 @@ msgstr ""
msgid "Please enter the new passphrase"
msgstr "Bitte geben Sie das Mantra (Passphrase) ein:"
#: agent/query.c:193
#: agent/call-pinentry.c:193
#, c-format
msgid "failed to acquire the pinentry lock: %s\n"
msgstr "Die Sperre für das Pinentry kann nicht gesetzt werden: %s\n"
#: agent/query.c:356
#: agent/call-pinentry.c:356
msgid ""
"Please enter your PIN, so that the secret key can be unlocked for this "
"session"
@ -356,7 +366,7 @@ msgstr ""
"Bitte geben Sie Ihre PIN ein, so daß der geheime Schlüssel benutzt werden "
"kann"
#: agent/query.c:359
#: agent/call-pinentry.c:359
msgid ""
"Please enter your passphrase, so that the secret key can be unlocked for "
"this session"
@ -364,31 +374,31 @@ msgstr ""
"Bitte geben Sie Ihr Mantra (Passphrase) ein, so daß der geheime Schlüssel "
"benutzt werden kann"
#: agent/query.c:417 agent/query.c:429
#: agent/call-pinentry.c:417 agent/call-pinentry.c:429
msgid "PIN too long"
msgstr "Die PIN ist zu lang"
#: agent/query.c:418
#: agent/call-pinentry.c:418
msgid "Passphrase too long"
msgstr "Das Matra (Passphrase) ist zu lang"
#: agent/query.c:426
#: agent/call-pinentry.c:426
msgid "Invalid characters in PIN"
msgstr "Ungültige Zeichen in der PIN"
#: agent/query.c:431
#: agent/call-pinentry.c:431
msgid "PIN too short"
msgstr "Die PIN ist zu kurz"
#: agent/query.c:443
#: agent/call-pinentry.c:443
msgid "Bad PIN"
msgstr "Falsche PIN"
#: agent/query.c:444
#: agent/call-pinentry.c:444
msgid "Bad Passphrase"
msgstr "Falsches Mantra (Passphrase)"
#: agent/query.c:484
#: agent/call-pinentry.c:484
msgid "Passphrase"
msgstr "Mantra"
@ -484,7 +494,7 @@ msgstr "Vom Benutzer abgebrochen\n"
msgid "problem with the agent\n"
msgstr "Problem mit dem Agenten\n"
#: jnlib/logging.c:611
#: jnlib/logging.c:619
#, c-format
msgid "you found a bug ... (%s:%d)\n"
msgstr "Sie haben einen Bug (Softwarefehler) gefunden ... (%s:%d)\n"
@ -583,18 +593,18 @@ msgstr ""
"Synatx: scdaemon [Optionen] [Kommando [Argumente]]\n"
"Smartcard Daemon für GnuPG\n"
#: scd/scdaemon.c:665
#: scd/scdaemon.c:667
msgid "please use the option `--daemon' to run the program in the background\n"
msgstr ""
"Bitte die Option `--daemon' nutzen um das Programm im Hintergund "
"auszuführen\n"
#: scd/scdaemon.c:1006
#: scd/scdaemon.c:1008
#, c-format
msgid "handler for fd %d started\n"
msgstr "Handhabungsroutine für fd %d gestartet\n"
#: scd/scdaemon.c:1011
#: scd/scdaemon.c:1013
#, c-format
msgid "handler for fd %d terminated\n"
msgstr "Handhabungsroutine für den fd %d beendet\n"
@ -626,18 +636,18 @@ msgstr "Die Antwort enthält keinen RSA Modulus\n"
msgid "response does not contain the RSA public exponent\n"
msgstr "Die Antwort enthält keinen öffenlichen RSA Exponent\n"
#: scd/app-openpgp.c:1297 scd/app-openpgp.c:1385 scd/app-openpgp.c:2192
#: scd/app-openpgp.c:1297 scd/app-openpgp.c:1385 scd/app-openpgp.c:2196
#, c-format
msgid "PIN callback returned error: %s\n"
msgstr "Fehler vom PIN \"callback\": %s\n"
#: scd/app-openpgp.c:1303 scd/app-openpgp.c:1391 scd/app-openpgp.c:2198
#: scd/app-openpgp.c:1303 scd/app-openpgp.c:1391 scd/app-openpgp.c:2202
#, c-format
msgid "PIN for CHV%d is too short; minimum length is %d\n"
msgstr "Die PIN für den CHV%d ist zu kurz; Mindestlänge ist %d\n"
#: scd/app-openpgp.c:1312 scd/app-openpgp.c:1326 scd/app-openpgp.c:1401
#: scd/app-openpgp.c:2207 scd/app-openpgp.c:2221
#: scd/app-openpgp.c:2211 scd/app-openpgp.c:2225
#, c-format
msgid "verify CHV%d failed: %s\n"
msgstr "Prüfen von CHV%d fehlgeschlagen: %s\n"
@ -646,11 +656,11 @@ msgstr "Prüfen von CHV%d fehlgeschlagen: %s\n"
msgid "access to admin commands is not configured\n"
msgstr "Zugriff auf Admin Kommandos ist nicht konfiguriert\n"
#: scd/app-openpgp.c:1364 scd/app-openpgp.c:2427
#: scd/app-openpgp.c:1364 scd/app-openpgp.c:2435
msgid "error retrieving CHV status from card\n"
msgstr "Fehler beim Holen des CHV Status von der Karte\n"
#: scd/app-openpgp.c:1370 scd/app-openpgp.c:2436
#: scd/app-openpgp.c:1370 scd/app-openpgp.c:2444
msgid "card is permanently locked!\n"
msgstr "Die Karte ist dauerhaft gesperrt!\n"
@ -749,24 +759,24 @@ msgstr "Ungültige Struktur der OpenPGP Karte (DO 0x93)\n"
msgid "card does not support digest algorithm %s\n"
msgstr "Der Hashalgorithmus %s wird von der Karte nicht unterstützt\n"
#: scd/app-openpgp.c:2172
#: scd/app-openpgp.c:2176
#, c-format
msgid "signatures created so far: %lu\n"
msgstr "Anzahl bereits erzeugter Signaturen: %lu\n"
#: scd/app-openpgp.c:2180
#: scd/app-openpgp.c:2184
#, c-format
msgid "||Please enter the PIN%%0A[sigs done: %lu]"
msgstr "||Bitte geben Sie die PIN ein%%0A[Sigs bisher: %lu]"
#: scd/app-openpgp.c:2441
#: scd/app-openpgp.c:2449
msgid ""
"verification of Admin PIN is currently prohibited through this command\n"
msgstr ""
"Die Überprüfung der Admin PIN is momentan durch ein Kommando verboten "
"worden\n"
#: scd/app-openpgp.c:2514 scd/app-openpgp.c:2524
#: scd/app-openpgp.c:2522 scd/app-openpgp.c:2532
#, c-format
msgid "can't access %s - invalid OpenPGP card?\n"
msgstr "Zugriff auf %s nicht möglich - ungültige OpenPGP Karte?\n"
@ -850,7 +860,7 @@ msgid "no key usage specified - assuming all usages\n"
msgstr ""
"Schlüsselverwendungszweck nicht vorhanden - für alle Zwecke akzeptiert\n"
#: sm/certlist.c:133 sm/keylist.c:246
#: sm/certlist.c:133 sm/keylist.c:254
#, c-format
msgid "error getting key usage information: %s\n"
msgstr "Fehler beim holen der Schlüsselbenutzungsinformationen: %s\n"
@ -886,121 +896,121 @@ msgstr "Das Zertifikat kann nicht zum Signieren benutzt werden\n"
msgid "critical certificate extension %s is not supported"
msgstr "Die kritische Zertifikaterweiterung %s wird nicht unterstützt"
#: sm/certchain.c:142
#: sm/certchain.c:144
msgid "issuer certificate is not marked as a CA"
msgstr "Das Herausgeberzertifikat ist nicht für eine CA gekennzeichnet"
#: sm/certchain.c:180
#: sm/certchain.c:182
msgid "critical marked policy without configured policies"
msgstr "kritische Richtlinie ohne konfigurierte Richtlinien"
#: sm/certchain.c:190
#: sm/certchain.c:192
#, c-format
msgid "failed to open `%s': %s\n"
msgstr "Datei `%s' kann nicht geöffnet werden: %s\n"
#: sm/certchain.c:197 sm/certchain.c:226
#: sm/certchain.c:199 sm/certchain.c:228
msgid "note: non-critical certificate policy not allowed"
msgstr "Notiz: Die unkritische Zertifikatrichtlinie ist nicht erlaubt"
#: sm/certchain.c:201 sm/certchain.c:230
#: sm/certchain.c:203 sm/certchain.c:232
msgid "certificate policy not allowed"
msgstr "Die Zertifikatrichtlinie ist nicht erlaubt"
#: sm/certchain.c:341
#: sm/certchain.c:343
msgid "looking up issuer at external location\n"
msgstr "Der Herausgeber wird von einer externen Stelle gesucht\n"
#: sm/certchain.c:361
#: sm/certchain.c:363
#, c-format
msgid "number of issuers matching: %d\n"
msgstr "Anzahl der übereinstimmenden Heruasgeber: %d\n"
#: sm/certchain.c:514 sm/certchain.c:678 sm/certchain.c:1116 sm/decrypt.c:261
#: sm/certchain.c:516 sm/certchain.c:680 sm/certchain.c:1118 sm/decrypt.c:261
#: sm/encrypt.c:342 sm/sign.c:325 sm/verify.c:107
msgid "failed to allocated keyDB handle\n"
msgstr "Ein keyDB Handle konnte nicht bereitgestellt werden\n"
#: sm/certchain.c:605
#: sm/certchain.c:607
msgid "certificate has been revoked"
msgstr "Das Zertifikat wurde widerrufen"
#: sm/certchain.c:614
#: sm/certchain.c:616
msgid "no CRL found for certificate"
msgstr "Keine CRL für das Zertifikat gefunden"
#: sm/certchain.c:618
#: sm/certchain.c:620
msgid "the available CRL is too old"
msgstr "Die vorhandene CRL ist zu alt"
#: sm/certchain.c:620
#: sm/certchain.c:622
msgid "please make sure that the \"dirmngr\" is properly installed\n"
msgstr ""
"Bitte vergewissern Sie sich das der \"dirmngr\" richtig installierrt ist\n"
#: sm/certchain.c:625
#: sm/certchain.c:627
#, c-format
msgid "checking the CRL failed: %s"
msgstr "Die CRL konnte nicht geprüft werden: %s"
#: sm/certchain.c:698
#: sm/certchain.c:700
msgid "no issuer found in certificate"
msgstr "Im Zertifikat ist kein Herausgeber enthalten"
#: sm/certchain.c:711
#: sm/certchain.c:713
#, c-format
msgid "certificate with invalid validity: %s"
msgstr "Zertifikat mit unzulässiger Gültigkeit: %s"
#: sm/certchain.c:727
#: sm/certchain.c:729
msgid "certificate not yet valid"
msgstr "Das Zertifikat ist noch nicht gültig"
#: sm/certchain.c:740
#: sm/certchain.c:742
msgid "certificate has expired"
msgstr "Das Zertifikat ist abgelaufen"
#: sm/certchain.c:777
#: sm/certchain.c:779
msgid "self-signed certificate has a BAD signature"
msgstr "Das eigenbeglaubigte Zertifikat hat eine FALSCHE Signatur"
#: sm/certchain.c:842
#: sm/certchain.c:844
msgid "root certificate is not marked trusted"
msgstr "Das Wurzelzertifikat ist nicht als vertrauenswürdig markiert"
#: sm/certchain.c:853
#: sm/certchain.c:855
#, c-format
msgid "fingerprint=%s\n"
msgstr "Fingerprint=%s\n"
#: sm/certchain.c:858
#: sm/certchain.c:860
msgid "root certificate has now been marked as trusted\n"
msgstr "Das Wurzelzertifikat wurde nun als vertrauenswürdig markiert\n"
#: sm/certchain.c:873
#: sm/certchain.c:875
#, c-format
msgid "checking the trust list failed: %s\n"
msgstr "Fehler beim Prüfen der vertrauenswürdigen Zertifikate: %s\n"
#: sm/certchain.c:899 sm/import.c:158
#: sm/certchain.c:901 sm/import.c:158
msgid "certificate chain too long\n"
msgstr "Der Zertifikatkette ist zu lang\n"
#: sm/certchain.c:911
#: sm/certchain.c:913
msgid "issuer certificate not found"
msgstr "Herausgeberzertifikat nicht gefunden"
#: sm/certchain.c:944
#: sm/certchain.c:946
msgid "certificate has a BAD signature"
msgstr "Das Zertifikat hat eine FALSCHE Signatur"
#: sm/certchain.c:974
#: sm/certchain.c:976
msgid "found another possible matching CA certificate - trying again"
msgstr ""
"Eine anderes möglicherweise passendes CA-Zertifikat gefunden - versuche "
"nochmal"
#: sm/certchain.c:997
#: sm/certchain.c:999
#, c-format
msgid "certificate chain longer than allowed by CA (%d)"
msgstr "Die Zertifikatkette ist länger als von der CA erlaubt (%d)"
@ -1356,32 +1366,32 @@ msgstr "Verschlüsseln für `%s' nicht möglich: %s\n"
msgid "libksba is too old (need %s, have %s)\n"
msgstr "Die Bibliothek Libksba is nicht aktuell (benötige %s, habe %s)\n"
#: sm/gpgsm.c:1229
#: sm/gpgsm.c:1230
msgid "WARNING: program may create a core file!\n"
msgstr "WARNUNG: Programm könnte eine core-dump-Datei schreiben!\n"
#: sm/gpgsm.c:1246
#: sm/gpgsm.c:1247
msgid "WARNING: running with faked system time: "
msgstr "WARNUNG: Ausführung mit gefälschter Systemzeit: "
#: sm/gpgsm.c:1272
#: sm/gpgsm.c:1273
msgid "selected cipher algorithm is invalid\n"
msgstr "Das ausgewählte Verschlüsselungsverfahren ist ungültig\n"
#: sm/gpgsm.c:1280
#: sm/gpgsm.c:1281
msgid "selected digest algorithm is invalid\n"
msgstr "Das ausgewählte Hashverfahren ist ungültig\n"
#: sm/gpgsm.c:1310
#: sm/gpgsm.c:1311
#, c-format
msgid "can't sign using `%s': %s\n"
msgstr "Signieren mit `%s' nicht möglich: %s\n"
#: sm/gpgsm.c:1483
#: sm/gpgsm.c:1495
msgid "this command has not yet been implemented\n"
msgstr "Dieses Kommando wurde noch nicht implementiert\n"
#: sm/gpgsm.c:1713 sm/gpgsm.c:1750 sm/qualified.c:74
#: sm/gpgsm.c:1740 sm/gpgsm.c:1777 sm/qualified.c:74
#, c-format
msgid "can't open `%s': %s\n"
msgstr "Datei `%s' kann nicht geöffnet werden: %s\n"

View File

@ -1,3 +1,19 @@
2006-09-06 Werner Koch <wk@g10code.com>
* apdu.c (pcsc_end_transaction):
* pcsc-wrapper.c (pcsc_end_transaction: Fixed dclaration.
Reported by Bob Dunlop.
* scdaemon.h (CTRL,APP): Removed and changed everywhere to
ctrl_t/app_t.
Replaced all Assuan error codes by libgpg-error codes. Removed
all map_to_assuan_status and map_assuan_err.
* scdaemon.c (main): Call assuan_set_assuan_err_source to have Assuan
switch to gpg-error codes.
* command.c (set_error): Adjusted.
2006-09-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (get_reader_slot): Return the slot_table index, not

View File

@ -274,7 +274,8 @@ long (* DLSTDCALL pcsc_status) (unsigned long card,
unsigned long *r_protocol,
unsigned char *atr, unsigned long *atrlen);
long (* DLSTDCALL pcsc_begin_transaction) (unsigned long card);
long (* DLSTDCALL pcsc_end_transaction) (unsigned long card);
long (* DLSTDCALL pcsc_end_transaction) (unsigned long card,
unsigned long disposition);
long (* DLSTDCALL pcsc_transmit) (unsigned long card,
const pcsc_io_request_t send_pci,
const unsigned char *send_buffer,

View File

@ -430,7 +430,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
/* Select the DINSIG application on the card in SLOT. This function
must be used before any other DINSIG application functions. */
gpg_error_t
app_select_dinsig (APP app)
app_select_dinsig (app_t app)
{
static char const aid[] = { 0xD2, 0x76, 0x00, 0x00, 0x66, 0x01 };
int slot = app->slot;

View File

@ -119,7 +119,7 @@ keygripstr_from_pk_file (int slot, int fid, char *r_gripstr)
static gpg_error_t
do_learn_status (APP app, CTRL ctrl)
do_learn_status (app_t app, ctrl_t ctrl)
{
gpg_error_t err;
char ct_buf[100], id_buf[100];
@ -490,7 +490,7 @@ do_decipher (app_t app, const char *keyidstr,
/* Select the NKS 2.0 application on the card in SLOT. */
gpg_error_t
app_select_nks (APP app)
app_select_nks (app_t app)
{
static char const aid[] = { 0xD2, 0x76, 0x00, 0x00, 0x03, 0x01, 0x02 };
int slot = app->slot;

View File

@ -492,7 +492,7 @@ app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp)
/* Write out the application specifig status lines for the LEARN
command. */
gpg_error_t
app_write_learn_status (app_t app, CTRL ctrl)
app_write_learn_status (app_t app, ctrl_t ctrl)
{
gpg_error_t err;
@ -574,7 +574,7 @@ app_readkey (app_t app, const char *keyid, unsigned char **pk, size_t *pklen)
/* Perform a GETATTR operation. */
gpg_error_t
app_getattr (app_t app, CTRL ctrl, const char *name)
app_getattr (app_t app, ctrl_t ctrl, const char *name)
{
gpg_error_t err;
@ -763,7 +763,7 @@ app_writekey (app_t app, ctrl_t ctrl,
/* Perform a SETATTR operation. */
gpg_error_t
app_genkey (app_t app, CTRL ctrl, const char *keynostr, unsigned int flags,
app_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
gpg_error_t (*pincb)(void*, const char *, char **),
void *pincb_arg)
{
@ -810,7 +810,7 @@ app_get_challenge (app_t app, size_t nbytes, unsigned char *buffer)
/* Perform a CHANGE REFERENCE DATA or RESET RETRY COUNTER operation. */
gpg_error_t
app_change_pin (app_t app, CTRL ctrl, const char *chvnostr, int reset_mode,
app_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr, int reset_mode,
gpg_error_t (*pincb)(void*, const char *, char **),
void *pincb_arg)
{

View File

@ -45,7 +45,7 @@
#define MAXLEN_KEYDATA 4096
#define set_error(e,t) assuan_set_error (ctx, ASSUAN_ ## e, (t))
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
/* Macro to flag a removed card. */
@ -262,7 +262,7 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
/* A value of 0 is allowed to reset the event signal. */
int i = *value? atoi (value) : -1;
if (i < 0)
return ASSUAN_Parameter_Error;
return gpg_error (GPG_ERR_ASS_PARAMETER);
ctrl->server_local->event_signal = i;
}
@ -309,7 +309,7 @@ open_card (ctrl_t ctrl, const char *apptype)
the SERIALNO command and a reset are able to clear from that
state. */
if (ctrl->server_local->card_removed)
return map_to_assuan_status (gpg_error (GPG_ERR_CARD_REMOVED));
return gpg_error (GPG_ERR_CARD_REMOVED);
if ( IS_LOCKED (ctrl) )
return gpg_error (GPG_ERR_LOCKED);
@ -333,7 +333,7 @@ open_card (ctrl_t ctrl, const char *apptype)
err = select_application (ctrl, slot, apptype, &ctrl->app_ctx);
TEST_CARD_REMOVAL (ctrl, err);
return map_to_assuan_status (err);
return err;
}
@ -413,12 +413,12 @@ cmd_serialno (assuan_context_t ctx, char *line)
rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp);
if (rc)
return map_to_assuan_status (rc);
return rc;
rc = asprintf (&serial_and_stamp, "%s %lu", serial, (unsigned long)stamp);
xfree (serial);
if (rc < 0)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = 0;
assuan_write_status (ctx, "SERIALNO", serial_and_stamp);
free (serial_and_stamp);
@ -510,11 +510,11 @@ cmd_learn (assuan_context_t ctx, char *line)
rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp);
if (rc)
return map_to_assuan_status (rc);
return rc;
rc = asprintf (&serial_and_stamp, "%s %lu", serial, (unsigned long)stamp);
xfree (serial);
if (rc < 0)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = 0;
assuan_write_status (ctx, "SERIALNO", serial_and_stamp);
@ -526,16 +526,16 @@ cmd_learn (assuan_context_t ctx, char *line)
if (rc < 0)
{
free (serial_and_stamp);
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
rc = 0;
rc = assuan_inquire (ctx, command, NULL, NULL, 0);
free (command); /* (must use standard free here) */
if (rc)
{
if (rc != ASSUAN_Canceled)
if (gpg_err_code (rc) != GPG_ERR_ASS_CANCELED)
log_error ("inquire KNOWNCARDP failed: %s\n",
assuan_strerror (rc));
gpg_strerror (rc));
free (serial_and_stamp);
return rc;
}
@ -550,7 +550,7 @@ cmd_learn (assuan_context_t ctx, char *line)
rc = app_write_learn_status (ctrl->app_ctx, ctrl);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -585,7 +585,7 @@ cmd_readcert (assuan_context_t ctx, char *line)
}
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -620,7 +620,6 @@ cmd_readkey (assuan_context_t ctx, char *line)
{ /* Yeah, got that key - send it back. */
rc = assuan_send_data (ctx, pk, pklen);
xfree (pk);
rc = map_assuan_err (rc);
xfree (line);
line = NULL;
goto leave;
@ -661,7 +660,6 @@ cmd_readkey (assuan_context_t ctx, char *line)
n = gcry_sexp_canon_len (p, 0, NULL, NULL);
rc = assuan_send_data (ctx, p, n);
rc = map_assuan_err (rc);
xfree (p);
@ -669,7 +667,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
ksba_cert_release (kc);
xfree (cert);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -694,15 +692,15 @@ cmd_setdata (assuan_context_t ctx, char *line)
for (p=line,n=0; hexdigitp (p); p++, n++)
;
if (*p)
return set_error (Parameter_Error, "invalid hexstring");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid hexstring");
if (!n)
return set_error (Parameter_Error, "no data given");
return set_error (GPG_ERR_ASS_PARAMETER, "no data given");
if ((n&1))
return set_error (Parameter_Error, "odd number of digits");
return set_error (GPG_ERR_ASS_PARAMETER, "odd number of digits");
n /= 2;
buf = xtrymalloc (n);
if (!buf)
return ASSUAN_Out_Of_Core;
return out_of_core ();
ctrl->in_data.value = buf;
ctrl->in_data.valuelen = n;
@ -734,7 +732,7 @@ pin_cb (void *opaque, const char *info, char **retstr)
rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN);
free (command);
if (rc)
return map_assuan_err (rc);
return rc;
if (!valuelen || value[valuelen-1])
{
@ -771,7 +769,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
else if (!strstr (line, "--"))
hash_algo = GCRY_MD_SHA1;
else
return set_error (Parameter_Error, "invalid hash algorithm");
return set_error (GPG_ERR_ASS_PARAMETER, "invalid hash algorithm");
/* Skip over options. */
while ( *line == '-' && line[1] == '-' )
{
@ -792,7 +790,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
overwriting the original line with the keyid */
keyidstr = xtrystrdup (line);
if (!keyidstr)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = app_sign (ctrl->app_ctx,
keyidstr, hash_algo,
@ -814,7 +812,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
}
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
/* PKAUTH <hexified_id>
@ -843,7 +841,7 @@ cmd_pkauth (assuan_context_t ctx, char *line)
overwriting the original line with the keyid */
keyidstr = xtrystrdup (line);
if (!keyidstr)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = app_auth (ctrl->app_ctx,
keyidstr,
@ -864,7 +862,7 @@ cmd_pkauth (assuan_context_t ctx, char *line)
}
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
/* PKDECRYPT <hexified_id>
@ -887,7 +885,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
keyidstr = xtrystrdup (line);
if (!keyidstr)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = app_decipher (ctrl->app_ctx,
keyidstr,
pin_cb, ctx,
@ -908,7 +906,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
}
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -947,7 +945,7 @@ cmd_getattr (assuan_context_t ctx, char *line)
rc = app_getattr (ctrl->app_ctx, ctrl, keyword);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -983,7 +981,7 @@ cmd_setattr (assuan_context_t ctx, char *orig_line)
context and thus reuses the Assuan provided LINE. */
line = linebuf = xtrystrdup (orig_line);
if (!line)
return ASSUAN_Out_Of_Core;
return out_of_core ();
keyword = line;
for (keywordlen=0; *line && !spacep (line); line++, keywordlen++)
@ -999,7 +997,7 @@ cmd_setattr (assuan_context_t ctx, char *orig_line)
xfree (linebuf);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -1039,7 +1037,7 @@ cmd_writekey (assuan_context_t ctx, char *line)
line++;
}
if (!*line)
return set_error (Parameter_Error, "no keyid given");
return set_error (GPG_ERR_ASS_PARAMETER, "no keyid given");
keyid = line;
while (*line && !spacep (line))
line++;
@ -1053,7 +1051,7 @@ cmd_writekey (assuan_context_t ctx, char *line)
keyid = xtrystrdup (keyid);
if (!keyid)
return ASSUAN_Out_Of_Core;
return out_of_core ();
/* Now get the actual keydata. */
rc = assuan_inquire (ctx, "KEYDATA", &keydata, &keydatalen, MAXLEN_KEYDATA);
@ -1070,7 +1068,7 @@ cmd_writekey (assuan_context_t ctx, char *line)
xfree (keydata);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -1114,7 +1112,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
line++;
}
if (!*line)
return set_error (Parameter_Error, "no key number given");
return set_error (GPG_ERR_ASS_PARAMETER, "no key number given");
keyno = line;
while (*line && !spacep (line))
line++;
@ -1128,12 +1126,12 @@ cmd_genkey (assuan_context_t ctx, char *line)
keyno = xtrystrdup (keyno);
if (!keyno)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = app_genkey (ctrl->app_ctx, ctrl, keyno, force? 1:0, pin_cb, ctx);
xfree (keyno);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -1152,7 +1150,7 @@ cmd_random (assuan_context_t ctx, char *line)
unsigned char *buffer;
if (!*line)
return set_error (Parameter_Error, "number of requested bytes missing");
return set_error (GPG_ERR_ASS_PARAMETER, "number of requested bytes missing");
nbytes = strtoul (line, NULL, 0);
if ((rc = open_card (ctrl, NULL)))
@ -1163,7 +1161,7 @@ cmd_random (assuan_context_t ctx, char *line)
buffer = xtrymalloc (nbytes);
if (!buffer)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = app_get_challenge (ctrl->app_ctx, nbytes, buffer);
if (!rc)
@ -1175,7 +1173,7 @@ cmd_random (assuan_context_t ctx, char *line)
xfree (buffer);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -1203,7 +1201,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
line++;
}
if (!*line)
return set_error (Parameter_Error, "no CHV number given");
return set_error (GPG_ERR_ASS_PARAMETER, "no CHV number given");
chvnostr = line;
while (*line && !spacep (line))
line++;
@ -1217,14 +1215,14 @@ cmd_passwd (assuan_context_t ctx, char *line)
chvnostr = xtrystrdup (chvnostr);
if (!chvnostr)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = app_change_pin (ctrl->app_ctx, ctrl, chvnostr, reset_mode, pin_cb, ctx);
if (rc)
log_error ("command passwd failed: %s\n", gpg_strerror (rc));
xfree (chvnostr);
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -1268,7 +1266,7 @@ cmd_checkpin (assuan_context_t ctx, char *line)
overwriting the original line with the keyid. */
keyidstr = xtrystrdup (line);
if (!keyidstr)
return ASSUAN_Out_Of_Core;
return out_of_core ();
rc = app_check_pin (ctrl->app_ctx,
keyidstr,
@ -1278,7 +1276,7 @@ cmd_checkpin (assuan_context_t ctx, char *line)
log_error ("app_check_pin failed: %s\n", gpg_strerror (rc));
TEST_CARD_REMOVAL (ctrl, rc);
return map_to_assuan_status (rc);
return rc;
}
@ -1322,7 +1320,7 @@ cmd_lock (assuan_context_t ctx, char *line)
if (rc)
log_error ("cmd_lock failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -1348,7 +1346,7 @@ cmd_unlock (assuan_context_t ctx, char *line)
if (rc)
log_error ("cmd_unlock failed: %s\n", gpg_strerror (rc));
return map_to_assuan_status (rc);
return rc;
}
@ -1404,7 +1402,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
rc = assuan_send_data (ctx, &flag, 1);
}
else
rc = set_error (Parameter_Error, "unknown value for WHAT");
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
return rc;
}
@ -1460,7 +1458,6 @@ cmd_apdu (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
int rc_is_assuan = 0;
unsigned char *apdu;
size_t apdulen;
int with_atr;
@ -1520,7 +1517,6 @@ cmd_apdu (assuan_context_t ctx, char *line)
log_error ("apdu_send_direct failed: %s\n", gpg_strerror (rc));
else
{
rc_is_assuan = 1;
rc = assuan_send_data (ctx, result, resultlen);
xfree (result);
}
@ -1529,7 +1525,7 @@ cmd_apdu (assuan_context_t ctx, char *line)
leave:
TEST_CARD_REMOVAL (ctrl, rc);
return rc_is_assuan? rc : map_to_assuan_status (rc);
return rc;
}
@ -1611,14 +1607,14 @@ scd_command_handler (int fd)
if (rc)
{
log_error ("failed to initialize the server: %s\n",
assuan_strerror(rc));
gpg_strerror(rc));
scd_exit (2);
}
rc = register_commands (ctx);
if (rc)
{
log_error ("failed to register commands with Assuan: %s\n",
assuan_strerror(rc));
gpg_strerror(rc));
scd_exit (2);
}
assuan_set_pointer (ctx, &ctrl);
@ -1651,14 +1647,14 @@ scd_command_handler (int fd)
}
else if (rc)
{
log_info ("Assuan accept problem: %s\n", assuan_strerror (rc));
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
break;
}
rc = assuan_process (ctx);
if (rc)
{
log_info ("Assuan processing failed: %s\n", assuan_strerror (rc));
log_info ("Assuan processing failed: %s\n", gpg_strerror (rc));
continue;
}
}

View File

@ -169,7 +169,8 @@ long (* pcsc_status) (unsigned long card,
unsigned long *r_protocol,
unsigned char *atr, unsigned long *atrlen);
long (* pcsc_begin_transaction) (unsigned long card);
long (* pcsc_end_transaction) (unsigned long card);
long (* pcsc_end_transaction) (unsigned long card,
unsigned long disposition);
long (* pcsc_transmit) (unsigned long card,
const pcsc_io_request_t send_pci,
const unsigned char *send_buffer,

View File

@ -360,6 +360,8 @@ main (int argc, char **argv )
assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
assuan_set_assuan_log_stream (log_get_stream ());
assuan_set_assuan_log_prefix (log_get_prefix (NULL));
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
gcry_set_log_handler (my_gcry_logger, NULL);
gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);

View File

@ -27,10 +27,6 @@
#endif
#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_SCD
#include <gpg-error.h>
#define map_assuan_err(a) \
map_assuan_err_with_source (GPG_ERR_SOURCE_DEFAULT, (a))
#include <errno.h>
#include <time.h>
#include <gcrypt.h>
@ -41,7 +37,8 @@
#define MAX_DIGEST_LEN 24
/* A large struct name "opt" to keep global flags. */
struct {
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE). */
int verbose; /* Verbosity level. */
int quiet; /* Be as quiet as possible. */
@ -103,9 +100,7 @@ struct server_control_s
} in_data;
};
typedef struct server_control_s *CTRL;
typedef struct server_control_s *ctrl_t;
typedef struct app_ctx_s *APP;
typedef struct app_ctx_s *app_t;
/*-- scdaemon.c --*/
@ -115,7 +110,7 @@ const char *scd_get_socket_name (void);
/*-- command.c --*/
void scd_command_handler (int);
void send_status_info (CTRL ctrl, const char *keyword, ...);
void send_status_info (ctrl_t ctrl, const char *keyword, ...);
void scd_update_reader_status_file (void);

View File

@ -1,3 +1,17 @@
2006-09-06 Werner Koch <wk@g10code.com>
* gpgsm.h (OUT_OF_CORE): Removed and changed all callers to
out_of_core.
(CTRL): Removed and changed everywhere to ctrl_t.
(CERTLIST): Ditto.
Replaced all Assuan error codes by libgpg-error codes. Removed
all map_to_assuan_status and map_assuan_err.
* gpgsm.c (main): Call assuan_set_assuan_err_source to have Assuan
switch to gpg-error codes.
* server.c (set_error): Adjusted.
2006-08-29 Werner Koch <wk@g10code.com>
* call-agent.c (gpgsm_agent_pkdecrypt): Allow decryption using

View File

@ -522,7 +522,7 @@ base64_finish_write (struct writer_cb_parm_s *parm)
until no more objects were found. */
int
gpgsm_create_reader (Base64Context *ctx,
CTRL ctrl, FILE *fp, int allow_multi_pem,
ctrl_t ctrl, FILE *fp, int allow_multi_pem,
ksba_reader_t *r_reader)
{
int rc;
@ -531,7 +531,7 @@ gpgsm_create_reader (Base64Context *ctx,
*r_reader = NULL;
*ctx = xtrycalloc (1, sizeof **ctx);
if (!*ctx)
return OUT_OF_CORE (errno);
return out_of_core ();
(*ctx)->u.rparm.allow_multi_pem = allow_multi_pem;
rc = ksba_reader_new (&r);
@ -595,7 +595,7 @@ gpgsm_destroy_reader (Base64Context ctx)
function on. */
int
gpgsm_create_writer (Base64Context *ctx,
CTRL ctrl, FILE *fp, ksba_writer_t *r_writer)
ctrl_t ctrl, FILE *fp, ksba_writer_t *r_writer)
{
int rc;
ksba_writer_t w;
@ -603,7 +603,7 @@ gpgsm_create_writer (Base64Context *ctx,
*r_writer = NULL;
*ctx = xtrycalloc (1, sizeof **ctx);
if (!*ctx)
return OUT_OF_CORE (errno);
return out_of_core ();
rc = ksba_writer_new (&w);
if (rc)

View File

@ -129,7 +129,7 @@ start_agent (ctrl_t ctrl)
no_close_list[i] = -1;
/* Connect to the agent and perform initial handshaking. */
rc = assuan_pipe_connect (&ctx, opt.agent_program, (char**)argv,
rc = assuan_pipe_connect (&ctx, opt.agent_program, argv,
no_close_list);
}
}
@ -162,7 +162,7 @@ start_agent (ctrl_t ctrl)
rc = assuan_socket_connect (&ctx, infostr, pid);
xfree (infostr);
if (rc == ASSUAN_Connect_Failed)
if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED)
{
log_error (_("can't connect to the agent - trying fall back\n"));
force_pipe_server = 1;
@ -172,7 +172,7 @@ start_agent (ctrl_t ctrl)
if (rc)
{
log_error ("can't connect to the agent: %s\n", assuan_strerror (rc));
log_error ("can't connect to the agent: %s\n", gpg_strerror (rc));
return gpg_error (GPG_ERR_NO_AGENT);
}
agent_ctx = ctx;
@ -182,7 +182,7 @@ start_agent (ctrl_t ctrl)
rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
return send_pinentry_environment (agent_ctx, GPG_ERR_SOURCE_DEFAULT,
opt.display, opt.ttyname, opt.ttytype,
@ -190,7 +190,7 @@ start_agent (ctrl_t ctrl)
}
static AssuanError
static int
membuf_data_cb (void *opaque, const void *buffer, size_t length)
{
membuf_t *data = opaque;
@ -225,13 +225,13 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
snprintf (line, DIM(line)-1, "SIGKEY %s", keygrip);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
if (desc)
{
@ -240,7 +240,7 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
}
sprintf (line, "SETHASH %d ", digestalgo);
@ -249,7 +249,7 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
sprintf (p, "%02X", digest[i]);
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
init_membuf (&data, 1024);
rc = assuan_transact (agent_ctx, "PKSIGN",
@ -257,7 +257,7 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
if (rc)
{
xfree (get_membuf (&data, &len));
return map_assuan_err (rc);
return rc;
}
*r_buf = get_membuf (&data, r_buflen);
@ -267,7 +267,7 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
return gpg_error (GPG_ERR_INV_VALUE);
}
return *r_buf? 0 : OUT_OF_CORE (errno);
return *r_buf? 0 : out_of_core ();
}
@ -275,11 +275,11 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
/* Handle a CIPHERTEXT inquiry. Note, we only send the data,
assuan_transact talkes care of flushing and writing the end */
static AssuanError
static int
inq_ciphertext_cb (void *opaque, const char *keyword)
{
struct cipher_parm_s *parm = opaque;
AssuanError rc;
int rc;
assuan_begin_confidential (parm->ctx);
rc = assuan_send_data (parm->ctx, parm->ciphertext, parm->ciphertextlen);
@ -317,14 +317,14 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
assert ( DIM(line) >= 50 );
snprintf (line, DIM(line)-1, "SETKEY %s", keygrip);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
if (desc)
{
@ -333,7 +333,7 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
}
init_membuf (&data, 1024);
@ -346,7 +346,7 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
if (rc)
{
xfree (get_membuf (&data, &len));
return map_assuan_err (rc);
return rc;
}
put_membuf (&data, "", 1); /* Make sure it is 0 terminated. */
@ -390,11 +390,11 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
/* Handle a KEYPARMS inquiry. Note, we only send the data,
assuan_transact takes care of flushing and writing the end */
static AssuanError
static int
inq_genkey_parms (void *opaque, const char *keyword)
{
struct genkey_parm_s *parm = opaque;
AssuanError rc;
int rc;
rc = assuan_send_data (parm->ctx, parm->sexp, parm->sexplen);
return rc;
@ -420,7 +420,7 @@ gpgsm_agent_genkey (ctrl_t ctrl,
rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
init_membuf (&data, 1024);
gk_parm.ctx = agent_ctx;
@ -434,7 +434,7 @@ gpgsm_agent_genkey (ctrl_t ctrl,
if (rc)
{
xfree (get_membuf (&data, &len));
return map_assuan_err (rc);
return rc;
}
buf = get_membuf (&data, &len);
if (!buf)
@ -467,7 +467,7 @@ gpgsm_agent_readkey (ctrl_t ctrl, const char *hexkeygrip,
rc = assuan_transact (agent_ctx, "RESET",NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
snprintf (line, DIM(line)-1, "READKEY %s", hexkeygrip);
line[DIM(line)-1] = 0;
@ -479,7 +479,7 @@ gpgsm_agent_readkey (ctrl_t ctrl, const char *hexkeygrip,
if (rc)
{
xfree (get_membuf (&data, &len));
return map_assuan_err (rc);
return rc;
}
buf = get_membuf (&data, &len);
if (!buf)
@ -519,7 +519,7 @@ gpgsm_agent_istrusted (ctrl_t ctrl, ksba_cert_t cert)
xfree (fpr);
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}
/* Ask the agent to mark CERT as a trusted Root-CA one */
@ -553,7 +553,7 @@ gpgsm_agent_marktrusted (ctrl_t ctrl, ksba_cert_t cert)
xfree (fpr);
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}
@ -577,11 +577,11 @@ gpgsm_agent_havekey (ctrl_t ctrl, const char *hexkeygrip)
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}
static AssuanError
static int
learn_cb (void *opaque, const void *buffer, size_t length)
{
struct learn_parm_s *parm = opaque;
@ -671,7 +671,7 @@ gpgsm_agent_learn (ctrl_t ctrl)
NULL, NULL, NULL, NULL);
xfree (get_membuf (&data, &len));
if (rc)
return map_assuan_err (rc);
return rc;
return learn_parm.error;
}
@ -699,14 +699,14 @@ gpgsm_agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc)
rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
return rc;
}
snprintf (line, DIM(line)-1, "PASSWD %s", hexkeygrip);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}
@ -727,5 +727,5 @@ gpgsm_agent_get_confirmation (ctrl_t ctrl, const char *desc)
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return map_assuan_err (rc);
return rc;
}

View File

@ -48,25 +48,25 @@ struct membuf {
static ASSUAN_CONTEXT dirmngr_ctx = NULL;
static assuan_context_t dirmngr_ctx = NULL;
static int force_pipe_server = 0;
struct inq_certificate_parm_s {
ASSUAN_CONTEXT ctx;
assuan_context_t ctx;
ksba_cert_t cert;
ksba_cert_t issuer_cert;
};
struct isvalid_status_parm_s {
CTRL ctrl;
ctrl_t ctrl;
int seen;
unsigned char fpr[20];
};
struct lookup_parm_s {
CTRL ctrl;
ASSUAN_CONTEXT ctx;
ctrl_t ctrl;
assuan_context_t ctx;
void (*cb)(void *, ksba_cert_t);
void *cb_value;
struct membuf data;
@ -74,7 +74,7 @@ struct lookup_parm_s {
};
struct run_command_parm_s {
ASSUAN_CONTEXT ctx;
assuan_context_t ctx;
};
@ -148,7 +148,7 @@ start_dirmngr (void)
{
int rc;
char *infostr, *p;
ASSUAN_CONTEXT ctx;
assuan_context_t ctx;
int try_default = 0;
if (dirmngr_ctx)
@ -200,7 +200,7 @@ start_dirmngr (void)
no_close_list[i] = -1;
/* connect to the agent and perform initial handshaking */
rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, (char**)argv,
rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, argv,
no_close_list);
}
else
@ -237,7 +237,7 @@ start_dirmngr (void)
rc = assuan_socket_connect (&ctx, infostr, pid);
xfree (infostr);
if (rc == ASSUAN_Connect_Failed)
if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED)
{
log_error (_("can't connect to the dirmngr - trying fall back\n"));
force_pipe_server = 1;
@ -247,7 +247,7 @@ start_dirmngr (void)
if (rc)
{
log_error ("can't connect to the dirmngr: %s\n", assuan_strerror (rc));
log_error ("can't connect to the dirmngr: %s\n", gpg_strerror (rc));
return gpg_error (GPG_ERR_NO_DIRMNGR);
}
dirmngr_ctx = ctx;
@ -260,11 +260,11 @@ start_dirmngr (void)
/* Handle a SENDCERT inquiry. */
static AssuanError
static int
inq_certificate (void *opaque, const char *line)
{
struct inq_certificate_parm_s *parm = opaque;
AssuanError rc;
int rc;
const unsigned char *der;
size_t derlen;
int issuer_mode = 0;
@ -296,7 +296,7 @@ inq_certificate (void *opaque, const char *line)
else
{
log_error ("unsupported inquiry `%s'\n", line);
return ASSUAN_Inquire_Unknown;
return gpg_error (GPG_ERR_ASS_UNKNOWN_INQUIRE);
}
if (!*line)
@ -304,7 +304,7 @@ inq_certificate (void *opaque, const char *line)
der = ksba_cert_get_image (issuer_mode? parm->issuer_cert : parm->cert,
&derlen);
if (!der)
rc = ASSUAN_Inquire_Error;
rc = gpg_error (GPG_ERR_INV_CERT_OBJ);
else
rc = assuan_send_data (parm->ctx, der, derlen);
}
@ -312,7 +312,7 @@ inq_certificate (void *opaque, const char *line)
{
log_error ("sending specific issuer certificate back "
"is not yet implemented\n");
rc = ASSUAN_Inquire_Error;
rc = gpg_error (GPG_ERR_ASS_UNKNOWN_INQUIRE);
}
else
{ /* Send the given certificate. */
@ -324,13 +324,13 @@ inq_certificate (void *opaque, const char *line)
if (err)
{
log_error ("certificate not found: %s\n", gpg_strerror (err));
rc = ASSUAN_Inquire_Error;
rc = gpg_error (GPG_ERR_NOT_FOUND);
}
else
{
der = ksba_cert_get_image (cert, &derlen);
if (!der)
rc = ASSUAN_Inquire_Error;
rc = gpg_error (GPG_ERR_INV_CERT_OBJ);
else
rc = assuan_send_data (parm->ctx, der, derlen);
ksba_cert_release (cert);
@ -373,7 +373,7 @@ isvalid_status_cb (void *opaque, const char *line)
for (line += 8; *line == ' '; line++)
;
if (gpgsm_status (parm->ctrl, STATUS_PROGRESS, line))
return ASSUAN_Canceled;
return gpg_error (GPG_ERR_ASS_CANCELED);
}
}
else if (!strncmp (line, "ONLY_VALID_IF_CERT_VALID", 24)
@ -466,8 +466,8 @@ gpgsm_dirmngr_isvalid (ctrl_t ctrl,
inq_certificate, &parm,
isvalid_status_cb, &stparm);
if (opt.verbose > 1)
log_info ("response of dirmngr: %s\n", rc? assuan_strerror (rc): "okay");
rc = map_assuan_err (rc);
log_info ("response of dirmngr: %s\n", rc? gpg_strerror (rc): "okay");
rc = rc;
if (!rc && stparm.seen)
{
@ -526,7 +526,7 @@ gpgsm_dirmngr_isvalid (ctrl_t ctrl,
/* Lookup helpers*/
static AssuanError
static int
lookup_cb (void *opaque, const void *buffer, size_t length)
{
struct lookup_parm_s *parm = opaque;
@ -632,7 +632,7 @@ pattern_from_strlist (STRLIST names)
return pattern;
}
static AssuanError
static int
lookup_status_cb (void *opaque, const char *line)
{
struct lookup_parm_s *parm = opaque;
@ -644,7 +644,7 @@ lookup_status_cb (void *opaque, const char *line)
for (line += 8; *line == ' '; line++)
;
if (gpgsm_status (parm->ctrl, STATUS_PROGRESS, line))
return ASSUAN_Canceled;
return gpg_error (GPG_ERR_ASS_CANCELED);
}
}
else if (!strncmp (line, "TRUNCATED", 9) && (line[9]==' ' || !line[9]))
@ -665,7 +665,7 @@ lookup_status_cb (void *opaque, const char *line)
the callback CB which will be passed cert by cert. Note that CTRL
is optional. */
int
gpgsm_dirmngr_lookup (CTRL ctrl, STRLIST names,
gpgsm_dirmngr_lookup (ctrl_t ctrl, STRLIST names,
void (*cb)(void*, ksba_cert_t), void *cb_value)
{
int rc;
@ -680,7 +680,7 @@ gpgsm_dirmngr_lookup (CTRL ctrl, STRLIST names,
pattern = pattern_from_strlist (names);
if (!pattern)
return OUT_OF_CORE (errno);
return out_of_core ();
snprintf (line, DIM(line)-1, "LOOKUP %s", pattern);
line[DIM(line)-1] = 0;
xfree (pattern);
@ -696,7 +696,7 @@ gpgsm_dirmngr_lookup (CTRL ctrl, STRLIST names,
NULL, NULL, lookup_status_cb, &parm);
xfree (get_membuf (&parm.data, &len));
if (rc)
return map_assuan_err (rc);
return rc;
return parm.error;
}
@ -705,7 +705,7 @@ gpgsm_dirmngr_lookup (CTRL ctrl, STRLIST names,
/* Run Command helpers*/
/* Fairly simple callback to write all output of dirmngr to stdout. */
static AssuanError
static int
run_command_cb (void *opaque, const void *buffer, size_t length)
{
if (buffer)
@ -717,11 +717,11 @@ run_command_cb (void *opaque, const void *buffer, size_t length)
}
/* Handle inquiries from the dirmngr COMMAND. */
static AssuanError
static int
run_command_inq_cb (void *opaque, const char *line)
{
struct run_command_parm_s *parm = opaque;
AssuanError rc = 0;
int rc = 0;
if ( !strncmp (line, "SENDCERT", 8) && (line[8] == ' ' || !line[8]) )
{ /* send the given certificate */
@ -732,19 +732,19 @@ run_command_inq_cb (void *opaque, const char *line)
line += 8;
if (!*line)
return ASSUAN_Inquire_Error;
return gpg_error (GPG_ERR_ASS_PARAMETER);
err = gpgsm_find_cert (line, NULL, &cert);
if (err)
{
log_error ("certificate not found: %s\n", gpg_strerror (err));
rc = ASSUAN_Inquire_Error;
rc = gpg_error (GPG_ERR_NOT_FOUND);
}
else
{
der = ksba_cert_get_image (cert, &derlen);
if (!der)
rc = ASSUAN_Inquire_Error;
rc = gpg_error (GPG_ERR_INV_CERT_OBJ);
else
rc = assuan_send_data (parm->ctx, der, derlen);
ksba_cert_release (cert);
@ -758,13 +758,13 @@ run_command_inq_cb (void *opaque, const char *line)
else
{
log_error ("unsupported inquiry `%s'\n", line);
rc = ASSUAN_Inquire_Unknown;
rc = gpg_error (GPG_ERR_ASS_UNKNOWN_INQUIRE);
}
return rc;
}
static AssuanError
static int
run_command_status_cb (void *opaque, const char *line)
{
ctrl_t ctrl = opaque;
@ -780,7 +780,7 @@ run_command_status_cb (void *opaque, const char *line)
for (line += 8; *line == ' '; line++)
;
if (gpgsm_status (ctrl, STATUS_PROGRESS, line))
return ASSUAN_Canceled;
return gpg_error (GPG_ERR_ASS_CANCELED);
}
}
return 0;
@ -794,7 +794,7 @@ run_command_status_cb (void *opaque, const char *line)
percent characters within the argument strings are percent escaped
so that blanks can act as delimiters. */
int
gpgsm_dirmngr_run_command (CTRL ctrl, const char *command,
gpgsm_dirmngr_run_command (ctrl_t ctrl, const char *command,
int argc, char **argv)
{
int rc;
@ -815,7 +815,7 @@ gpgsm_dirmngr_run_command (CTRL ctrl, const char *command,
len += 1 + 3*strlen (argv[i]); /* enough space for percent escaping */
line = xtrymalloc (len);
if (!line)
return OUT_OF_CORE (errno);
return out_of_core ();
p = stpcpy (line, command);
for (i=0; i < argc; i++)
@ -843,6 +843,6 @@ gpgsm_dirmngr_run_command (CTRL ctrl, const char *command,
run_command_inq_cb, &parm,
run_command_status_cb, ctrl);
xfree (line);
log_info ("response of dirmngr: %s\n", rc? assuan_strerror (rc): "okay");
return map_assuan_err (rc);
log_info ("response of dirmngr: %s\n", rc? gpg_strerror (rc): "okay");
return rc;
}

View File

@ -54,7 +54,7 @@ do_encode_md (gcry_md_hd_t md, int algo, int pkalgo, unsigned int nbits,
}
frame = xtrymalloc (nframe);
if (!frame)
return OUT_OF_CORE (errno);
return out_of_core ();
memcpy (frame, gcry_md_read (md, algo), nframe);
n = nframe;
}
@ -91,7 +91,7 @@ do_encode_md (gcry_md_hd_t md, int algo, int pkalgo, unsigned int nbits,
*/
frame = xtrymalloc (nframe);
if (!frame)
return OUT_OF_CORE (errno);
return out_of_core ();
n = 0;
frame[n++] = 0;
frame[n++] = 1; /* block type */

View File

@ -258,7 +258,7 @@ gpgsm_add_cert_to_certlist (ctrl_t ctrl, ksba_cert_t cert,
{
certlist_t cl = xtrycalloc (1, sizeof *cl);
if (!cl)
return OUT_OF_CORE (errno);
return out_of_core ();
cl->cert = cert;
ksba_cert_ref (cert);
cl->next = *listaddr;
@ -274,7 +274,7 @@ gpgsm_add_cert_to_certlist (ctrl_t ctrl, ksba_cert_t cert,
flag in the new create LISTADDR item. */
int
gpgsm_add_to_certlist (ctrl_t ctrl, const char *name, int secret,
CERTLIST *listaddr, int is_encrypt_to)
certlist_t *listaddr, int is_encrypt_to)
{
int rc;
KEYDB_SEARCH_DESC desc;
@ -379,9 +379,9 @@ gpgsm_add_to_certlist (ctrl_t ctrl, const char *name, int secret,
rc = gpgsm_validate_chain (ctrl, cert, NULL, 0, NULL, 0);
if (!rc)
{
CERTLIST cl = xtrycalloc (1, sizeof *cl);
certlist_t cl = xtrycalloc (1, sizeof *cl);
if (!cl)
rc = OUT_OF_CORE (errno);
rc = out_of_core ();
else
{
cl->cert = cert; cert = NULL;
@ -400,11 +400,11 @@ gpgsm_add_to_certlist (ctrl_t ctrl, const char *name, int secret,
}
void
gpgsm_release_certlist (CERTLIST list)
gpgsm_release_certlist (certlist_t list)
{
while (list)
{
CERTLIST cl = list->next;
certlist_t cl = list->next;
ksba_cert_release (list->cert);
xfree (list);
list = cl;

View File

@ -606,7 +606,7 @@ create_request (ctrl_t ctrl,
buf = xtrymalloc (strlen (s) + 3);
if (!buf)
{
rc = OUT_OF_CORE (errno);
rc = out_of_core ();
goto leave;
}
*buf = '<';
@ -631,7 +631,7 @@ create_request (ctrl_t ctrl,
buf = p = xtrymalloc (11 + strlen (numbuf) + len + 3);
if (!buf)
{
rc = OUT_OF_CORE (errno);
rc = out_of_core ();
goto leave;
}
p = stpcpy (p, "(8:dns-name");
@ -658,7 +658,7 @@ create_request (ctrl_t ctrl,
buf = p = xtrymalloc (6 + strlen (numbuf) + len + 3);
if (!buf)
{
rc = OUT_OF_CORE (errno);
rc = out_of_core ();
goto leave;
}
p = stpcpy (p, "(3:uri");

View File

@ -38,7 +38,7 @@
/* Delete a certificate or an secret key from a key database. */
static int
delete_one (CTRL ctrl, const char *username)
delete_one (ctrl_t ctrl, const char *username)
{
int rc = 0;
KEYDB_SEARCH_DESC desc;
@ -148,7 +148,7 @@ delete_one (CTRL ctrl, const char *username)
/* Delete the certificates specified by NAMES. */
int
gpgsm_delete (CTRL ctrl, STRLIST names)
gpgsm_delete (ctrl_t ctrl, STRLIST names)
{
int rc;

View File

@ -217,7 +217,7 @@ encrypt_dek (const DEK dek, ksba_cert_t cert, unsigned char **encval)
buf = xtrymalloc (len);
if (!buf)
{
gpg_error_t tmperr = OUT_OF_CORE (errno);
gpg_error_t tmperr = out_of_core ();
gcry_sexp_release (s_ciph);
return tmperr;
}
@ -304,7 +304,7 @@ encrypt_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
recipients are take from the certificate given in recplist; if this
is NULL it will be encrypted for a default recipient */
int
gpgsm_encrypt (CTRL ctrl, CERTLIST recplist, int data_fd, FILE *out_fp)
gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int data_fd, FILE *out_fp)
{
int rc = 0;
Base64Context b64writer = NULL;
@ -318,7 +318,7 @@ gpgsm_encrypt (CTRL ctrl, CERTLIST recplist, int data_fd, FILE *out_fp)
DEK dek = NULL;
int recpno;
FILE *data_fp = NULL;
CERTLIST cl;
certlist_t cl;
memset (&encparm, 0, sizeof encparm);
@ -402,7 +402,7 @@ gpgsm_encrypt (CTRL ctrl, CERTLIST recplist, int data_fd, FILE *out_fp)
/* Create a session key */
dek = xtrycalloc_secure (1, sizeof *dek);
if (!dek)
rc = OUT_OF_CORE (errno);
rc = out_of_core ();
else
{
dek->algoid = opt.def_cipher_algoid;
@ -430,7 +430,7 @@ gpgsm_encrypt (CTRL ctrl, CERTLIST recplist, int data_fd, FILE *out_fp)
encparm.buffer = xtrymalloc (encparm.bufsize);
if (!encparm.buffer)
{
rc = OUT_OF_CORE (errno);
rc = out_of_core ();
goto leave;
}

View File

@ -129,7 +129,7 @@ insert_duptable (duptable_t *table, unsigned char *fpr, int *exists)
/* Export all certificates or just those given in NAMES. */
void
gpgsm_export (CTRL ctrl, STRLIST names, FILE *fp)
gpgsm_export (ctrl_t ctrl, STRLIST names, FILE *fp)
{
KEYDB_HANDLE hd = NULL;
KEYDB_SEARCH_DESC *desc = NULL;
@ -170,7 +170,7 @@ gpgsm_export (CTRL ctrl, STRLIST names, FILE *fp)
if (!ndesc)
{
log_error ("allocating memory for export failed: %s\n",
gpg_strerror (OUT_OF_CORE (errno)));
gpg_strerror (out_of_core ()));
goto leave;
}
@ -349,7 +349,7 @@ gpgsm_p12_export (ctrl_t ctrl, const char *name, FILE *fp)
if (!desc)
{
log_error ("allocating memory for export failed: %s\n",
gpg_strerror (OUT_OF_CORE (errno)));
gpg_strerror (out_of_core ()));
goto leave;
}

View File

@ -736,8 +736,8 @@ main ( int argc, char **argv)
char *def_digest_string = NULL;
enum cmd_and_opt_values cmd = 0;
struct server_control_s ctrl;
CERTLIST recplist = NULL;
CERTLIST signerlist = NULL;
certlist_t recplist = NULL;
certlist_t signerlist = NULL;
int do_not_setup_keys = 0;
@ -830,6 +830,7 @@ main ( int argc, char **argv)
assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
assuan_set_assuan_log_stream (log_get_stream ());
assuan_set_assuan_log_prefix (log_get_prefix (NULL));
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
keybox_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);

View File

@ -27,20 +27,17 @@
#endif
#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GPGSM
#include <gpg-error.h>
#define map_assuan_err(a) \
map_assuan_err_with_source (GPG_ERR_SOURCE_DEFAULT, (a))
#include <ksba.h>
#include "../common/util.h"
#include "../common/errors.h"
#define OUT_OF_CORE(a) (gpg_error (gpg_err_code_from_errno ((a))))
#define MAX_DIGEST_LEN 24
/* A large struct named "opt" to keep global flags */
struct {
/* A large struct named "opt" to keep global flags. */
struct
{
unsigned int debug; /* debug flags (DBG_foo_VALUE) */
int verbose; /* verbosity level */
int quiet; /* be as quiet as possible */
@ -119,6 +116,7 @@ struct {
} opt;
/* Debug values and macros. */
#define DBG_X509_VALUE 1 /* debug x.509 data reading/writing */
#define DBG_MPI_VALUE 2 /* debug mpi details */
#define DBG_CRYPTO_VALUE 4 /* debug low level crypto */
@ -135,11 +133,14 @@ struct {
#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
#define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE)
/* Forward declaration for an object defined in server.c */
struct server_local_s;
/* Note that the default values for this are set by
gpgsm_init_default_ctrl() */
struct server_control_s {
/* Session control object. This object is passed down to most
functions. Note that the default values for it are set by
gpgsm_init_default_ctrl(). */
struct server_control_s
{
int no_server; /* We are not running under server control */
int status_fd; /* Only for non-server mode */
struct server_local_s *server_local;
@ -161,20 +162,21 @@ struct server_control_s {
signer) */
int use_ocsp; /* Set to true if OCSP should be used. */
};
typedef struct server_control_s *CTRL;
typedef struct server_control_s *ctrl_t;
/* data structure used in base64.c */
/* Data structure used in base64.c. */
typedef struct base64_context_s *Base64Context;
struct certlist_s {
/* An object to keep a list of certificates. */
struct certlist_s
{
struct certlist_s *next;
ksba_cert_t cert;
int is_encrypt_to; /* True if the certificate has been set through
the --encrypto-to option. */
};
typedef struct certlist_s *CERTLIST;
typedef struct certlist_s *certlist_t;
/*-- gpgsm.c --*/
@ -286,11 +288,11 @@ int gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, FILE *out_fp);
/*-- sign.c --*/
int gpgsm_get_default_cert (ctrl_t ctrl, ksba_cert_t *r_cert);
int gpgsm_sign (ctrl_t ctrl, CERTLIST signerlist,
int gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
int data_fd, int detached, FILE *out_fp);
/*-- encrypt.c --*/
int gpgsm_encrypt (ctrl_t ctrl, CERTLIST recplist, int in_fd, FILE *out_fp);
int gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int in_fd, FILE *out_fp);
/*-- decrypt.c --*/
int gpgsm_decrypt (ctrl_t ctrl, int in_fd, FILE *out_fp);

View File

@ -53,7 +53,7 @@ static gpg_error_t parse_p12 (ctrl_t ctrl, ksba_reader_t reader, FILE **retfp,
static void
print_imported_status (CTRL ctrl, ksba_cert_t cert, int new_cert)
print_imported_status (ctrl_t ctrl, ksba_cert_t cert, int new_cert)
{
char *fpr;
@ -76,7 +76,7 @@ print_imported_status (CTRL ctrl, ksba_cert_t cert, int new_cert)
4 := "Error storing certificate".
*/
static void
print_import_problem (CTRL ctrl, ksba_cert_t cert, int reason)
print_import_problem (ctrl_t ctrl, ksba_cert_t cert, int reason)
{
char *fpr = NULL;
char buf[25];
@ -101,7 +101,7 @@ print_import_problem (CTRL ctrl, ksba_cert_t cert, int reason)
void
print_imported_summary (CTRL ctrl, struct stats_s *stats)
print_imported_summary (ctrl_t ctrl, struct stats_s *stats)
{
char buf[14*25];
@ -147,7 +147,7 @@ print_imported_summary (CTRL ctrl, struct stats_s *stats)
static void
check_and_store (CTRL ctrl, struct stats_s *stats, ksba_cert_t cert, int depth)
check_and_store (ctrl_t ctrl, struct stats_s *stats, ksba_cert_t cert, int depth)
{
int rc;
@ -245,7 +245,7 @@ check_and_store (CTRL ctrl, struct stats_s *stats, ksba_cert_t cert, int depth)
static int
import_one (CTRL ctrl, struct stats_s *stats, int in_fd)
import_one (ctrl_t ctrl, struct stats_s *stats, int in_fd)
{
int rc;
Base64Context b64reader = NULL;
@ -406,7 +406,7 @@ import_one (CTRL ctrl, struct stats_s *stats, int in_fd)
int
gpgsm_import (CTRL ctrl, int in_fd)
gpgsm_import (ctrl_t ctrl, int in_fd)
{
int rc;
struct stats_s stats;
@ -424,7 +424,7 @@ gpgsm_import (CTRL ctrl, int in_fd)
int
gpgsm_import_files (CTRL ctrl, int nfiles, char **files,
gpgsm_import_files (ctrl_t ctrl, int nfiles, char **files,
int (*of)(const char *fname))
{
int rc = 0;

View File

@ -1445,7 +1445,7 @@ keydb_clear_some_cert_flags (ctrl_t ctrl, STRLIST names)
if (!ndesc)
{
log_error ("allocating memory failed: %s\n",
gpg_strerror (OUT_OF_CORE (errno)));
gpg_strerror (out_of_core ()));
goto leave;
}

View File

@ -1327,7 +1327,7 @@ list_external_cb (void *cb_value, ksba_cert_t cert)
make sense here because it would be unwise to list external secret
keys */
static gpg_error_t
list_external_keys (CTRL ctrl, STRLIST names, FILE *fp, int raw_mode)
list_external_keys (ctrl_t ctrl, STRLIST names, FILE *fp, int raw_mode)
{
int rc;
struct list_external_parm_s parm;
@ -1357,7 +1357,7 @@ list_external_keys (CTRL ctrl, STRLIST names, FILE *fp, int raw_mode)
Bit 8: Do a raw format dump.
*/
gpg_error_t
gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp, unsigned int mode)
gpgsm_list_keys (ctrl_t ctrl, STRLIST names, FILE *fp, unsigned int mode)
{
gpg_error_t err = 0;

View File

@ -32,7 +32,7 @@
#include "gpgsm.h"
#define set_error(e,t) assuan_set_error (ctx, ASSUAN_ ## e, (t))
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
/* The filepointer for status message used in non-server mode */
@ -88,7 +88,7 @@ has_option (const char *line, const char *name)
static void
close_message_fd (CTRL ctrl)
close_message_fd (ctrl_t ctrl)
{
if (ctrl->server_local->message_fd != -1)
{
@ -99,24 +99,24 @@ close_message_fd (CTRL ctrl)
static int
option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
option_handler (assuan_context_t ctx, const char *key, const char *value)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
if (!strcmp (key, "include-certs"))
{
int i = *value? atoi (value) : -1;
if (ctrl->include_certs < -2)
return ASSUAN_Parameter_Error;
return gpg_error (GPG_ERR_ASS_PARAMETER);
ctrl->include_certs = i;
}
else if (!strcmp (key, "display"))
else if (!strcmp (key, "display"))
{
if (opt.display)
free (opt.display);
opt.display = strdup (value);
if (!opt.display)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "ttyname"))
{
@ -124,7 +124,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (opt.ttyname);
opt.ttyname = strdup (value);
if (!opt.ttyname)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "ttytype"))
{
@ -132,7 +132,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (opt.ttytype);
opt.ttytype = strdup (value);
if (!opt.ttytype)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "lc-ctype"))
{
@ -140,7 +140,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (opt.lc_ctype);
opt.lc_ctype = strdup (value);
if (!opt.lc_ctype)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "lc-messages"))
{
@ -148,7 +148,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
free (opt.lc_messages);
opt.lc_messages = strdup (value);
if (!opt.lc_messages)
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
else if (!strcmp (key, "list-mode"))
{
@ -169,7 +169,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
ctrl->server_local->list_external = 1;
}
else
return ASSUAN_Parameter_Error;
return gpg_error (GPG_ERR_ASS_PARAMETER);
}
else if (!strcmp (key, "with-validation"))
{
@ -177,7 +177,7 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
ctrl->with_validation = i;
}
else
return ASSUAN_Invalid_Option;
return gpg_error (GPG_ERR_UNKNOWN_OPTION);
return 0;
}
@ -186,9 +186,9 @@ option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
static void
reset_notify (ASSUAN_CONTEXT ctx)
reset_notify (assuan_context_t ctx)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
gpgsm_release_certlist (ctrl->server_local->recplist);
gpgsm_release_certlist (ctrl->server_local->signerlist);
@ -201,9 +201,9 @@ reset_notify (ASSUAN_CONTEXT ctx)
static void
input_notify (ASSUAN_CONTEXT ctx, const char *line)
input_notify (assuan_context_t ctx, const char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
ctrl->autodetect_encoding = 0;
ctrl->is_pem = 0;
@ -219,9 +219,9 @@ input_notify (ASSUAN_CONTEXT ctx, const char *line)
}
static void
output_notify (ASSUAN_CONTEXT ctx, const char *line)
output_notify (assuan_context_t ctx, const char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
ctrl->create_pem = 0;
ctrl->create_base64 = 0;
@ -245,9 +245,9 @@ output_notify (ASSUAN_CONTEXT ctx, const char *line)
client has to take care of this. All RECIPIENT commands are
cumulative until a RESET or an successful ENCRYPT command. */
static int
cmd_recipient (ASSUAN_CONTEXT ctx, char *line)
cmd_recipient (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
rc = gpgsm_add_to_certlist (ctrl, line, 0, &ctrl->server_local->recplist, 0);
@ -268,7 +268,7 @@ cmd_recipient (ASSUAN_CONTEXT ctx, char *line)
line, NULL);
}
return map_to_assuan_status (rc);
return rc;
}
/* SIGNER <userID>
@ -288,9 +288,9 @@ cmd_recipient (ASSUAN_CONTEXT ctx, char *line)
Note that this command returns an INV_RECP status which is a bit
strange, but they are very similar. */
static int
cmd_signer (ASSUAN_CONTEXT ctx, char *line)
cmd_signer (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
rc = gpgsm_add_to_certlist (ctrl, line, 1,
@ -312,7 +312,7 @@ cmd_signer (ASSUAN_CONTEXT ctx, char *line)
"0",
line, NULL);
}
return map_to_assuan_status (rc);
return rc;
}
@ -330,9 +330,9 @@ cmd_signer (ASSUAN_CONTEXT ctx, char *line)
have been done while setting the recipients. The input and output
pipes are closed. */
static int
cmd_encrypt (ASSUAN_CONTEXT ctx, char *line)
cmd_encrypt (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
certlist_t cl;
int inp_fd, out_fd;
FILE *out_fp;
@ -340,14 +340,14 @@ cmd_encrypt (ASSUAN_CONTEXT ctx, char *line)
inp_fd = assuan_get_input_fd (ctx);
if (inp_fd == -1)
return set_error (No_Input, NULL);
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
out_fd = assuan_get_output_fd (ctx);
if (out_fd == -1)
return set_error (No_Output, NULL);
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
out_fp = fdopen ( dup(out_fd), "w");
if (!out_fp)
return set_error (General_Error, "fdopen() failed");
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
/* Now add all encrypt-to marked recipients from the default
list. */
@ -371,7 +371,7 @@ cmd_encrypt (ASSUAN_CONTEXT ctx, char *line)
close_message_fd (ctrl);
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return map_to_assuan_status (rc);
return rc;
}
/* DECRYPT
@ -382,23 +382,23 @@ cmd_encrypt (ASSUAN_CONTEXT ctx, char *line)
no need to ask the client for a protecting passphrase - GpgAgent
does take care of this by requesting this from the user. */
static int
cmd_decrypt (ASSUAN_CONTEXT ctx, char *line)
cmd_decrypt (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int inp_fd, out_fd;
FILE *out_fp;
int rc;
inp_fd = assuan_get_input_fd (ctx);
if (inp_fd == -1)
return set_error (No_Input, NULL);
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
out_fd = assuan_get_output_fd (ctx);
if (out_fd == -1)
return set_error (No_Output, NULL);
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
out_fp = fdopen ( dup(out_fd), "w");
if (!out_fp)
return set_error (General_Error, "fdopen() failed");
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
rc = gpgsm_decrypt (ctrl, inp_fd, out_fp);
fclose (out_fp);
@ -407,7 +407,7 @@ cmd_decrypt (ASSUAN_CONTEXT ctx, char *line)
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return map_to_assuan_status (rc);
return rc;
}
@ -421,22 +421,22 @@ cmd_decrypt (ASSUAN_CONTEXT ctx, char *line)
the signed material and the client must provide it.
*/
static int
cmd_verify (ASSUAN_CONTEXT ctx, char *line)
cmd_verify (assuan_context_t ctx, char *line)
{
int rc;
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int fd = assuan_get_input_fd (ctx);
int out_fd = assuan_get_output_fd (ctx);
FILE *out_fp = NULL;
if (fd == -1)
return set_error (No_Input, NULL);
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
if (out_fd != -1)
{
out_fp = fdopen ( dup(out_fd), "w");
if (!out_fp)
return set_error (General_Error, "fdopen() failed");
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
}
rc = gpgsm_verify (assuan_get_pointer (ctx), fd,
@ -449,7 +449,7 @@ cmd_verify (ASSUAN_CONTEXT ctx, char *line)
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return map_to_assuan_status (rc);
return rc;
}
@ -459,9 +459,9 @@ cmd_verify (ASSUAN_CONTEXT ctx, char *line)
set by OUTPUT. With "--detached" specified, a detached signature is
created (surprise). */
static int
cmd_sign (ASSUAN_CONTEXT ctx, char *line)
cmd_sign (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int inp_fd, out_fd;
FILE *out_fp;
int detached;
@ -469,16 +469,16 @@ cmd_sign (ASSUAN_CONTEXT ctx, char *line)
inp_fd = assuan_get_input_fd (ctx);
if (inp_fd == -1)
return set_error (No_Input, NULL);
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
out_fd = assuan_get_output_fd (ctx);
if (out_fd == -1)
return set_error (No_Output, NULL);
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
detached = has_option (line, "--detached");
out_fp = fdopen ( dup(out_fd), "w");
if (!out_fp)
return set_error (General_Error, "fdopen() failed");
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
rc = gpgsm_sign (assuan_get_pointer (ctx), ctrl->server_local->signerlist,
inp_fd, detached, out_fp);
@ -489,7 +489,7 @@ cmd_sign (ASSUAN_CONTEXT ctx, char *line)
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return map_to_assuan_status (rc);
return rc;
}
@ -500,14 +500,14 @@ cmd_sign (ASSUAN_CONTEXT ctx, char *line)
the certificate but not of the entire chain. It is possible to
import expired certificates. */
static int
cmd_import (ASSUAN_CONTEXT ctx, char *line)
cmd_import (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
int fd = assuan_get_input_fd (ctx);
if (fd == -1)
return set_error (No_Input, NULL);
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
rc = gpgsm_import (assuan_get_pointer (ctx), fd);
@ -516,21 +516,21 @@ cmd_import (ASSUAN_CONTEXT ctx, char *line)
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return map_to_assuan_status (rc);
return rc;
}
static int
cmd_export (ASSUAN_CONTEXT ctx, char *line)
cmd_export (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int fd = assuan_get_output_fd (ctx);
FILE *out_fp;
char *p;
STRLIST list, sl;
if (fd == -1)
return set_error (No_Output, NULL);
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
/* break the line down into an STRLIST */
list = NULL;
@ -546,7 +546,7 @@ cmd_export (ASSUAN_CONTEXT ctx, char *line)
if (!sl)
{
free_strlist (list);
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
sl->flags = 0;
strcpy_escaped_plus (sl->d, line);
@ -559,7 +559,7 @@ cmd_export (ASSUAN_CONTEXT ctx, char *line)
if (!out_fp)
{
free_strlist (list);
return set_error (General_Error, "fdopen() failed");
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
}
gpgsm_export (ctrl, list, out_fp);
@ -574,9 +574,9 @@ cmd_export (ASSUAN_CONTEXT ctx, char *line)
static int
cmd_delkeys (ASSUAN_CONTEXT ctx, char *line)
cmd_delkeys (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
char *p;
STRLIST list, sl;
int rc;
@ -595,7 +595,7 @@ cmd_delkeys (ASSUAN_CONTEXT ctx, char *line)
if (!sl)
{
free_strlist (list);
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
sl->flags = 0;
strcpy_escaped_plus (sl->d, line);
@ -612,7 +612,7 @@ cmd_delkeys (ASSUAN_CONTEXT ctx, char *line)
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return map_to_assuan_status (rc);
return rc;
}
@ -622,22 +622,22 @@ cmd_delkeys (ASSUAN_CONTEXT ctx, char *line)
Set the file descriptor to read a message which is used with
detached signatures */
static int
cmd_message (ASSUAN_CONTEXT ctx, char *line)
cmd_message (assuan_context_t ctx, char *line)
{
char *endp;
int fd;
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
if (strncmp (line, "FD=", 3))
return set_error (Syntax_Error, "FD=<n> expected");
return set_error (GPG_ERR_ASS_SYNTAX, "FD=<n> expected");
line += 3;
if (!digitp (line))
return set_error (Syntax_Error, "number required");
return set_error (GPG_ERR_ASS_SYNTAX, "number required");
fd = strtoul (line, &endp, 10);
if (*endp)
return set_error (Syntax_Error, "garbage found");
return set_error (GPG_ERR_ASS_SYNTAX, "garbage found");
if (fd == -1)
return set_error (No_Input, NULL);
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
ctrl->server_local->message_fd = fd;
return 0;
@ -645,9 +645,9 @@ cmd_message (ASSUAN_CONTEXT ctx, char *line)
static int
do_listkeys (ASSUAN_CONTEXT ctx, char *line, int mode)
do_listkeys (assuan_context_t ctx, char *line, int mode)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
FILE *fp = assuan_get_data_fp (ctx);
char *p;
STRLIST list, sl;
@ -655,7 +655,7 @@ do_listkeys (ASSUAN_CONTEXT ctx, char *line, int mode)
gpg_error_t err;
if (!fp)
return set_error (General_Error, "no data stream");
return set_error (GPG_ERR_ASS_GENERAL, "no data stream");
/* break the line down into an STRLIST */
list = NULL;
@ -671,7 +671,7 @@ do_listkeys (ASSUAN_CONTEXT ctx, char *line, int mode)
if (!sl)
{
free_strlist (list);
return ASSUAN_Out_Of_Core;
return out_of_core ();
}
sl->flags = 0;
strcpy_escaped_plus (sl->d, line);
@ -688,17 +688,17 @@ do_listkeys (ASSUAN_CONTEXT ctx, char *line, int mode)
listmode |= (1<<7);
err = gpgsm_list_keys (assuan_get_pointer (ctx), list, fp, listmode);
free_strlist (list);
return map_to_assuan_status (err);
return err;
}
static int
cmd_listkeys (ASSUAN_CONTEXT ctx, char *line)
cmd_listkeys (assuan_context_t ctx, char *line)
{
return do_listkeys (ctx, line, 3);
}
static int
cmd_listsecretkeys (ASSUAN_CONTEXT ctx, char *line)
cmd_listsecretkeys (assuan_context_t ctx, char *line)
{
return do_listkeys (ctx, line, 2);
}
@ -710,23 +710,23 @@ cmd_listsecretkeys (ASSUAN_CONTEXT ctx, char *line)
certificate request to the output.
*/
static int
cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
cmd_genkey (assuan_context_t ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl_t ctrl = assuan_get_pointer (ctx);
int inp_fd, out_fd;
FILE *out_fp;
int rc;
inp_fd = assuan_get_input_fd (ctx);
if (inp_fd == -1)
return set_error (No_Input, NULL);
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
out_fd = assuan_get_output_fd (ctx);
if (out_fd == -1)
return set_error (No_Output, NULL);
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
out_fp = fdopen ( dup(out_fd), "w");
if (!out_fp)
return set_error (General_Error, "fdopen() failed");
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
rc = gpgsm_genkey (ctrl, inp_fd, out_fp);
fclose (out_fp);
@ -734,7 +734,7 @@ cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return map_to_assuan_status (rc);
return rc;
}
@ -743,11 +743,11 @@ cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
/* Tell the assuan library about our commands */
static int
register_commands (ASSUAN_CONTEXT ctx)
register_commands (assuan_context_t ctx)
{
static struct {
const char *name;
int (*handler)(ASSUAN_CONTEXT, char *line);
int (*handler)(assuan_context_t, char *line);
} table[] = {
{ "RECIPIENT", cmd_recipient },
{ "SIGNER", cmd_signer },
@ -785,7 +785,7 @@ gpgsm_server (certlist_t default_recplist)
{
int rc;
int filedes[2];
ASSUAN_CONTEXT ctx;
assuan_context_t ctx;
struct server_control_s ctrl;
static const char hello[] = ("GNU Privacy Guard's S/M server "
VERSION " ready");
@ -802,14 +802,14 @@ gpgsm_server (certlist_t default_recplist)
if (rc)
{
log_error ("failed to initialize the server: %s\n",
assuan_strerror(rc));
gpg_strerror (rc));
gpgsm_exit (2);
}
rc = register_commands (ctx);
if (rc)
{
log_error ("failed to the register commands with Assuan: %s\n",
assuan_strerror(rc));
gpg_strerror(rc));
gpgsm_exit (2);
}
if (opt.verbose || opt.debug)
@ -862,14 +862,14 @@ gpgsm_server (certlist_t default_recplist)
}
else if (rc)
{
log_info ("Assuan accept problem: %s\n", assuan_strerror (rc));
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
break;
}
rc = assuan_process (ctx);
if (rc)
{
log_info ("Assuan processing failed: %s\n", assuan_strerror (rc));
log_info ("Assuan processing failed: %s\n", gpg_strerror (rc));
continue;
}
}
@ -966,7 +966,7 @@ get_status_string ( int no )
gpg_error_t
gpgsm_status2 (CTRL ctrl, int no, ...)
gpgsm_status2 (ctrl_t ctrl, int no, ...)
{
gpg_error_t err = 0;
va_list arg_ptr;
@ -1015,7 +1015,7 @@ gpgsm_status2 (CTRL ctrl, int no, ...)
}
else
{
ASSUAN_CONTEXT ctx = ctrl->server_local->assuan_ctx;
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
char buf[950], *p;
size_t n;
@ -1032,8 +1032,7 @@ gpgsm_status2 (CTRL ctrl, int no, ...)
*p++ = *text++;
}
*p = 0;
err = map_assuan_err (assuan_write_status (ctx,
get_status_string (no), buf));
err = assuan_write_status (ctx, get_status_string (no), buf);
}
va_end (arg_ptr);
@ -1041,13 +1040,13 @@ gpgsm_status2 (CTRL ctrl, int no, ...)
}
gpg_error_t
gpgsm_status (CTRL ctrl, int no, const char *text)
gpgsm_status (ctrl_t ctrl, int no, const char *text)
{
return gpgsm_status2 (ctrl, no, text, NULL);
}
gpg_error_t
gpgsm_status_with_err_code (CTRL ctrl, int no, const char *text,
gpgsm_status_with_err_code (ctrl_t ctrl, int no, const char *text,
gpg_err_code_t ec)
{
char buf[30];

View File

@ -234,7 +234,7 @@ get_default_signer (ctrl_t ctrl)
other certificate up in the chain to the Root-CA to the CMS
object. */
static int
add_certificate_list (CTRL ctrl, ksba_cms_t cms, ksba_cert_t cert)
add_certificate_list (ctrl_t ctrl, ksba_cms_t cms, ksba_cert_t cert)
{
gpg_error_t err;
int rc = 0;
@ -301,7 +301,7 @@ add_certificate_list (CTRL ctrl, ksba_cms_t cms, ksba_cert_t cert)
keys used to sign are taken from SIGNERLIST or the default one will
be used if the value of this argument is NULL. */
int
gpgsm_sign (CTRL ctrl, CERTLIST signerlist,
gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
int data_fd, int detached, FILE *out_fp)
{
int i, rc;
@ -316,7 +316,7 @@ gpgsm_sign (CTRL ctrl, CERTLIST signerlist,
const char *algoid;
int algo;
ksba_isotime_t signed_at;
CERTLIST cl;
certlist_t cl;
int release_signerlist = 0;
kh = keydb_new (0);
@ -387,7 +387,7 @@ gpgsm_sign (CTRL ctrl, CERTLIST signerlist,
signerlist = xtrycalloc (1, sizeof *signerlist);
if (!signerlist)
{
rc = OUT_OF_CORE (errno);
rc = out_of_core ();
ksba_cert_release (cert);
goto leave;
}

View File

@ -82,7 +82,7 @@ hash_data (int fd, gcry_md_hd_t md)
must be different than -1. With OUT_FP given and a non-detached
signature, the signed material is written to that stream. */
int
gpgsm_verify (CTRL ctrl, int in_fd, int data_fd, FILE *out_fp)
gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, FILE *out_fp)
{
int i, rc;
Base64Context b64reader = NULL;

View File

@ -1,3 +1,11 @@
2006-09-06 Werner Koch <wk@g10code.com>
* gpg-connect-agent.c: Switch everything to new Assuan error code
style.
* no-libgcrypt.c (out_of_core): Reanmed to ...
(out_of_memory): .. this to avoid name clash with util.h.
2006-08-21 Werner Koch <wk@g10code.com>
* gpgsplit.c: New. Taken from 1.4. Adjusted to GnuPG2.

View File

@ -224,6 +224,7 @@ main (int argc, char **argv)
set_strusage (my_strusage);
log_set_prefix ("gpg-connect-agent", 1);
assuan_set_assuan_err_source (0);
i18n_init();
@ -259,7 +260,7 @@ main (int argc, char **argv)
if (rc)
{
log_error ("can't connect to socket `%s': %s\n",
opt.raw_socket, assuan_strerror (rc));
opt.raw_socket, gpg_strerror (rc));
exit (1);
}
@ -347,7 +348,7 @@ main (int argc, char **argv)
rc = assuan_write_line (ctx, line);
if (rc)
{
log_info (_("sending line failed: %s\n"), assuan_strerror (rc) );
log_info (_("sending line failed: %s\n"), gpg_strerror (rc) );
continue;
}
if (*line == '#' || !*line)
@ -355,7 +356,7 @@ main (int argc, char **argv)
rc = read_and_print_response (ctx);
if (rc)
log_info (_("receiving line failed: %s\n"), assuan_strerror (rc) );
log_info (_("receiving line failed: %s\n"), gpg_strerror (rc) );
}
if (opt.verbose)
@ -431,7 +432,7 @@ handle_inquire (assuan_context_t ctx, char *line)
rc = assuan_send_data (ctx, buffer, n);
if (rc)
{
log_error ("sending data back failed: %s\n", assuan_strerror (rc) );
log_error ("sending data back failed: %s\n", gpg_strerror (rc) );
break;
}
}
@ -440,7 +441,7 @@ handle_inquire (assuan_context_t ctx, char *line)
rc = assuan_send_data (ctx, NULL, 0);
if (rc)
log_error ("sending data back failed: %s\n", assuan_strerror (rc) );
log_error ("sending data back failed: %s\n", gpg_strerror (rc) );
if (d->is_prog)
{
@ -556,7 +557,7 @@ read_and_print_response (assuan_context_t ctx)
/* Received from server, thus more responses are expected. */
}
else
return ASSUAN_Invalid_Response;
return gpg_error (GPG_ERR_ASS_INV_RESPONSE);
}
}
@ -612,7 +613,7 @@ start_agent (void)
if (rc)
{
log_error ("can't connect to the agent: %s\n", assuan_strerror (rc));
log_error ("can't connect to the agent: %s\n", gpg_strerror (rc));
exit (1);
}
@ -623,7 +624,7 @@ start_agent (void)
if (rc)
{
log_error (_("error sending %s command: %s\n"), "RESET",
assuan_strerror (rc));
gpg_strerror (rc));
exit (1);
}

View File

@ -33,7 +33,7 @@
../jnlib/libjnlib.a . ../common/util.h defines macros to map them
to xmalloc etc. */
static void
out_of_core (void)
out_of_memory (void)
{
log_fatal (_("error allocating enough memory: %s\n"), strerror (errno));
}
@ -50,7 +50,7 @@ gcry_xmalloc (size_t n)
{
void *p = malloc (n);
if (!p)
out_of_core ();
out_of_memory ();
return p;
}
@ -72,7 +72,7 @@ gcry_xrealloc (void *a, size_t n)
{
void *p = realloc (a, n);
if (!p)
out_of_core ();
out_of_memory ();
return p;
}
@ -89,7 +89,7 @@ gcry_xcalloc (size_t n, size_t m)
{
void *p = calloc (n, m);
if (!p)
out_of_core ();
out_of_memory ();
return p;
}
@ -99,7 +99,7 @@ gcry_xstrdup (const char *string)
{
void *p = malloc (strlen (string)+1);
if (!p)
out_of_core ();
out_of_memory ();
strcpy( p, string );
return p;
}