Skip to content

Commit 6c0bf68

Browse files
committed
Remove runtime keystore lock file mechanism
The H5PL_SIG_LOCK_FILE_PATH feature allowed a sysadmin to drop a file at /etc/hdf5/lock_keystore (or its Windows equivalent) to prevent users from overriding the keystore via HDF5_PLUGIN_KEYSTORE. Remove it because: - The compile-time H5PL_DISABLE_ENV_KEYSTORE flag already covers the security-hardening use case cleanly - The hardcoded path requires root/admin access to create - The path is not configurable Removes: H5PL_SIG_LOCK_FILE_PATH macro, H5PL__is_keystore_locked(), and its call site in H5PL__init_keystore().
1 parent 6edf59c commit 6c0bf68

2 files changed

Lines changed: 9 additions & 56 deletions

File tree

src/H5PLpkg.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ typedef const void *(*H5PL_get_plugin_info_t)(void);
113113
/************************************/
114114
#ifdef H5_REQUIRE_DIGITAL_SIGNATURE
115115

116-
/* Lock file path for disabling environment variable keystore override */
117-
#ifdef H5_HAVE_WIN32_API
118-
#define H5PL_SIG_LOCK_FILE_PATH "C:\\ProgramData\\HDF_Group\\HDF5\\lock_keystore"
119-
#else
120-
#define H5PL_SIG_LOCK_FILE_PATH "/etc/hdf5/lock_keystore"
121-
#endif
122-
123116
/* Keystore directory string for error messages */
124117
#ifdef H5PL_KEYSTORE_DIR
125118
#define H5PL_SIG_KEYSTORE_DIR_STR H5PL_KEYSTORE_DIR

src/H5PLsig.c

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -823,39 +823,6 @@ H5PL__load_keys_from_directory(const char *dir_path)
823823
} /* end H5PL__load_keys_from_directory() */
824824
#endif /* H5_HAVE_WIN32_API */
825825

826-
/*-------------------------------------------------------------------------
827-
* Function: H5PL__is_keystore_locked
828-
*
829-
* Purpose: Check if keystore environment variable override is locked
830-
* by presence of system lock file
831-
*
832-
* Lock file locations:
833-
* - Unix/Linux: /etc/hdf5/lock_keystore
834-
* - Windows: C:\ProgramData\HDF_Group\HDF5\lock_keystore
835-
*
836-
* This allows system administrators to disable the
837-
* HDF5_PLUGIN_KEYSTORE environment variable on pre-built
838-
* binaries without recompiling HDF5.
839-
*
840-
* Return: true if locked, false otherwise
841-
*-------------------------------------------------------------------------
842-
*/
843-
static bool
844-
H5PL__is_keystore_locked(void)
845-
{
846-
h5_stat_t st;
847-
bool ret_value = false;
848-
849-
FUNC_ENTER_PACKAGE_NOERR
850-
851-
if (HDstat(H5PL_SIG_LOCK_FILE_PATH, &st) == 0) {
852-
ret_value = true;
853-
H5PL_SIG_DEBUG_PRINT("HDF5 KeyStore: Environment variable override disabled by %s\n",
854-
H5PL_SIG_LOCK_FILE_PATH);
855-
}
856-
857-
FUNC_LEAVE_NOAPI(ret_value)
858-
} /* end H5PL__is_keystore_locked() */
859826

860827
/*-------------------------------------------------------------------------
861828
* Function: H5PL__init_keystore
@@ -892,24 +859,17 @@ H5PL__init_keystore(void)
892859

893860
/* 1. Check environment variable (highest priority) */
894861
#ifndef H5PL_DISABLE_ENV_KEYSTORE
895-
/* Check if environment variable override is locked by runtime lock file */
896-
if (!H5PL__is_keystore_locked()) {
897-
if (NULL != (env_keystore = getenv("HDF5_PLUGIN_KEYSTORE"))) {
898-
if (H5PL__load_keys_from_directory(env_keystore) < 0)
899-
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, FAIL,
900-
"failed to load keys from HDF5_PLUGIN_KEYSTORE: %s", env_keystore);
901-
keys_loaded = true;
902-
903-
/* Load revoked signatures from same directory */
904-
if (H5PL__load_revoked_signatures(env_keystore) < 0) {
905-
/* Non-fatal - continue even if revoked signatures fail to load */
906-
}
862+
if (NULL != (env_keystore = getenv("HDF5_PLUGIN_KEYSTORE"))) {
863+
if (H5PL__load_keys_from_directory(env_keystore) < 0)
864+
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, FAIL,
865+
"failed to load keys from HDF5_PLUGIN_KEYSTORE: %s", env_keystore);
866+
keys_loaded = true;
867+
868+
/* Load revoked signatures from same directory */
869+
if (H5PL__load_revoked_signatures(env_keystore) < 0) {
870+
/* Non-fatal - continue even if revoked signatures fail to load */
907871
}
908872
}
909-
else {
910-
H5PL_SIG_DEBUG_PRINT(
911-
"HDF5 KeyStore: Skipping HDF5_PLUGIN_KEYSTORE environment variable (locked by sysadmin)\n");
912-
}
913873
#else
914874
/* Environment variable override disabled at compile time (security hardening) */
915875
env_keystore = NULL; /* Suppress unused variable warning */

0 commit comments

Comments
 (0)