Change WININSTALLCONTEXT to OSSL_WINCTX

Make it more in line with other command line defines, and a bit shorter

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24450)
This commit is contained in:
Neil Horman 2024-06-07 13:36:46 -04:00
parent f4540c1b14
commit 630e3a1684
5 changed files with 22 additions and 19 deletions

View File

@ -130,19 +130,22 @@ defaults can be overridden by registry keys. This is done because it is common
practice for windows based installers to allow users to place the installation practice for windows based installers to allow users to place the installation
tree at various locations not defined at build time. The following keys: tree at various locations not defined at build time. The following keys:
`\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL\OPENSSLDIR` `\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL-<version>-<ctx>\OPENSSLDIR`
`\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL\ENGINESDIR` `\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL-<version>-<ctx>\ENGINESDIR`
`\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL\MODULESDIR` `\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL-<version>-<ctx>\MODULESDIR`
Can be administratively set, and openssl will take the paths found there as the Can be administratively set, and openssl will take the paths found there as the
values for OPENSSLDIR, ENGINESDIR and MODULESDIR respectively. If unset, the values for OPENSSLDIR, ENGINESDIR and MODULESDIR respectively.
build time defaults will be used.
To enable the reading of registry keys from windows builds, add To enable the reading of registry keys from windows builds, add
`-DWININSTALLCONTEXT=<string>`to the Configure command line. Without setting `-DOPENSSL_WINCTX=<string>`to the Configure command line. This define is used
this, the library defaults back to reporing the build time defaults without at build time to construct library build specific registry key paths of the
checking the registry. Note that if you wish to have a private set of registry format:
keys for your application, you should set `OPENSSL_VERSION` to a unique value `\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\OpenSSL-<version>-<ctx>`
Where `<version>` is the semantic major.minor.patch version of the library being
built, and `<ctx>` is the value specified by `-DOPENSSL_WINCTX`. This allows
for multiple openssl builds to be created and installed on a single system, in
which each library can use its own set of registry keys.
Note the installer available at <https://github.com/openssl/installer> will set Note the installer available at <https://github.com/openssl/installer> will set
these keys when the installer is run. these keys when the installer is run.

View File

@ -136,7 +136,7 @@ opthelp:
if (cpuinfo) if (cpuinfo)
printf("%s\n", OpenSSL_version(OPENSSL_CPU_INFO)); printf("%s\n", OpenSSL_version(OPENSSL_CPU_INFO));
if (windows) if (windows)
printf("WININSTALLCONTEXT: %s\n", OpenSSL_version(OPENSSL_WININSTALLCONTEXT)); printf("OSSL_WINCTX: %s\n", OpenSSL_version(OPENSSL_WINCTX));
ret = 0; ret = 0;
end: end:
return ret; return ret;

View File

@ -70,7 +70,7 @@ const char *OpenSSL_version(int t)
return ossl_cpu_info_str; return ossl_cpu_info_str;
else else
return "CPUINFO: N/A"; return "CPUINFO: N/A";
case OPENSSL_WININSTALLCONTEXT: case OPENSSL_WINCTX:
return ossl_get_wininstallcontext(); return ossl_get_wininstallcontext();
} }
return "not available"; return "not available";

View File

@ -18,8 +18,8 @@
# define TOSTR(x) #x # define TOSTR(x) #x
# define MAKESTR(x) TOSTR(x) # define MAKESTR(x) TOSTR(x)
# define NOQUOTE(x) x # define NOQUOTE(x) x
#if defined(WININSTALLCONTEXT) #if defined(OSSL_WINCTX)
# define REGISTRY_KEY "SOFTWARE\\WOW6432Node\\OpenSSL" ##"-"## NOQUOTE(OPENSSL_VERSION_STR) ##"-"## MAKESTR(WININSTALLCONTEXT) # define REGISTRY_KEY "SOFTWARE\\WOW6432Node\\OpenSSL" ##"-"## NOQUOTE(OPENSSL_VERSION_STR) ##"-"## MAKESTR(OSSL_WINCTX)
#else #else
# define REGISTRY_KEY "NONE" # define REGISTRY_KEY "NONE"
#endif #endif
@ -117,7 +117,7 @@ DEFINE_RUN_ONCE_STATIC(do_defaults_setup)
const char *ossl_get_openssldir(void) const char *ossl_get_openssldir(void)
{ {
#if defined(_WIN32) #if defined(_WIN32)
# if defined(WININSTALLCONTEXT) # if defined(OSSL_WINCTX)
if (!RUN_ONCE(&defaults_setup_init, do_defaults_setup)) if (!RUN_ONCE(&defaults_setup_init, do_defaults_setup))
return NULL; return NULL;
return (const char *)openssldir; return (const char *)openssldir;
@ -141,7 +141,7 @@ const char *ossl_get_openssldir(void)
const char *ossl_get_enginesdir(void) const char *ossl_get_enginesdir(void)
{ {
#if defined(_WIN32) #if defined(_WIN32)
# if defined(WININSTALLCONTEXT) # if defined(OSSL_WINCTX)
if (!RUN_ONCE(&defaults_setup_init, do_defaults_setup)) if (!RUN_ONCE(&defaults_setup_init, do_defaults_setup))
return NULL; return NULL;
return (const char *)enginesdir; return (const char *)enginesdir;
@ -165,7 +165,7 @@ const char *ossl_get_enginesdir(void)
const char *ossl_get_modulesdir(void) const char *ossl_get_modulesdir(void)
{ {
#if defined(_WIN32) #if defined(_WIN32)
# if definied (WININSTALLCONTEXT) # if defined (OSSL_WINCTX)
if (!RUN_ONCE(&defaults_setup_init, do_defaults_setup)) if (!RUN_ONCE(&defaults_setup_init, do_defaults_setup))
return NULL; return NULL;
return (const char *)modulesdir; return (const char *)modulesdir;
@ -188,8 +188,8 @@ const char *ossl_get_modulesdir(void)
*/ */
const char *ossl_get_wininstallcontext(void) const char *ossl_get_wininstallcontext(void)
{ {
#if defined(_WIN32) && defined (WININSTALLCONTEXT) #if defined(_WIN32) && defined (OSSL_WINCTX)
return MAKESTR(WININSTALLCONTEXT); return MAKESTR(OSSL_WINCTX);
#else #else
return ""; return "";
#endif #endif

View File

@ -170,7 +170,7 @@ const char *OpenSSL_version(int type);
# define OPENSSL_FULL_VERSION_STRING 7 # define OPENSSL_FULL_VERSION_STRING 7
# define OPENSSL_MODULES_DIR 8 # define OPENSSL_MODULES_DIR 8
# define OPENSSL_CPU_INFO 9 # define OPENSSL_CPU_INFO 9
# define OPENSSL_WININSTALLCONTEXT 10 # define OPENSSL_WINCTX 10
const char *OPENSSL_info(int type); const char *OPENSSL_info(int type);
/* /*