From 3981ff15f3c0829ba22cd37794353502d996683c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 18 Aug 2014 15:42:54 +0200 Subject: agent: Return NO_SECKEY instead of ENONET for PKSIGN and others. * agent/pksign.c (agent_pksign_do): Replace ENONET by NO_SECKEY. * agent/findkey.c (agent_key_from_file): No diagnostic for NO_SECKEY. * agent/pkdecrypt.c (agent_pkdecrypt): Replace checking for ENOENT. --- agent/findkey.c | 6 +++++- agent/pkdecrypt.c | 4 +--- agent/pksign.c | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'agent') diff --git a/agent/findkey.c b/agent/findkey.c index 8725afbf3..5ff263ef4 100644 --- a/agent/findkey.c +++ b/agent/findkey.c @@ -605,7 +605,11 @@ agent_key_from_file (ctrl_t ctrl, const char *cache_nonce, rc = read_key_file (grip, &s_skey); if (rc) - return rc; + { + if (gpg_err_code (rc) == GPG_ERR_ENOENT) + rc = gpg_error (GPG_ERR_NO_SECKEY); + return rc; + } /* For use with the protection functions we also need the key as an canonical encoded S-expression in a buffer. Create this buffer diff --git a/agent/pkdecrypt.c b/agent/pkdecrypt.c index 14aa78f75..945de3c51 100644 --- a/agent/pkdecrypt.c +++ b/agent/pkdecrypt.c @@ -72,9 +72,7 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text, CACHE_MODE_NORMAL, NULL, &s_skey, NULL); if (rc) { - if (gpg_err_code (rc) == GPG_ERR_ENOENT) - rc = gpg_error (GPG_ERR_NO_SECKEY); - else + if (gpg_err_code (rc) != GPG_ERR_NO_SECKEY) log_error ("failed to read the secret key\n"); goto leave; } diff --git a/agent/pksign.c b/agent/pksign.c index 713c8ba79..9147b50d0 100644 --- a/agent/pksign.c +++ b/agent/pksign.c @@ -312,7 +312,8 @@ agent_pksign_do (ctrl_t ctrl, const char *cache_nonce, &s_skey, NULL); if (rc) { - log_error ("failed to read the secret key\n"); + if (gpg_err_code (rc) != GPG_ERR_NO_SECKEY) + log_error ("failed to read the secret key\n"); goto leave; } -- cgit v1.2.3