From 6dc9312dbcc47643b41c4089931e1528d3e927c9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 16 May 2022 16:51:54 +0200 Subject: [PATCH] recognize options even if the build does not support them there were several cases of confused users who failed to notice that they built without OpenSSL and wondered what is wrong with their config. --- src/drv_imap.c | 65 +++++++++++++++++++++++++++++++++-------------- src/drv_maildir.c | 7 ++++- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 0b3a070..c2a4ac7 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -3786,25 +3786,6 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) } } else if (!strcasecmp( "CipherString", cfg->cmd )) { server->sconf.cipher_string = nfstrdup( cfg->val ); - } else if (!strcasecmp( "TLSType", cfg->cmd )) { - goto tlstype; - } else if (!strcasecmp( "SSLType", cfg->cmd )) { - static int sslt_warned; - if (!sslt_warned) { - sslt_warned = 1; - warn( "Notice: SSLType is deprecated. Use TLSType instead.\n" ); - } - tlstype: - if (!strcasecmp( "None", cfg->val )) { - server->ssl_type = SSL_None; - } else if (!strcasecmp( "STARTTLS", cfg->val )) { - server->ssl_type = SSL_STARTTLS; - } else if (!strcasecmp( "IMAPS", cfg->val )) { - server->ssl_type = SSL_IMAPS; - } else { - error( "%s:%d: Invalid TLS type\n", cfg->file, cfg->line ); - cfg->err = 1; - } } else if (!strcasecmp( "TLSVersions", cfg->cmd )) { arg = cfg->val; do { @@ -3863,7 +3844,44 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) cfg->err = 1; } } while ((arg = get_arg( cfg, ARG_OPTIONAL, NULL ))); +#else + } else if (!strcasecmp( "CertificateFile", cfg->cmd ) || + !strcasecmp( "SystemCertificates", cfg->cmd ) || + !strcasecmp( "ClientCertificate", cfg->cmd ) || + !strcasecmp( "ClientKey", cfg->cmd ) || + !strcasecmp( "CipherString", cfg->cmd ) || + !strcasecmp( "SSLVersion", cfg->cmd ) || + !strcasecmp( "SSLVersions", cfg->cmd ) || + !strcasecmp( "TLSVersions", cfg->cmd )) { + error( "Error: " EXE " built without OpenSSL; %s is not supported.\n", cfg->cmd ); + cfg->err = 1; #endif + } else if (!strcasecmp( "TLSType", cfg->cmd )) { + goto tlstype; + } else if (!strcasecmp( "SSLType", cfg->cmd )) { + static int sslt_warned; + if (!sslt_warned) { + sslt_warned = 1; + warn( "Notice: SSLType is deprecated. Use TLSType instead.\n" ); + } + tlstype: + if (!strcasecmp( "None", cfg->val )) { +#ifdef HAVE_LIBSSL + server->ssl_type = SSL_None; + } else if (!strcasecmp( "STARTTLS", cfg->val )) { + server->ssl_type = SSL_STARTTLS; + } else if (!strcasecmp( "IMAPS", cfg->val )) { + server->ssl_type = SSL_IMAPS; +#else + } else if (!strcasecmp( "STARTTLS", cfg->val ) || + !strcasecmp( "IMAPS", cfg->val )) { + error( "Error: " EXE " built without OpenSSL; only TLSType None is supported.\n" ); + cfg->err = 1; +#endif + } else { + error( "%s:%d: Invalid TLS type\n", cfg->file, cfg->line ); + cfg->err = 1; + } } else if (!strcasecmp( "AuthMech", cfg->cmd ) || !strcasecmp( "AuthMechs", cfg->cmd )) { arg = cfg->val; @@ -3948,6 +3966,15 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) if (require_cram) add_string_list(&server->auth_mechs, "CRAM-MD5"); } +#ifndef HAVE_LIBSASL + for (string_list_t *mech = server->auth_mechs; mech; mech = mech->next) { + if (strcmp( mech->string, "*" ) && strcasecmp( mech->string, "LOGIN" )) { + error( "Error: " EXE " built without LibSASL; only AuthMech LOGIN is supported.\n" ); + cfg->err = 1; + break; + } + } +#endif if (!server->auth_mechs) add_string_list( &server->auth_mechs, "*" ); if (!server->sconf.port) { diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 60f85f9..58f6a77 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -1879,9 +1879,14 @@ maildir_parse_store( conffile_t *cfg, store_conf_t **storep ) store->inbox = expand_strdup( cfg->val, cfg ); } else if (!strcasecmp( "Path", cfg->cmd )) { store->path = expand_strdup( cfg->val, cfg ); -#ifdef USE_DB } else if (!strcasecmp( "AltMap", cfg->cmd )) { +#ifdef USE_DB store->alt_map = parse_bool( cfg ); +#else + if (parse_bool( cfg )) { + error( "Error: AltMap=true is not supported by this build.\n" ); + cfg->err = 1; + } #endif /* USE_DB */ } else if (!strcasecmp( "InfoDelimiter", cfg->cmd )) { if (strlen( cfg->val ) != 1) {