From 5f3fefe2f3b1103299eda85831908508d8bb2114 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Tue, 15 Oct 2024 12:22:52 +0200 Subject: [PATCH] Add 'openssl info' item for the Windows install context This information is already present as an 'openssl version' item. Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/25694) --- apps/info.c | 7 ++++++- crypto/info.c | 2 ++ doc/man1/openssl-info.pod.in | 4 ++++ doc/man3/OpenSSL_version.pod | 9 +++++++++ include/openssl/crypto.h.in | 1 + 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/info.c b/apps/info.c index f3a1a2b107..5a469eed96 100644 --- a/apps/info.c +++ b/apps/info.c @@ -14,7 +14,7 @@ typedef enum OPTION_choice { OPT_COMMON, OPT_CONFIGDIR, OPT_ENGINESDIR, OPT_MODULESDIR, OPT_DSOEXT, OPT_DIRNAMESEP, - OPT_LISTSEP, OPT_SEEDS, OPT_CPUSETTINGS + OPT_LISTSEP, OPT_SEEDS, OPT_CPUSETTINGS, OPT_WINDOWSCONTEXT } OPTION_CHOICE; const OPTIONS info_options[] = { @@ -32,6 +32,7 @@ const OPTIONS info_options[] = { {"listsep", OPT_LISTSEP, '-', "List separator character"}, {"seeds", OPT_SEEDS, '-', "Seed sources"}, {"cpusettings", OPT_CPUSETTINGS, '-', "CPU settings info"}, + {"windowscontext", OPT_WINDOWSCONTEXT, '-', "Windows install context"}, {NULL} }; @@ -85,6 +86,10 @@ opthelp: type = OPENSSL_INFO_CPU_SETTINGS; dirty++; break; + case OPT_WINDOWSCONTEXT: + type = OPENSSL_INFO_WINDOWS_CONTEXT; + dirty++; + break; } } if (!opt_check_rest_arg(NULL)) diff --git a/crypto/info.c b/crypto/info.c index 153460a71f..ad31c9ec31 100644 --- a/crypto/info.c +++ b/crypto/info.c @@ -243,6 +243,8 @@ const char *OPENSSL_info(int t) if (ossl_cpu_info_str[0] != '\0') return ossl_cpu_info_str + strlen(CPUINFO_PREFIX); break; + case OPENSSL_INFO_WINDOWS_CONTEXT: + return ossl_get_wininstallcontext(); default: break; } diff --git a/doc/man1/openssl-info.pod.in b/doc/man1/openssl-info.pod.in index 0e91bb28ee..90c6676079 100644 --- a/doc/man1/openssl-info.pod.in +++ b/doc/man1/openssl-info.pod.in @@ -73,6 +73,10 @@ Outputs the randomness seed sources. Outputs the OpenSSL CPU settings info. +=item B<-windowscontext> + +Outputs the Windows install context. + =back =head1 HISTORY diff --git a/doc/man3/OpenSSL_version.pod b/doc/man3/OpenSSL_version.pod index e1cf16e2a1..8227c78500 100644 --- a/doc/man3/OpenSSL_version.pod +++ b/doc/man3/OpenSSL_version.pod @@ -211,6 +211,15 @@ automatically configured but may be set via an environment variable. The value has the same syntax as the environment variable. For x86 the string looks like C. +=item OPENSSL_INFO_WINDOWS_CONTEXT + +The Windows install context. +The Windows install context is used to compute the OpenSSL registry key name +on Windows. The full registry key is +C, where C<{major}>, +C<{minor}> and C<{context}> are OpenSSL's major version number, minor version +number and the Windows install context, respectively. + =back For an unknown I, NULL is returned. diff --git a/include/openssl/crypto.h.in b/include/openssl/crypto.h.in index a2f67c1e62..101719ab5b 100644 --- a/include/openssl/crypto.h.in +++ b/include/openssl/crypto.h.in @@ -186,6 +186,7 @@ const char *OPENSSL_info(int type); # define OPENSSL_INFO_LIST_SEPARATOR 1006 # define OPENSSL_INFO_SEED_SOURCE 1007 # define OPENSSL_INFO_CPU_SETTINGS 1008 +# define OPENSSL_INFO_WINDOWS_CONTEXT 1009 int OPENSSL_issetugid(void);