mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-23 15:07:03 +01:00
A small step for GnuPG but a huge leap for error codes.
(Sorry, it does not build currently - I need to check it in to avoid duplicate work.)
This commit is contained in:
parent
4d3fecee56
commit
bd820bad4f
@ -1,3 +1,7 @@
|
||||
2003-06-04 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Renamed error codes from INVALID to INV and removed _ERROR suffixes.
|
||||
|
||||
2003-06-03 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Changed all error codes in all files to the new libgpg-error scheme.
|
||||
|
@ -155,7 +155,7 @@ cmd_istrusted (ASSUAN_CONTEXT ctx, char *line)
|
||||
return ASSUAN_Not_Trusted;
|
||||
else
|
||||
{
|
||||
log_error ("command is_trusted failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command is_trusted failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ cmd_listtrusted (ASSUAN_CONTEXT ctx, char *line)
|
||||
{
|
||||
int rc = agent_listtrusted (ctx);
|
||||
if (rc)
|
||||
log_error ("command listtrusted failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command listtrusted failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ cmd_marktrusted (ASSUAN_CONTEXT ctx, char *line)
|
||||
|
||||
rc = agent_marktrusted (ctrl, p, fpr, flag);
|
||||
if (rc)
|
||||
log_error ("command marktrusted failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command marktrusted failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ cmd_pksign (ASSUAN_CONTEXT ctx, char *line)
|
||||
|
||||
rc = agent_pksign (ctrl, assuan_get_data_fp (ctx), ignore_cache);
|
||||
if (rc)
|
||||
log_error ("command pksign failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command pksign failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ cmd_pkdecrypt (ASSUAN_CONTEXT ctx, char *line)
|
||||
rc = agent_pkdecrypt (ctrl, value, valuelen, assuan_get_data_fp (ctx));
|
||||
xfree (value);
|
||||
if (rc)
|
||||
log_error ("command pkdecrypt failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command pkdecrypt failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
|
||||
rc = agent_genkey (ctrl, value, valuelen, assuan_get_data_fp (ctx));
|
||||
xfree (value);
|
||||
if (rc)
|
||||
log_error ("command genkey failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command genkey failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ cmd_get_passphrase (ASSUAN_CONTEXT ctx, char *line)
|
||||
}
|
||||
|
||||
if (rc)
|
||||
log_error ("command get_passphrase failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command get_passphrase failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
@ -534,7 +534,7 @@ cmd_learn (ASSUAN_CONTEXT ctx, char *line)
|
||||
|
||||
rc = agent_handle_learn (has_option (line, "--send")? ctx : NULL);
|
||||
if (rc)
|
||||
log_error ("command learn failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command learn failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
@ -571,7 +571,7 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
|
||||
gcry_sexp_release (s_skey);
|
||||
xfree (shadow_info);
|
||||
if (rc)
|
||||
log_error ("command passwd failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("command passwd failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ agent_key_from_file (CTRL ctrl,
|
||||
}
|
||||
}
|
||||
if (rc)
|
||||
log_error ("get_shadow_info failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("get_shadow_info failed: %s\n", gpg_strerror (rc));
|
||||
}
|
||||
rc = -1; /* ugly interface: we return an error but keep a value
|
||||
in shadow_info. */
|
||||
|
@ -300,7 +300,7 @@ read_and_protect (const char *fname)
|
||||
xfree (key);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("protecting the key failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("protecting the key failed: %s\n", gpg_strerror (rc));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ read_and_unprotect (const char *fname)
|
||||
xfree (key);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("unprotecting the key failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("unprotecting the key failed: %s\n", gpg_strerror (rc));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -371,7 +371,7 @@ read_and_shadow (const char *fname)
|
||||
xfree (key);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("shadowing the key failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("shadowing the key failed: %s\n", gpg_strerror (rc));
|
||||
return;
|
||||
}
|
||||
resultlen = gcry_sexp_canon_len (result, 0, NULL,NULL);
|
||||
@ -407,7 +407,7 @@ show_shadow_info (const char *fname)
|
||||
xfree (key);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("get_shadow_info failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("get_shadow_info failed: %s\n", gpg_strerror (rc));
|
||||
return;
|
||||
}
|
||||
infolen = gcry_sexp_canon_len (info, 0, NULL,NULL);
|
||||
@ -663,7 +663,7 @@ import_p12_file (const char *fname)
|
||||
xfree (key);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("protecting the key failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("protecting the key failed: %s\n", gpg_strerror (rc));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,20 @@
|
||||
2003-06-04 Werner Koch <wk@gnupg.org>
|
||||
|
||||
|
||||
* errors.h: Removed all error codes. We keep the status codes for
|
||||
now.
|
||||
* Makefile.am: Do not create errors.c anymore; remove it from the
|
||||
sources.
|
||||
|
||||
* maperror.c: Don't include error.h. Change all error codes to
|
||||
libgpg-error style.
|
||||
(map_assuan_err): Changed to new Assuan error code convention.
|
||||
(map_to_assuan_status): Likewise.
|
||||
(map_gcry_err,map_kbx_err): Not needed. For now dummy functions.
|
||||
|
||||
* membuf.c, membuf.h: New. Code taken from ../sm/call-agent.h.
|
||||
* Makefile.am: Added above.
|
||||
|
||||
2003-04-29 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* util.h (fopencokokie): Removed prototype and struct.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Makefile for common gnupg modules
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GnuPG.
|
||||
#
|
||||
@ -29,19 +29,17 @@ AM_CPPFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS)
|
||||
|
||||
libcommon_a_SOURCES = \
|
||||
util.h i18n.h \
|
||||
errors.c errors.h \
|
||||
errors.h \
|
||||
maperror.c \
|
||||
sysutils.c sysutils.h \
|
||||
cryptmiss.c \
|
||||
gettime.c \
|
||||
membuf.c membuf.h \
|
||||
signal.c
|
||||
|
||||
|
||||
libcommon_a_LIBADD = @LIBOBJS@
|
||||
|
||||
errors.c : errors.h mkerrors mkerrtok
|
||||
$(srcdir)/mkerrors < $(srcdir)/errors.h > errors.c
|
||||
$(srcdir)/mkerrtok < $(srcdir)/errors.h >> errors.c
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
Stuff used by several modules of GnuPG. This way we can share error
|
||||
codes and serveral other things.
|
||||
|
||||
Stuff used by several modules of GnuPG.
|
||||
|
||||
These directories use it:
|
||||
|
||||
@ -10,5 +8,4 @@ agent
|
||||
|
||||
These directories don't use it:
|
||||
|
||||
assuan
|
||||
kbx
|
@ -23,91 +23,6 @@
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifndef GPG_ERR_SOURCE_DEFAULT
|
||||
/* Error numbers. Note, that they are onkly used for old code not yet
|
||||
converted to libgpg-error. */
|
||||
enum {
|
||||
GNUPG_EOF = -1,
|
||||
GNUPG_No_Error = 0,
|
||||
GNUPG_General_Error = 1,
|
||||
GNUPG_Out_Of_Core = 2,
|
||||
GNUPG_Invalid_Value = 3,
|
||||
GNUPG_IO_Error = 4,
|
||||
GNUPG_Resource_Limit = 5,
|
||||
GNUPG_Internal_Error = 6,
|
||||
GNUPG_Bad_Certificate = 7,
|
||||
GNUPG_Bad_Certificate_Chain = 8,
|
||||
GNUPG_Missing_Certificate = 9,
|
||||
GNUPG_No_Data = 10,
|
||||
GNUPG_Bad_Signature = 11,
|
||||
GNUPG_Not_Implemented = 12,
|
||||
GNUPG_Conflict = 13,
|
||||
GNUPG_Bug = 14,
|
||||
GNUPG_Read_Error = 15,
|
||||
GNUPG_Write_Error = 16,
|
||||
GNUPG_Incomplete_Line = 17,
|
||||
GNUPG_Invalid_Response = 18,
|
||||
GNUPG_No_Agent = 19,
|
||||
GNUPG_Agent_Error = 20,
|
||||
GNUPG_No_Public_Key = 21,
|
||||
GNUPG_No_Secret_Key = 22,
|
||||
GNUPG_File_Open_Error = 23,
|
||||
GNUPG_File_Create_Error = 24,
|
||||
GNUPG_File_Error = 25,
|
||||
GNUPG_Not_Supported = 26,
|
||||
GNUPG_Invalid_Data = 27,
|
||||
GNUPG_Assuan_Server_Fault = 28,
|
||||
GNUPG_Assuan_Error = 29, /* catch all assuan error */
|
||||
GNUPG_Invalid_Session_Key = 30,
|
||||
GNUPG_Invalid_Sexp = 31,
|
||||
GNUPG_Unsupported_Algorithm = 32,
|
||||
GNUPG_No_PIN_Entry = 33,
|
||||
GNUPG_PIN_Entry_Error = 34,
|
||||
GNUPG_Bad_PIN = 35,
|
||||
GNUPG_Bad_Passphrase = 36,
|
||||
GNUPG_Invalid_Name = 37,
|
||||
GNUPG_Bad_Public_Key = 38,
|
||||
GNUPG_Bad_Secret_Key = 39,
|
||||
GNUPG_Bad_Data = 40,
|
||||
GNUPG_Invalid_Parameter = 41,
|
||||
GNUPG_Tribute_to_D_A = 42,
|
||||
GNUPG_No_Dirmngr = 43,
|
||||
GNUPG_Dirmngr_Error = 44,
|
||||
GNUPG_Certificate_Revoked = 45,
|
||||
GNUPG_No_CRL_Known = 46,
|
||||
GNUPG_CRL_Too_Old = 47,
|
||||
GNUPG_Line_Too_Long = 48,
|
||||
GNUPG_Not_Trusted = 49,
|
||||
GNUPG_Canceled = 50,
|
||||
GNUPG_Bad_CA_Certificate = 51,
|
||||
GNUPG_Certificate_Expired = 52,
|
||||
GNUPG_Certificate_Too_Young = 53,
|
||||
GNUPG_Unsupported_Certificate = 54,
|
||||
GNUPG_Unknown_Sexp = 55,
|
||||
GNUPG_Unsupported_Protection = 56,
|
||||
GNUPG_Corrupted_Protection = 57,
|
||||
GNUPG_Ambiguous_Name = 58,
|
||||
GNUPG_Card_Error = 59,
|
||||
GNUPG_Card_Reset = 60,
|
||||
GNUPG_Card_Removed = 61,
|
||||
GNUPG_Invalid_Card = 62,
|
||||
GNUPG_Card_Not_Present = 63,
|
||||
GNUPG_No_PKCS15_App = 64,
|
||||
GNUPG_Not_Confirmed = 65,
|
||||
GNUPG_Configuration_Error = 66,
|
||||
GNUPG_No_Policy_Match = 67,
|
||||
GNUPG_Invalid_Index = 68,
|
||||
GNUPG_Invalid_Id = 69,
|
||||
GNUPG_No_Scdaemon = 70,
|
||||
GNUPG_Scdaemon_Error = 71,
|
||||
GNUPG_Unsupported_Protocol = 72,
|
||||
GNUPG_Bad_PIN_Method = 73,
|
||||
GNUPG_Card_Not_Initialized = 74,
|
||||
GNUPG_Unsupported_Operation = 75,
|
||||
GNUPG_Wrong_Key_Usage = 76,
|
||||
};
|
||||
#endif /* !GPG_ERR_SOURCE_DEFAULT */
|
||||
|
||||
/* Status codes - fixme: should go into another file */
|
||||
enum {
|
||||
STATUS_ENTER,
|
||||
|
@ -43,21 +43,21 @@ map_ksba_err (int err)
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case KSBA_Out_Of_Core: err = GNUPG_Out_Of_Core; break;
|
||||
case KSBA_Invalid_Value: err = GNUPG_Invalid_Value; break;
|
||||
case KSBA_Not_Implemented: err = GNUPG_Not_Implemented; break;
|
||||
case KSBA_Conflict: err = GNUPG_Conflict; break;
|
||||
case KSBA_Read_Error: err = GNUPG_Read_Error; break;
|
||||
case KSBA_Write_Error: err = GNUPG_Write_Error; break;
|
||||
case KSBA_No_Data: err = GNUPG_No_Data; break;
|
||||
case KSBA_Bug: err = GNUPG_Bug; break;
|
||||
case KSBA_Unsupported_Algorithm: err = GNUPG_Unsupported_Algorithm; break;
|
||||
case KSBA_Invalid_Index: err = GNUPG_Invalid_Index; break;
|
||||
case KSBA_Invalid_Sexp: err = GNUPG_Invalid_Sexp; break;
|
||||
case KSBA_Unknown_Sexp: err = GNUPG_Unknown_Sexp; break;
|
||||
case KSBA_Out_Of_Core: err = GPG_ERR_ENOMEM; break;
|
||||
case KSBA_Invalid_Value: err = GPG_ERR_INV_VALUE; break;
|
||||
case KSBA_Not_Implemented: err = GPG_ERR_NOT_IMPLEMENTED; break;
|
||||
case KSBA_Conflict: err = GPG_ERR_CONFLICT; break;
|
||||
case KSBA_Read_Error: err = GPG_ERR_EIO; break;
|
||||
case KSBA_Write_Error: err = GPG_ERR_EIO; break;
|
||||
case KSBA_No_Data: err = GPG_ERR_NO_DATA; break;
|
||||
case KSBA_Bug: err = GPG_ERR_BUG; break;
|
||||
case KSBA_Unsupported_Algorithm: err = GPG_ERR_UNSUPPORTED_ALGORITHM; break;
|
||||
case KSBA_Invalid_Index: err = GPG_ERR_INV_INDEX; break;
|
||||
case KSBA_Invalid_Sexp: err = GPG_ERR_INV_SEXP; break;
|
||||
case KSBA_Unknown_Sexp: err = GPG_ERR_UNKNOWN_SEXP; break;
|
||||
|
||||
default:
|
||||
err = seterr (General_Error);
|
||||
err = GPG_ERR_GENERAL;
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
@ -67,200 +67,80 @@ map_ksba_err (int err)
|
||||
int
|
||||
map_gcry_err (int err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case GCRYERR_EOF:
|
||||
case -1:
|
||||
err = -1;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case GCRYERR_WRONG_PK_ALGO:
|
||||
case GCRYERR_INV_PK_ALGO:
|
||||
case GCRYERR_INV_MD_ALGO:
|
||||
case GCRYERR_INV_CIPHER_ALGO:
|
||||
err = GNUPG_Unsupported_Algorithm;
|
||||
break;
|
||||
case GCRYERR_INV_KEYLEN:
|
||||
case GCRYERR_WEAK_KEY:
|
||||
case GCRYERR_BAD_PUBLIC_KEY: err = GNUPG_Bad_Public_Key; break;
|
||||
case GCRYERR_BAD_SECRET_KEY: err = GNUPG_Bad_Secret_Key; break;
|
||||
case GCRYERR_BAD_SIGNATURE: err = GNUPG_Bad_Signature; break;
|
||||
|
||||
case GCRYERR_BAD_MPI:
|
||||
err = GNUPG_Bad_Data;
|
||||
break;
|
||||
|
||||
case GCRYERR_INV_ARG:
|
||||
case GCRYERR_INV_OP:
|
||||
case GCRYERR_INTERNAL:
|
||||
case GCRYERR_INV_CIPHER_MODE:
|
||||
err = GNUPG_Invalid_Value;
|
||||
break;
|
||||
|
||||
case GCRYERR_SELFTEST:
|
||||
err = GNUPG_Bug;
|
||||
break;
|
||||
|
||||
case GCRYERR_SEXP_INV_LEN_SPEC :
|
||||
case GCRYERR_SEXP_STRING_TOO_LONG :
|
||||
case GCRYERR_SEXP_UNMATCHED_PAREN :
|
||||
case GCRYERR_SEXP_NOT_CANONICAL :
|
||||
case GCRYERR_SEXP_BAD_CHARACTER :
|
||||
case GCRYERR_SEXP_BAD_QUOTATION :
|
||||
case GCRYERR_SEXP_ZERO_PREFIX :
|
||||
case GCRYERR_SEXP_NESTED_DH :
|
||||
case GCRYERR_SEXP_UNMATCHED_DH :
|
||||
case GCRYERR_SEXP_UNEXPECTED_PUNC :
|
||||
case GCRYERR_SEXP_BAD_HEX_CHAR :
|
||||
case GCRYERR_SEXP_ODD_HEX_NUMBERS :
|
||||
case GCRYERR_SEXP_BAD_OCT_CHAR :
|
||||
err = GNUPG_Invalid_Sexp;
|
||||
break;
|
||||
|
||||
case GCRYERR_NO_MEM: err = GNUPG_Out_Of_Core; break;
|
||||
|
||||
case GCRYERR_NOT_IMPL: err = GNUPG_Not_Implemented; break;
|
||||
case GCRYERR_CONFLICT: err = GNUPG_Conflict; break;
|
||||
|
||||
case GCRYERR_INV_OBJ: /* an object is not valid */
|
||||
case GCRYERR_TOO_SHORT: /* provided buffer too short */
|
||||
case GCRYERR_TOO_LARGE: /* object is too large */
|
||||
case GCRYERR_NO_OBJ: /* Missing item in an object */
|
||||
default:
|
||||
err = seterr (General_Error);
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
map_kbx_err (int err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case -1:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
default:
|
||||
err = seterr (General_Error);
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
/* 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
|
||||
simple: All errors with a gpg_err_source of UNKNOWN are genuine
|
||||
Assuan codes all others are passed verbatim through. */
|
||||
gpg_error_t
|
||||
map_assuan_err (int err)
|
||||
{
|
||||
gpg_err_code_t ec;
|
||||
|
||||
if (gpg_err_source (err))
|
||||
return err;
|
||||
|
||||
switch (err)
|
||||
{
|
||||
case -1:
|
||||
case 0:
|
||||
break;
|
||||
case -1: ec = GPG_ERR_EOF; break;
|
||||
case 0: ec = 0; break;
|
||||
|
||||
case ASSUAN_Canceled: err = GNUPG_Canceled; break;
|
||||
case ASSUAN_Invalid_Index: err = GNUPG_Invalid_Index; break;
|
||||
case ASSUAN_Canceled: ec = GPG_ERR_CANCELED; break;
|
||||
case ASSUAN_Invalid_Index: ec = GPG_ERR_INV_INDEX; break;
|
||||
|
||||
case ASSUAN_Not_Implemented: err = GNUPG_Not_Implemented; break;
|
||||
case ASSUAN_Server_Fault: err = GNUPG_Assuan_Server_Fault; break;
|
||||
case ASSUAN_No_Public_Key: err = GNUPG_No_Public_Key; break;
|
||||
case ASSUAN_No_Secret_Key: err = GNUPG_No_Secret_Key; break;
|
||||
case ASSUAN_Not_Implemented: ec = GPG_ERR_NOT_IMPLEMENTED; break;
|
||||
case ASSUAN_Server_Fault: ec = GPG_ERR_ASSUAN_SERVER_FAULT; break;
|
||||
case ASSUAN_No_Public_Key: ec = GPG_ERR_NO_PUBKEY; break;
|
||||
case ASSUAN_No_Secret_Key: ec = GPG_ERR_NO_SECKEY; break;
|
||||
|
||||
case ASSUAN_Cert_Revoked: err = GNUPG_Certificate_Revoked; break;
|
||||
case ASSUAN_No_CRL_For_Cert: err = GNUPG_No_CRL_Known; break;
|
||||
case ASSUAN_CRL_Too_Old: err = GNUPG_CRL_Too_Old; break;
|
||||
case ASSUAN_Cert_Revoked: ec = GPG_ERR_CERT_REVOKED; break;
|
||||
case ASSUAN_No_CRL_For_Cert: ec = GPG_ERR_NO_CRL_KNOWN; break;
|
||||
case ASSUAN_CRL_Too_Old: ec = GPG_ERR_CRL_TOO_OLD; break;
|
||||
|
||||
case ASSUAN_Not_Trusted: err = GNUPG_Not_Trusted; break;
|
||||
case ASSUAN_Not_Trusted: ec = GPG_ERR_NOT_TRUSTED; break;
|
||||
|
||||
case ASSUAN_Card_Error: err = GNUPG_Card_Error; break;
|
||||
case ASSUAN_Invalid_Card: err = GNUPG_Invalid_Card; break;
|
||||
case ASSUAN_No_PKCS15_App: err = GNUPG_No_PKCS15_App; break;
|
||||
case ASSUAN_Card_Not_Present: err= GNUPG_Card_Not_Present; break;
|
||||
case ASSUAN_Not_Confirmed: err = GNUPG_Not_Confirmed; break;
|
||||
case ASSUAN_Invalid_Id: err = GNUPG_Invalid_Id; break;
|
||||
case ASSUAN_Card_Error: ec = GPG_ERR_CARD; break;
|
||||
case ASSUAN_Invalid_Card: ec = GPG_ERR_INV_CARD; break;
|
||||
case ASSUAN_No_PKCS15_App: ec = GPG_ERR_NO_PKCS15_APP; break;
|
||||
case ASSUAN_Card_Not_Present: ec= GPG_ERR_CARD_NOT_PRESENT; break;
|
||||
case ASSUAN_Not_Confirmed: ec = GPG_ERR_NOT_CONFIRMED; break;
|
||||
case ASSUAN_Invalid_Id: ec = GPG_ERR_INV_ID; break;
|
||||
|
||||
default:
|
||||
err = err < 100? GNUPG_Assuan_Server_Fault : GNUPG_Assuan_Error;
|
||||
ec = err < 100? GPG_ERR_ASSUAN_SERVER_FAULT : GPG_ERR_ASSUAN;
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
return gpg_err_make (GPG_ERR_SOURCE_UNKNOWN, ec);
|
||||
}
|
||||
|
||||
/* Map GNUPG_xxx error codes to Assuan status codes */
|
||||
/* Map GPG_xERR_xx error codes to Assuan status codes */
|
||||
int
|
||||
map_to_assuan_status (int rc)
|
||||
{
|
||||
switch (rc)
|
||||
gpg_err_code_t ec = gpg_err_code (rc);
|
||||
gpg_err_source_t es = gpg_err_source (rc);
|
||||
|
||||
if (!es)
|
||||
{
|
||||
case -1:
|
||||
rc = ASSUAN_No_Data_Available;
|
||||
break;
|
||||
case 0: break;
|
||||
case GNUPG_Bad_CA_Certificate:
|
||||
case GNUPG_Bad_Certificate:
|
||||
case GNUPG_Wrong_Key_Usage:
|
||||
case GNUPG_Certificate_Revoked:
|
||||
case GNUPG_No_CRL_Known:
|
||||
case GNUPG_CRL_Too_Old:
|
||||
case GNUPG_No_Policy_Match:
|
||||
case GNUPG_Certificate_Expired:
|
||||
rc = ASSUAN_Bad_Certificate;
|
||||
break;
|
||||
case GNUPG_Bad_Certificate_Chain: rc = ASSUAN_Bad_Certificate_Chain; break;
|
||||
case GNUPG_Missing_Certificate: rc = ASSUAN_Missing_Certificate; break;
|
||||
case GNUPG_No_Data: rc = ASSUAN_No_Data_Available; break;
|
||||
case GNUPG_Bad_Signature: rc = ASSUAN_Bad_Signature; break;
|
||||
case GNUPG_Not_Implemented: rc = ASSUAN_Not_Implemented; break;
|
||||
case GNUPG_No_Agent: rc = ASSUAN_No_Agent; break;
|
||||
case GNUPG_Agent_Error: rc = ASSUAN_Agent_Error; break;
|
||||
case GNUPG_No_Public_Key: rc = ASSUAN_No_Public_Key; break;
|
||||
case GNUPG_No_Secret_Key: rc = ASSUAN_No_Secret_Key; break;
|
||||
case GNUPG_Invalid_Data: rc = ASSUAN_Invalid_Data; break;
|
||||
case GNUPG_Invalid_Name: rc = ASSUAN_Invalid_Name; break;
|
||||
case GNUPG_Not_Trusted: rc = ASSUAN_Not_Trusted; break;
|
||||
case GNUPG_Canceled: rc = ASSUAN_Canceled; break;
|
||||
case GNUPG_Invalid_Index: rc = ASSUAN_Invalid_Index; break;
|
||||
|
||||
case GNUPG_Card_Error:
|
||||
case GNUPG_Card_Reset:
|
||||
rc = ASSUAN_Card_Error;
|
||||
break;
|
||||
case GNUPG_Card_Removed:
|
||||
case GNUPG_Card_Not_Present:
|
||||
rc = ASSUAN_Card_Not_Present;
|
||||
break;
|
||||
case GNUPG_Invalid_Card: rc = ASSUAN_Invalid_Card; break;
|
||||
case GNUPG_No_PKCS15_App: rc = ASSUAN_No_PKCS15_App; break;
|
||||
case GNUPG_Not_Confirmed: rc = ASSUAN_Not_Confirmed; break;
|
||||
case GNUPG_Invalid_Id: rc = ASSUAN_Invalid_Id; break;
|
||||
|
||||
case GNUPG_Bad_PIN:
|
||||
case GNUPG_Bad_Passphrase:
|
||||
rc = ASSUAN_No_Secret_Key;
|
||||
break;
|
||||
|
||||
case GNUPG_Read_Error:
|
||||
case GNUPG_Write_Error:
|
||||
case GNUPG_IO_Error:
|
||||
rc = ASSUAN_Server_IO_Error;
|
||||
break;
|
||||
case GNUPG_Out_Of_Core:
|
||||
case GNUPG_Resource_Limit:
|
||||
rc = ASSUAN_Server_Resource_Problem;
|
||||
break;
|
||||
case GNUPG_Bug:
|
||||
case GNUPG_Internal_Error:
|
||||
rc = ASSUAN_Server_Bug;
|
||||
break;
|
||||
default:
|
||||
rc = ASSUAN_Server_Fault;
|
||||
break;
|
||||
es = GPG_ERR_SOURCE_USER_4; /* This should not happen, but we
|
||||
need to make sure to pass a new
|
||||
Assuan errorcode along. */
|
||||
log_debug ("map_to_assuan_status called with no error source\n");
|
||||
}
|
||||
return rc;
|
||||
|
||||
if (ec == -1)
|
||||
ec = GPG_ERR_NO_DATA; /* That used to be ASSUAN_No_Data_Available. */
|
||||
|
||||
return gpg_err_make (es, ec);
|
||||
}
|
||||
|
||||
|
||||
|
89
common/membuf.c
Normal file
89
common/membuf.c
Normal file
@ -0,0 +1,89 @@
|
||||
/* membuf.c - A simple implementation of a dynamic buffer
|
||||
* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "membuf.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/* A simple implementation of a dynamic buffer. Use init_membuf() to
|
||||
create a buffer, put_membuf to append bytes and get_membuf to
|
||||
release and return the buffer. Allocation errors are detected but
|
||||
only returned at the final get_membuf(), this helps not to clutter
|
||||
the code with out of core checks. */
|
||||
|
||||
void
|
||||
init_membuf (membuf_t *mb, int initiallen)
|
||||
{
|
||||
mb->len = 0;
|
||||
mb->size = initiallen;
|
||||
mb->out_of_core = 0;
|
||||
mb->buf = xtrymalloc (initiallen);
|
||||
if (!mb->buf)
|
||||
mb->out_of_core = errno;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
put_membuf (membuf_t *mb, const void *buf, size_t len)
|
||||
{
|
||||
if (mb->out_of_core)
|
||||
return;
|
||||
|
||||
if (mb->len + len >= mb->size)
|
||||
{
|
||||
char *p;
|
||||
|
||||
mb->size += len + 1024;
|
||||
p = xtryrealloc (mb->buf, mb->size);
|
||||
if (!p)
|
||||
{
|
||||
mb->out_of_core = errno;
|
||||
return;
|
||||
}
|
||||
mb->buf = p;
|
||||
}
|
||||
memcpy (mb->buf + mb->len, buf, len);
|
||||
mb->len += len;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
get_membuf (membuf_t *mb, size_t *len)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (mb->out_of_core)
|
||||
{
|
||||
xfree (mb->buf);
|
||||
mb->buf = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = mb->buf;
|
||||
*len = mb->len;
|
||||
mb->buf = NULL;
|
||||
mb->out_of_core = ENOMEM; /* hack to make sure it won't get reused. */
|
||||
return p;
|
||||
}
|
41
common/membuf.h
Normal file
41
common/membuf.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* membuf.h - A simple implementation of a dynamic buffer
|
||||
* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifndef GNUPG_COMMON_MEMBUF_H
|
||||
#define GNUPG_COMMON_MEMBUF_H
|
||||
|
||||
/* The definition of the structure is private, we only need it here,
|
||||
so it can be allocated on the stack. */
|
||||
struct private_membuf_s {
|
||||
size_t len;
|
||||
size_t size;
|
||||
char *buf;
|
||||
int out_of_core;
|
||||
};
|
||||
|
||||
typedef struct private_membuf_s membuf_t;
|
||||
|
||||
|
||||
void init_membuf (membuf_t *mb, int initiallen);
|
||||
void put_membuf (membuf_t *mb, const void *buf, size_t len);
|
||||
void *get_membuf (membuf_t *mb, size_t *len);
|
||||
|
||||
|
||||
#endif /*GNUPG_COMMON_MEMBUF_H*/
|
@ -21,8 +21,9 @@
|
||||
#ifndef GNUPG_COMMON_UTIL_H
|
||||
#define GNUPG_COMMON_UTIL_H
|
||||
|
||||
#include <gcrypt.h> /* we need this for the memory function protos */
|
||||
#include <time.h> /* we need time_t */
|
||||
#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. */
|
||||
|
||||
/* to pass hash functions to libksba we need to cast it */
|
||||
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
|
||||
@ -53,7 +54,7 @@
|
||||
int map_ksba_err (int err);
|
||||
int map_gcry_err (int err);
|
||||
int map_kbx_err (int err);
|
||||
int map_assuan_err (int err);
|
||||
gpg_error_t map_assuan_err (int err);
|
||||
int map_to_assuan_status (int rc);
|
||||
|
||||
/*-- gettime.c --*/
|
||||
|
@ -1,3 +1,9 @@
|
||||
2003-06-04 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* card.c (map_sc_err): Renamed gpg_make_err to gpg_err_make.
|
||||
|
||||
Renamed error codes from INVALID to INV and removed _ERROR suffixes.
|
||||
|
||||
2003-06-03 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Changed all error codes in all files to the new libgpg-error scheme.
|
||||
|
@ -145,11 +145,11 @@ main (int argc, char **argv )
|
||||
|
||||
rc = atr_dump (slot, stdout);
|
||||
if (rc)
|
||||
log_error ("can't dump ATR: %s\n", gnupg_strerror (rc));
|
||||
log_error ("can't dump ATR: %s\n", gpg_strerror (rc));
|
||||
|
||||
rc = app_select_openpgp (slot);
|
||||
if (rc)
|
||||
log_error ("selecting openpgp failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("selecting openpgp failed: %s\n", gpg_strerror (rc));
|
||||
else
|
||||
log_info ("openpgp application selected\n");
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
2003-06-04 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* call-agent.c (init_membuf,put_membuf,get_membuf): Removed.
|
||||
Include new membuf header and changed used type.
|
||||
|
||||
Renamed error codes from INVALID to INV and removed _ERROR suffixes.
|
||||
|
||||
2003-06-03 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Changed all error codes in all files to the new libgpg-error scheme.
|
||||
|
@ -165,7 +165,7 @@ gpgsm_export (CTRL ctrl, STRLIST names, FILE *fp)
|
||||
rc = gpgsm_finish_writer (b64writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("write failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("write failed: %s\n", gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
gpgsm_destroy_writer (b64writer);
|
||||
@ -182,7 +182,7 @@ gpgsm_export (CTRL ctrl, STRLIST names, FILE *fp)
|
||||
rc = gpgsm_finish_writer (b64writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("write failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("write failed: %s\n", gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
|
@ -1290,7 +1290,7 @@ main ( int argc, char **argv)
|
||||
{
|
||||
int rc = gpgsm_agent_learn ();
|
||||
if (rc)
|
||||
log_error ("error learning card: %s\n", gnupg_strerror (rc));
|
||||
log_error ("error learning card: %s\n", gpg_strerror (rc));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1311,7 +1311,7 @@ main ( int argc, char **argv)
|
||||
else
|
||||
rc = gpgsm_agent_passwd (grip);
|
||||
if (rc)
|
||||
log_error ("error changing passphrase: %s\n", gnupg_strerror (rc));
|
||||
log_error ("error changing passphrase: %s\n", gpg_strerror (rc));
|
||||
xfree (grip);
|
||||
ksba_cert_release (cert);
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ import_one (CTRL ctrl, struct stats_s *stats, int in_fd)
|
||||
rc = gpgsm_create_reader (&b64reader, ctrl, fp, &reader);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create reader: %s\n", gnupg_strerror (rc));
|
||||
log_error ("can't create reader: %s\n", gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ gpgsm_import (CTRL ctrl, int in_fd)
|
||||
line invocation will return with an error (log_error keeps a
|
||||
global errorcount) */
|
||||
if (rc && !log_get_errorcount (0))
|
||||
log_error (_("error importing certificate: %s\n"), gnupg_strerror (rc));
|
||||
log_error (_("error importing certificate: %s\n"), gpg_strerror (rc));
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ gpgsm_import_files (CTRL ctrl, int nfiles, char **files,
|
||||
line invocation will return with an error (log_error keeps a
|
||||
global errorcount) */
|
||||
if (rc && !log_get_errorcount (0))
|
||||
log_error (_("error importing certificate: %s\n"), gnupg_strerror (rc));
|
||||
log_error (_("error importing certificate: %s\n"), gpg_strerror (rc));
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ list_internal_keys (CTRL ctrl, STRLIST names, FILE *fp, unsigned int mode)
|
||||
rc = keydb_get_cert (hd, &cert);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("keydb_get_cert failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("keydb_get_cert failed: %s\n", gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
@ -593,7 +593,7 @@ list_external_keys (CTRL ctrl, STRLIST names, FILE *fp)
|
||||
|
||||
rc = gpgsm_dirmngr_lookup (ctrl, names, list_external_cb, &parm);
|
||||
if (rc)
|
||||
log_error ("listing external keys failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("listing external keys failed: %s\n", gpg_strerror (rc));
|
||||
}
|
||||
|
||||
/* List all keys or just the key given as NAMES.
|
||||
|
@ -148,7 +148,7 @@ gpgsm_get_default_cert (KsbaCert *r_cert)
|
||||
rc = keydb_get_cert (hd, &cert);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("keydb_get_cert failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("keydb_get_cert failed: %s\n", gpg_strerror (rc));
|
||||
keydb_release (hd);
|
||||
return rc;
|
||||
}
|
||||
@ -171,7 +171,7 @@ gpgsm_get_default_cert (KsbaCert *r_cert)
|
||||
}
|
||||
while (!(rc = keydb_search_next (hd)));
|
||||
if (rc && rc != -1)
|
||||
log_error ("keydb_search_next failed: %s\n", gnupg_strerror (rc));
|
||||
log_error ("keydb_search_next failed: %s\n", gpg_strerror (rc));
|
||||
|
||||
ksba_cert_release (cert);
|
||||
keydb_release (hd);
|
||||
@ -194,7 +194,7 @@ get_default_signer (void)
|
||||
{
|
||||
if (rc != -1)
|
||||
log_debug ("failed to find default certificate: %s\n",
|
||||
gnupg_strerror (rc));
|
||||
gpg_strerror (rc));
|
||||
return NULL;
|
||||
}
|
||||
return cert;
|
||||
|
18
sm/verify.c
18
sm/verify.c
@ -365,8 +365,13 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd, FILE *out_fp)
|
||||
else
|
||||
log_error ("failed to find the certificate: %s\n",
|
||||
gnupg_strerror(rc));
|
||||
gpgsm_status2 (ctrl, STATUS_ERROR, "verify.findkey",
|
||||
gnupg_error_token (rc), NULL);
|
||||
{
|
||||
char numbuf[50];
|
||||
sprintf (numbuf, "%d", rc);
|
||||
|
||||
gpgsm_status2 (ctrl, STATUS_ERROR, "verify.findkey",
|
||||
numbuf, NULL);
|
||||
}
|
||||
/* fixme: we might want to append the issuer and serial
|
||||
using our standard notation */
|
||||
goto next_signer;
|
||||
@ -533,8 +538,13 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd, FILE *out_fp)
|
||||
fclose (fp);
|
||||
|
||||
if (rc)
|
||||
gpgsm_status2 (ctrl, STATUS_ERROR, "verify.leave",
|
||||
gnupg_error_token (rc), NULL);
|
||||
{
|
||||
char numbuf[50];
|
||||
sprintf (numbuf, "%d", rc );
|
||||
gpgsm_status2 (ctrl, STATUS_ERROR, "verify.leave",
|
||||
numbuf, NULL);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user