diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2020-09-11 03:50:09 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2020-09-11 03:50:09 +1000 |
commit | 9a62ccbe8a73101d2cfcdf7902b6fe10da7602c9 (patch) | |
tree | d12d736be0605e05aa2d0000a4cb563c1e76b2b6 /apps/fipsinstall.c | |
parent | 9f604ca13ddc99e17ba37fed9281fbd1b71149a9 (diff) |
Fix fipsinstall module path
If a path is specified with the -module option it will use this path to load the library when the provider is activated,
instead of also having to set the environment variable OPENSSL_MODULES.
Added a platform specific opt_path_end() function that uses existing functionality used by opt_progname().
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12761)
Diffstat (limited to 'apps/fipsinstall.c')
-rw-r--r-- | apps/fipsinstall.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/apps/fipsinstall.c b/apps/fipsinstall.c index bd1cd68477..104806c1b7 100644 --- a/apps/fipsinstall.c +++ b/apps/fipsinstall.c @@ -277,7 +277,8 @@ int fipsinstall_main(int argc, char **argv) const char *prov_name = "fips"; BIO *module_bio = NULL, *mem_bio = NULL, *fout = NULL; char *in_fname = NULL, *out_fname = NULL, *prog; - char *module_fname = NULL, *parent_config = NULL; + char *module_fname = NULL, *parent_config = NULL, *module_path = NULL; + const char *tail; EVP_MAC_CTX *ctx = NULL, *ctx2 = NULL; STACK_OF(OPENSSL_STRING) *opts = NULL; OPTION_CHOICE o; @@ -368,6 +369,16 @@ opthelp: || argc != 0) goto opthelp; + tail = opt_path_end(module_fname); + if (tail != NULL) { + module_path = OPENSSL_strdup(module_fname); + if (module_path == NULL) + goto end; + module_path[tail - module_fname] = '\0'; + if (!OSSL_PROVIDER_set_default_search_path(NULL, module_path)) + goto end; + } + if (self_test_log || self_test_corrupt_desc != NULL || self_test_corrupt_type != NULL) @@ -474,6 +485,7 @@ end: } cleanup: + OPENSSL_free(module_path); BIO_free(fout); BIO_free(mem_bio); BIO_free(module_bio); |