diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-08-10 07:19:51 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-08-10 07:19:51 +0300 |
commit | 0ac500aef722ac5674cfd053889e1c0101c88f97 (patch) | |
tree | b81723b45461f65a38ccf70227694f0b0592e3cb | |
parent | 93970a7554512add3e9192a8eeabd0abbedcc5c0 (diff) | |
download | mailutils-0ac500aef722ac5674cfd053889e1c0101c88f97.tar.gz mailutils-0ac500aef722ac5674cfd053889e1c0101c88f97.tar.bz2 |
Fix compilation without TLS
* testsuite/mockmta.c: Fix preprocessor conditionals regarding TLS.
-rw-r--r-- | testsuite/mockmta.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/testsuite/mockmta.c b/testsuite/mockmta.c index 969f99e49..517df4b4c 100644 --- a/testsuite/mockmta.c +++ b/testsuite/mockmta.c | |||
@@ -566,21 +566,46 @@ iofile_create (int fd) | |||
566 | enum | 566 | enum |
567 | { | 567 | { |
568 | IO2_RD, | 568 | IO2_RD, |
569 | IO2_WR | 569 | IO2_WR |
570 | }; | 570 | }; |
571 | 571 | ||
572 | static void disable_starttls (void); | ||
573 | |||
572 | #ifdef WITH_TLS | 574 | #ifdef WITH_TLS |
573 | # include <gnutls/gnutls.h> | 575 | # include <gnutls/gnutls.h> |
574 | 576 | ||
575 | /* TLS support */ | 577 | /* TLS support */ |
576 | char *tls_cert; /* TLS sertificate */ | 578 | char *tls_cert; /* TLS sertificate */ |
577 | char *tls_key; /* TLS key */ | 579 | char *tls_key; /* TLS key */ |
578 | char *tls_cafile; | 580 | char *tls_cafile; |
579 | 581 | ||
580 | static inline int | 582 | static inline int |
583 | set_tls_opt (int c) | ||
584 | { | ||
585 | switch (c) | ||
586 | { | ||
587 | case 'c': | ||
588 | tls_cert = optarg; | ||
589 | break; | ||
590 | |||
591 | case 'k': | ||
592 | tls_key = optarg; | ||
593 | break; | ||
594 | |||
595 | case 'f': | ||
596 | tls_cafile = optarg; | ||
597 | break; | ||
598 | |||
599 | default: | ||
600 | return 1; | ||
601 | } | ||
602 | return 0; | ||
603 | } | ||
604 | |||
605 | static inline int | ||
581 | enable_tls (void) | 606 | enable_tls (void) |
582 | { | 607 | { |
583 | return tls_cert != NULL && tls_key != NULL; | 608 | return tls_cert != NULL && tls_key != NULL; |
584 | } | 609 | } |
585 | 610 | ||
586 | /* TLS streams */ | 611 | /* TLS streams */ |
@@ -664,14 +689,12 @@ static void | |||
664 | generate_dh_params (void) | 689 | generate_dh_params (void) |
665 | { | 690 | { |
666 | gnutls_dh_params_init (&dh_params); | 691 | gnutls_dh_params_init (&dh_params); |
667 | gnutls_dh_params_generate2 (dh_params, DH_BITS); | 692 | gnutls_dh_params_generate2 (dh_params, DH_BITS); |
668 | } | 693 | } |
669 | 694 | ||
670 | static void disable_starttls (void); | ||
671 | |||
672 | static int | 695 | static int |
673 | tls_init (void) | 696 | tls_init (void) |
674 | { | 697 | { |
675 | int rc; | 698 | int rc; |
676 | 699 | ||
677 | if (!enable_tls()) | 700 | if (!enable_tls()) |
@@ -763,12 +786,17 @@ iotls_create (int in, int out) | |||
763 | return NULL; | 786 | return NULL; |
764 | } | 787 | } |
765 | 788 | ||
766 | return (struct iobase *)bp; | 789 | return (struct iobase *)bp; |
767 | } | 790 | } |
768 | #else | 791 | #else |
792 | static inline int set_tls_opt (int c) { | ||
793 | terror ("option -%c not supported: program compiled without support for TLS", | ||
794 | c); | ||
795 | return 1; | ||
796 | } | ||
769 | static inline int enable_tls(void) { return 0; } | 797 | static inline int enable_tls(void) { return 0; } |
770 | static inline int tls_init (void) { return -1; } | 798 | static inline int tls_init (void) { return -1; } |
771 | static inline struct iobase *iotls_create (int in, int out) { return NULL; } | 799 | static inline struct iobase *iotls_create (int in, int out) { return NULL; } |
772 | #endif | 800 | #endif |
773 | 801 | ||
774 | /* Two-way I/O */ | 802 | /* Two-way I/O */ |
@@ -1297,13 +1325,15 @@ static struct smtp_transition smtp_transition_table[MAX_STATE][MAX_KW] = { | |||
1297 | }, | 1325 | }, |
1298 | }; | 1326 | }; |
1299 | 1327 | ||
1300 | static void | 1328 | static void |
1301 | disable_starttls (void) | 1329 | disable_starttls (void) |
1302 | { | 1330 | { |
1331 | #ifdef WITH_TLS | ||
1303 | tls_cert = tls_key = tls_cafile = NULL; | 1332 | tls_cert = tls_key = tls_cafile = NULL; |
1333 | #endif | ||
1304 | smtp_transition_table[STATE_EHLO][KW_STARTTLS].new_state = STATE_ERR; | 1334 | smtp_transition_table[STATE_EHLO][KW_STARTTLS].new_state = STATE_ERR; |
1305 | } | 1335 | } |
1306 | 1336 | ||
1307 | static void | 1337 | static void |
1308 | do_smtp (int fd) | 1338 | do_smtp (int fd) |
1309 | { | 1339 | { |
@@ -1471,26 +1501,15 @@ main (int argc, char **argv) | |||
1471 | { | 1501 | { |
1472 | terror ("wrong timeout value"); | 1502 | terror ("wrong timeout value"); |
1473 | exit (EX_USAGE); | 1503 | exit (EX_USAGE); |
1474 | } | 1504 | } |
1475 | break; | 1505 | break; |
1476 | 1506 | ||
1477 | case 'c': | ||
1478 | tls_cert = optarg; | ||
1479 | break; | ||
1480 | |||
1481 | case 'k': | ||
1482 | tls_key = optarg; | ||
1483 | break; | ||
1484 | |||
1485 | case 'f': | ||
1486 | tls_cafile = optarg; | ||
1487 | break; | ||
1488 | |||
1489 | default: | 1507 | default: |
1490 | exit (EX_USAGE); | 1508 | if (set_tls_opt (c)) |
1509 | exit (EX_USAGE); | ||
1491 | } | 1510 | } |
1492 | } | 1511 | } |
1493 | 1512 | ||
1494 | argc -= optind; | 1513 | argc -= optind; |
1495 | argv += optind; | 1514 | argv += optind; |
1496 | 1515 | ||