summaryrefslogtreecommitdiffstats
path: root/stap-client-connect.c
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2009-10-14 17:02:47 -0400
committerFrank Ch. Eigler <fche@elastic.org>2009-10-14 17:05:40 -0400
commit739cf6877b9bd84b0aba47f5c4c205a9dd63a93d (patch)
tree4e8f02f3a1a668084ef6f6202826d85016369c22 /stap-client-connect.c
parent85dfc5c81e213a1fc67c8c50d0e1101659c61d6e (diff)
downloadsystemtap-steved-739cf6877b9bd84b0aba47f5c4c205a9dd63a93d.tar.gz
systemtap-steved-739cf6877b9bd84b0aba47f5c4c205a9dd63a93d.tar.xz
systemtap-steved-739cf6877b9bd84b0aba47f5c4c205a9dd63a93d.zip
PR10331: improve nss error message handling
* stapsslerr.h: New file containing NSS* error number to string mappings. Originally from mozilla NSS documentation, also seen in other GPLv2 software. * nsscommon.c (nssError): Print error number, and text from <stapsslerr.h>. * stap-{client,server}-connect.c (errWarn): Standardize on nssError(). * Makefile.am (nss binaries): Also link in nsscommon.c.
Diffstat (limited to 'stap-client-connect.c')
-rw-r--r--stap-client-connect.c47
1 files changed, 5 insertions, 42 deletions
diff --git a/stap-client-connect.c b/stap-client-connect.c
index fd3b950c..8d48225d 100644
--- a/stap-client-connect.c
+++ b/stap-client-connect.c
@@ -29,6 +29,8 @@
#include <secerr.h>
#include <sslerr.h>
+#include "nsscommon.h"
+
#define READ_BUFFER_SIZE (60 * 1024)
static char *hostName = NULL;
static unsigned short port = 0;
@@ -46,50 +48,11 @@ Usage(const char *progName)
static void
errWarn(char *function)
{
- PRErrorCode errorNumber;
- PRInt32 errorTextLength;
- PRInt32 rc;
- char *errorText;
-
- errorNumber = PR_GetError();
- fprintf(stderr, "Error in function %s: %d: ", function, errorNumber);
-
- /* See if PR_GetErrorText can tell us what the error is. */
- if (errorNumber >= PR_NSPR_ERROR_BASE && errorNumber <= PR_MAX_ERROR)
- {
- errorTextLength = PR_GetErrorTextLength ();
- if (errorTextLength != 0) {
- errorText = PORT_Alloc(errorTextLength);
- rc = PR_GetErrorText (errorText);
- if (rc != 0)
- fprintf (stderr, "%s\n", errorText);
- PR_Free (errorText);
- if (rc != 0)
- return;
- }
- }
-
- /* Otherwise handle common errors ourselves. */
- switch (errorNumber)
- {
- case SEC_ERROR_CA_CERT_INVALID:
- fputs ("The issuer's certificate is invalid\n", stderr);
- break;
- case SEC_ERROR_BAD_DATABASE:
- fputs ("The specified certificate database does not exist or is not valid\n", stderr);
- break;
- case SSL_ERROR_BAD_CERT_DOMAIN:
- fputs ("The requested domain name does not match the server's certificate\n", stderr);
- break;
- case PR_CONNECT_RESET_ERROR:
- fputs ("Connection reset by peer\n", stderr);
- break;
- default:
- fputs ("Unknown error\n", stderr);
- break;
- }
+ fprintf(stderr, "Error in function %s: ", function);
+ nssError();
}
+
static void
exitErr(char *function)
{