MINOR: ssl: Add ssllib_name_startswith precondition
This new ssllib_name_startswith precondition check can be used to
distinguish application linked with OpenSSL from the ones linked with
other SSL libraries (LibreSSL or BoringSSL namely). This check takes a
string as input and returns 1 when the SSL library's name starts with
the given string. It is based on the OpenSSL_version function which
returns the same output as the "openssl version" command.
diff --git a/src/cfgcond.c b/src/cfgcond.c
index 4aaa92d..5fb7069 100644
--- a/src/cfgcond.c
+++ b/src/cfgcond.c
@@ -18,14 +18,15 @@
/* supported condition predicates */
const struct cond_pred_kw cond_predicates[] = {
- { "defined", CFG_PRED_DEFINED, ARG1(1, STR) },
- { "feature", CFG_PRED_FEATURE, ARG1(1, STR) },
- { "streq", CFG_PRED_STREQ, ARG2(2, STR, STR) },
- { "strneq", CFG_PRED_STRNEQ, ARG2(2, STR, STR) },
- { "version_atleast", CFG_PRED_VERSION_ATLEAST, ARG1(1, STR) },
- { "version_before", CFG_PRED_VERSION_BEFORE, ARG1(1, STR) },
- { "openssl_version_atleast", CFG_PRED_OSSL_VERSION_ATLEAST, ARG1(1, STR) },
- { "openssl_version_before", CFG_PRED_OSSL_VERSION_BEFORE, ARG1(1, STR) },
+ { "defined", CFG_PRED_DEFINED, ARG1(1, STR) },
+ { "feature", CFG_PRED_FEATURE, ARG1(1, STR) },
+ { "streq", CFG_PRED_STREQ, ARG2(2, STR, STR) },
+ { "strneq", CFG_PRED_STRNEQ, ARG2(2, STR, STR) },
+ { "version_atleast", CFG_PRED_VERSION_ATLEAST, ARG1(1, STR) },
+ { "version_before", CFG_PRED_VERSION_BEFORE, ARG1(1, STR) },
+ { "openssl_version_atleast", CFG_PRED_OSSL_VERSION_ATLEAST, ARG1(1, STR) },
+ { "openssl_version_before", CFG_PRED_OSSL_VERSION_BEFORE, ARG1(1, STR) },
+ { "ssllib_name_startswith", CFG_PRED_SSLLIB_NAME_STARTSWITH, ARG1(1, STR) },
{ NULL, CFG_PRED_NONE, 0 }
};
@@ -250,6 +251,10 @@
ret = opensslret > 0;
break;
}
+ case CFG_PRED_SSLLIB_NAME_STARTSWITH: { // checks if the current SSL library's name starts with a specified string (can be used to distinguish OpenSSL from LibreSSL or BoringSSL)
+ ret = openssl_compare_current_name(term->args[0].data.str.area) == 0;
+ break;
+ }
default:
memprintf(err, "internal error: unhandled conditional expression predicate '%s'", term->pred->word);
break;