summaryrefslogtreecommitdiffstats
path: root/tcpd/starttls.c
diff options
context:
space:
mode:
authorSam Varshavchik2018-02-13 08:28:41 -0500
committerSam Varshavchik2018-02-16 20:26:59 -0500
commit8b4fcc3895ca8243e200c15cd089323a482cad13 (patch)
treebecc145e3d20dfb889835ac28a56245bc3c0c619 /tcpd/starttls.c
parent0637302037d653fbe4c46f3889f48b341195525f (diff)
downloadcourier-libs-8b4fcc3895ca8243e200c15cd089323a482cad13.tar.bz2
couriretls: Improve error messages, remove deprecated API usage.
Make gnutls return the same error message about unexpected connection terminatation as the openssl version does.
Diffstat (limited to 'tcpd/starttls.c')
-rw-r--r--tcpd/starttls.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/tcpd/starttls.c b/tcpd/starttls.c
index 3e6f08e..23c4a69 100644
--- a/tcpd/starttls.c
+++ b/tcpd/starttls.c
@@ -1,5 +1,5 @@
/*
-** Copyright 2000-2008 Double Precision, Inc.
+** Copyright 2000-2018 Double Precision, Inc.
** See COPYING for distribution information.
*/
#include "config.h"
@@ -81,7 +81,32 @@ const char *printx509=0;
static void ssl_errmsg(const char *errmsg, void *dummy)
{
- fprintf(errfp, "%s\n", errmsg);
+ const char *loglevel_prefix="";
+ const char *tcpremoteip=getenv("TCPREMOTEIP");
+ const char *errmsgpfix="";
+ const char *errmsgsfix="";
+
+ if (strncmp(errmsg, "DEBUG: ", 7) == 0)
+ {
+ loglevel_prefix="DEBUG: ";
+ errmsg += 7;
+ }
+
+ if (tcpremoteip && *tcpremoteip)
+ {
+ errmsgpfix="ip=[";
+ errmsgsfix="], ";
+ }
+ else
+ {
+ tcpremoteip="";
+ }
+
+ fprintf(errfp, "%s%s%s%s%s\n",
+ loglevel_prefix,
+ errmsgpfix, tcpremoteip, errmsgsfix,
+ errmsg);
+ fflush(errfp);
}
static void nonsslerror(const char *pfix)
@@ -698,7 +723,7 @@ static void smtp_proto(int fd)
{
p=prb_getline(fd, &prb);
printf("%s\n", p);
- } while ( ! ( isdigit((int)(unsigned char)p[0]) &&
+ } while ( ! ( isdigit((int)(unsigned char)p[0]) &&
isdigit((int)(unsigned char)p[1]) &&
isdigit((int)(unsigned char)p[2]) &&
(p[3] == 0 || isspace((int)(unsigned char)p[3]))));
@@ -716,7 +741,7 @@ static void smtp_proto(int fd)
{
p=prb_getline(fd, &prb);
printf("%s\n", p);
- } while ( ! ( isdigit((int)(unsigned char)p[0]) &&
+ } while ( ! ( isdigit((int)(unsigned char)p[0]) &&
isdigit((int)(unsigned char)p[1]) &&
isdigit((int)(unsigned char)p[2]) &&
(p[3] == 0 || isspace((int)(unsigned char)p[3]))));
@@ -729,7 +754,7 @@ static void smtp_proto(int fd)
{
p=prb_getline(fd, &prb);
printf("%s\n", p);
- } while ( ! ( isdigit((int)(unsigned char)p[0]) &&
+ } while ( ! ( isdigit((int)(unsigned char)p[0]) &&
isdigit((int)(unsigned char)p[1]) &&
isdigit((int)(unsigned char)p[2]) &&
(p[3] == 0 || isspace((int)(unsigned char)p[3]))));