Skip to content

Commit c3fc3ea

Browse files
committed
Replace compile-time debug flag with runtime HDF5_DEBUG=PL
Remove H5PL_DEBUG_KEYSTORE compile-time flag and use HDF5's standard runtime debug infrastructure instead. Plugin debug output can now be enabled at runtime with: export HDF5_DEBUG=PL Changes: - Add H5_PKG_PL to debug package enum in H5private.h - Register "pl" package name in H5.c initialization - Update H5PL_SIG_DEBUG_PRINT to check H5DEBUG(PL) at runtime - Remove H5PL_DEBUG_KEYSTORE option from CMakeLists.txt - Remove conditional compilation around debug output - Update documentation to use HDF5_DEBUG=PL - Update error messages to suggest runtime debug flag This makes plugin debugging more accessible without requiring recompilation.
1 parent dfc01a2 commit c3fc3ea

6 files changed

Lines changed: 12 additions & 20 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,6 @@ set(HDF5_PLUGIN_KEYSTORE_DIR "" CACHE PATH
803803
set(HDF5_PLUGIN_PUBLIC_KEY_FILE "" CACHE FILEPATH
804804
"Path to RSA public key (PEM format) for plugin signature verification (single key, backward compatibility)")
805805

806-
# Debug output for KeyStore (helps troubleshoot key loading issues)
807-
option(HDF5_PLUGIN_KEYSTORE_DEBUG "Enable debug output for plugin KeyStore initialization" OFF)
808-
809806
# Security: Disable environment variable override (prevents runtime keystore redirection)
810807
# Note: Sysadmins can also lock the keystore at runtime without recompiling by
811808
# creating a lock file (/etc/hdf5/lock_keystore on Unix, or
@@ -940,12 +937,6 @@ if (HDF5_REQUIRE_SIGNED_PLUGINS)
940937
# Enable digital signature verification
941938
add_compile_definitions(H5_REQUIRE_DIGITAL_SIGNATURE)
942939

943-
# Enable debug output if requested
944-
if (HDF5_PLUGIN_KEYSTORE_DEBUG)
945-
add_compile_definitions(H5PL_DEBUG_KEYSTORE)
946-
message(STATUS "Plugin KeyStore debug output: ENABLED")
947-
endif ()
948-
949940
# Security: Disable environment variable override if requested
950941
if (HDF5_LOCK_PLUGIN_KEYSTORE)
951942
add_compile_definitions(H5PL_DISABLE_ENV_KEYSTORE)

release_docs/PLUGIN_SIGNATURE_README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,8 @@ The current system makes conscious trade-offs:
11081108
export HDF5_PLUGIN_KEYSTORE=/tmp/fake_keystore
11091109

11101110
# Enable debug output to see which keystore is used
1111-
HDF5_PLUGIN_KEYSTORE_DEBUG=1 h5dump test_file.h5
1111+
export HDF5_DEBUG=PL
1112+
h5dump test_file.h5
11121113

11131114
# Expected output: "Skipping HDF5_PLUGIN_KEYSTORE environment variable (locked by sysadmin)"
11141115
```

src/H5.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ H5_init_library(void)
209209
H5_debug_g.pkg[H5_PKG_MM].name = "mm";
210210
H5_debug_g.pkg[H5_PKG_O].name = "o";
211211
H5_debug_g.pkg[H5_PKG_P].name = "p";
212+
H5_debug_g.pkg[H5_PKG_PL].name = "pl";
212213
H5_debug_g.pkg[H5_PKG_S].name = "s";
213214
H5_debug_g.pkg[H5_PKG_T].name = "t";
214215
H5_debug_g.pkg[H5_PKG_V].name = "v";

src/H5PLpkg.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,13 @@ typedef const void *(*H5PL_get_plugin_info_t)(void);
127127
#define H5PL_SIG_KEYSTORE_DIR_STR "(not configured)"
128128
#endif
129129

130-
/* Debug logging for keystore operations (enable via CMake: HDF5_PLUGIN_KEYSTORE_DEBUG) */
131-
#ifdef H5PL_DEBUG_KEYSTORE
132-
#define H5PL_SIG_DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
133-
#else
134-
#define H5PL_SIG_DEBUG_PRINT(...) /* no-op */
135-
#endif
130+
#define H5PL_SIG_DEBUG_PRINT(...) \
131+
do { \
132+
if (H5DEBUG(PL)) { \
133+
fprintf(H5DEBUG(PL), __VA_ARGS__); \
134+
fflush(H5DEBUG(PL)); \
135+
} \
136+
} while (0)
136137

137138
#endif /* H5_REQUIRE_DIGITAL_SIGNATURE */
138139

src/H5PLsig.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,6 @@ H5PL__init_keystore(void)
971971
attempted_source);
972972
}
973973

974-
#ifdef H5PL_DEBUG_KEYSTORE
975-
/* Optional debug output (enable via compile-time flag) */
976974
if (H5PL_keystore_count_g > 0) {
977975
H5PL_SIG_DEBUG_PRINT("HDF5 Plugin KeyStore initialized:\n");
978976
H5PL_SIG_DEBUG_PRINT(" Keys loaded: %zu\n", H5PL_keystore_count_g);
@@ -983,7 +981,6 @@ H5PL__init_keystore(void)
983981
if (H5PL_revoked_sigs_count_g > 0) {
984982
H5PL_SIG_DEBUG_PRINT(" Revoked signatures loaded: %zu\n", H5PL_revoked_sigs_count_g);
985983
}
986-
#endif
987984

988985
done:
989986
/* Cleanup on initialization failure */
@@ -1610,7 +1607,7 @@ H5PL__verify_with_all_keys(int fd, size_t binary_size, const unsigned char *sign
16101607
else {
16111608
diagnostic = "\n"
16121609
" DIAGNOSIS: Unknown verification failure\n"
1613-
" - Enable HDF5_PLUGIN_KEYSTORE_DEBUG for detailed logging\n";
1610+
" - Enable debug output with: export HDF5_DEBUG=PL\n";
16141611
}
16151612

16161613
keystore_path = getenv("HDF5_PLUGIN_KEYSTORE");

src/H5private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ typedef enum {
984984
H5_PKG_MM, /* Core memory management */
985985
H5_PKG_O, /* Object headers */
986986
H5_PKG_P, /* Property lists */
987+
H5_PKG_PL, /* Plugins */
987988
H5_PKG_S, /* Dataspaces */
988989
H5_PKG_T, /* Datatypes */
989990
H5_PKG_V, /* Vector functions */

0 commit comments

Comments
 (0)