Add compile-in flag to program version output.

Then we can check if tools are compiled with a support for specific
extension/library.
This commit is contained in:
Milan Broz
2022-04-14 13:59:32 +02:00
parent 3363bad8c2
commit ebabf3ffee
5 changed files with 36 additions and 7 deletions

View File

@@ -2899,8 +2899,7 @@ static void help(poptContext popt_context,
struct action_type *action;
const struct crypt_pbkdf_type *pbkdf_luks1, *pbkdf_luks2;
log_std("%s\n",PACKAGE_STRING);
tools_package_version(PACKAGE_NAME, true);
poptPrintHelp(popt_context, stdout, 0);
log_std(_("\n"
@@ -2958,7 +2957,7 @@ static void help(poptContext popt_context,
poptFreeContext(popt_context);
exit(EXIT_SUCCESS);
} else if (key->shortName == 'V') {
log_std("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
tools_package_version(PACKAGE_NAME, true);
tools_cleanup();
poptFreeContext(popt_context);
exit(EXIT_SUCCESS);

View File

@@ -73,6 +73,7 @@ typedef enum { CREATED, UNLOCKED, REMOVED } crypt_object_op;
void tools_keyslot_msg(int keyslot, crypt_object_op op);
void tools_token_msg(int token, crypt_object_op op);
void tools_token_error_msg(int error, const char *type, int token, bool pin_provided);
void tools_package_version(const char *name, bool use_pwlibs);
extern volatile int quit;
void set_int_block(int block);

View File

@@ -540,7 +540,7 @@ static void help(poptContext popt_context,
struct action_type *action;
if (key->shortName == '?') {
log_std("%s %s\n", PACKAGE_INTEGRITY, PACKAGE_VERSION);
tools_package_version(PACKAGE_INTEGRITY, false);
poptPrintHelp(popt_context, stdout, 0);
log_std(_("\n"
"<action> is one of:\n"));
@@ -559,7 +559,7 @@ static void help(poptContext popt_context,
poptFreeContext(popt_context);
exit(EXIT_SUCCESS);
} else if (key->shortName == 'V') {
log_std("%s %s\n", PACKAGE_INTEGRITY, PACKAGE_VERSION);
tools_package_version(PACKAGE_INTEGRITY, false);
tools_cleanup();
poptFreeContext(popt_context);
exit(EXIT_SUCCESS);

View File

@@ -432,3 +432,32 @@ int tools_write_mk(const char *file, const char *key, int keysize)
close(fd);
return r;
}
void tools_package_version(const char *name, bool use_pwlibs)
{
log_std("%s %s flags: %s%s\n", name, PACKAGE_VERSION,
#ifdef USE_UDEV
"UDEV "
#endif
#ifdef HAVE_BLKID
"BLKID "
#endif
#ifdef KERNEL_KEYRING
"KEYRING "
#endif
#ifdef ENABLE_FIPS
"FIPS "
#endif
#ifdef ENABLE_AF_ALG
"KERNEL_CAPI "
#endif
,
#if defined(ENABLE_PWQUALITY)
use_pwlibs ? "PWQUALITY " : ""
#elif defined(ENABLE_PASSWDQC)
use_pwlibs ? "PASSWDQC " : ""
#else
""
#endif
);
}

View File

@@ -493,7 +493,7 @@ static void help(poptContext popt_context,
struct action_type *action;
if (key->shortName == '?') {
log_std("%s %s\n", PACKAGE_VERITY, PACKAGE_VERSION);
tools_package_version(PACKAGE_VERITY, false);
poptPrintHelp(popt_context, stdout, 0);
log_std(_("\n"
"<action> is one of:\n"));
@@ -516,7 +516,7 @@ static void help(poptContext popt_context,
poptFreeContext(popt_context);
exit(EXIT_SUCCESS);
} else if (key->shortName == 'V') {
log_std("%s %s\n", PACKAGE_VERITY, PACKAGE_VERSION);
tools_package_version(PACKAGE_VERITY, false);
tools_cleanup();
poptFreeContext(popt_context);
exit(EXIT_SUCCESS);