summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2020-08-10 04:19:51 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2020-08-10 04:19:51 (GMT)
commit0ac500aef722ac5674cfd053889e1c0101c88f97 (patch) (side-by-side diff)
treeb81723b45461f65a38ccf70227694f0b0592e3cb
parent93970a7554512add3e9192a8eeabd0abbedcc5c0 (diff)
downloadmailutils-master.tar.gz
mailutils-master.tar.bz2
Fix compilation without TLSHEADmaster
* testsuite/mockmta.c: Fix preprocessor conditionals regarding TLS.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--testsuite/mockmta.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/testsuite/mockmta.c b/testsuite/mockmta.c
index 969f99e..517df4b 100644
--- a/testsuite/mockmta.c
+++ b/testsuite/mockmta.c
@@ -566,21 +566,46 @@ iofile_create (int fd)
enum
{
IO2_RD,
IO2_WR
};
+static void disable_starttls (void);
+
#ifdef WITH_TLS
# include <gnutls/gnutls.h>
/* TLS support */
char *tls_cert; /* TLS sertificate */
char *tls_key; /* TLS key */
char *tls_cafile;
static inline int
+set_tls_opt (int c)
+{
+ switch (c)
+ {
+ case 'c':
+ tls_cert = optarg;
+ break;
+
+ case 'k':
+ tls_key = optarg;
+ break;
+
+ case 'f':
+ tls_cafile = optarg;
+ break;
+
+ default:
+ return 1;
+ }
+ return 0;
+}
+
+static inline int
enable_tls (void)
{
return tls_cert != NULL && tls_key != NULL;
}
/* TLS streams */
@@ -664,14 +689,12 @@ static void
generate_dh_params (void)
{
gnutls_dh_params_init (&dh_params);
gnutls_dh_params_generate2 (dh_params, DH_BITS);
}
-static void disable_starttls (void);
-
static int
tls_init (void)
{
int rc;
if (!enable_tls())
@@ -763,12 +786,17 @@ iotls_create (int in, int out)
return NULL;
}
return (struct iobase *)bp;
}
#else
+static inline int set_tls_opt (int c) {
+ terror ("option -%c not supported: program compiled without support for TLS",
+ c);
+ return 1;
+}
static inline int enable_tls(void) { return 0; }
static inline int tls_init (void) { return -1; }
static inline struct iobase *iotls_create (int in, int out) { return NULL; }
#endif
/* Two-way I/O */
@@ -1297,13 +1325,15 @@ static struct smtp_transition smtp_transition_table[MAX_STATE][MAX_KW] = {
},
};
static void
disable_starttls (void)
{
+#ifdef WITH_TLS
tls_cert = tls_key = tls_cafile = NULL;
+#endif
smtp_transition_table[STATE_EHLO][KW_STARTTLS].new_state = STATE_ERR;
}
static void
do_smtp (int fd)
{
@@ -1471,26 +1501,15 @@ main (int argc, char **argv)
{
terror ("wrong timeout value");
exit (EX_USAGE);
}
break;
- case 'c':
- tls_cert = optarg;
- break;
-
- case 'k':
- tls_key = optarg;
- break;
-
- case 'f':
- tls_cafile = optarg;
- break;
-
default:
- exit (EX_USAGE);
+ if (set_tls_opt (c))
+ exit (EX_USAGE);
}
}
argc -= optind;
argv += optind;

Return to:

Send suggestions and report system problems to the System administrator.