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.
This commit is contained in:
Oswald Buddenhagen 2022-05-16 16:51:54 +02:00
parent faec30abf4
commit 6dc9312dbc
2 changed files with 52 additions and 20 deletions

View File

@ -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) {

View File

@ -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) {