apps: add query to allow a command to know of a provider command line option was...
authorPauli <pauli@openssl.org>
Thu, 8 Jul 2021 01:22:14 +0000 (11:22 +1000)
committerPauli <pauli@openssl.org>
Sun, 11 Jul 2021 23:13:41 +0000 (09:13 +1000)
Better fixing:
Fixing #15683
Fixing #15686

Replacing rather than fixing:
Fixing #15414

Since that claims to fix another:
Fixing #15372

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16022)

apps/include/opt.h
apps/lib/app_provider.c

index ce0e35cd7223221cc023343fe45bf6883f7c6360..4f83a0ed53c939c6e2dc5be5fd5ffc04de3694a3 100644 (file)
@@ -388,8 +388,13 @@ int opt_pair(const char *arg, const OPT_PAIR * pairs, int *result);
 int opt_verify(int i, X509_VERIFY_PARAM *vpm);
 int opt_rand(int i);
 int opt_provider(int i);
+int opt_provider_option_given(void);
 
 char **opt_rest(void);
 int opt_num_rest(void);
 
+/* Returns non-zero if legacy paths are still available */
+int opt_legacy_okay(void);
+
+
 #endif /* OSSL_APPS_OPT_H */
index c3100b2fa889dfd312088620cb9b5f82f342d4c4..63f78ae07d80b1c34df03ca560cc787c5cab6d30 100644 (file)
@@ -13,6 +13,9 @@
 #include <openssl/provider.h>
 #include <openssl/safestack.h>
 
+/* Non-zero if any of the provider options have been seen */
+static int provider_option_given = 0;
+
 DEFINE_STACK_OF(OSSL_PROVIDER)
 
 /*
@@ -64,6 +67,9 @@ static int opt_provider_path(const char *path)
 
 int opt_provider(int opt)
 {
+    const int given = provider_option_given;
+
+    provider_option_given = 1;
     switch ((enum prov_range)opt) {
     case OPT_PROV__FIRST:
     case OPT_PROV__LAST:
@@ -75,5 +81,12 @@ int opt_provider(int opt)
     case OPT_PROV_PROPQUERY:
         return app_set_propq(opt_arg());
     }
+    /* Should never get here but if we do, undo what we did earlier */
+    provider_option_given = given;
     return 0;
 }
+
+int opt_provider_option_given(void)
+{
+    return provider_option_given;
+}