tpm-tss2: do not rely on a dynamic load path for tcti modules
Signed-off-by: Arthur Gautier <baloo@superbaloo.net>
This commit is contained in:
parent
fc4fa2847c
commit
eea5575bd3
2 changed files with 62 additions and 1 deletions
|
@ -27,7 +27,21 @@ stdenv.mkDerivation rec {
|
|||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postPatch = "patchShebangs script";
|
||||
patches = [
|
||||
# Do not rely on dynamic loader path
|
||||
# TCTI loader relies on dlopen(), this patch prefixes all calls with the output directory
|
||||
./no-dynamic-loader-path.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs script
|
||||
substituteInPlace src/tss2-tcti/tctildr-dl.c \
|
||||
--replace '@PREFIX@' $out/lib/
|
||||
substituteInPlace ./test/unit/tctildr-dl.c \
|
||||
--replace ', "libtss2' ", \"$out/lib/libtss2" \
|
||||
--replace ', "foo' ", \"$out/lib/foo" \
|
||||
--replace ', TEST_TCTI_NAME' ", \"$out/lib/\"TEST_TCTI_NAME"
|
||||
'';
|
||||
|
||||
configureFlags = [
|
||||
"--enable-unit"
|
||||
|
@ -35,6 +49,14 @@ stdenv.mkDerivation rec {
|
|||
];
|
||||
|
||||
doCheck = true;
|
||||
preCheck = ''
|
||||
# Since we rewrote the load path in the dynamic loader for the TCTI
|
||||
# The various tcti implementation should be placed in their target directory
|
||||
# before we could run tests
|
||||
installPhase
|
||||
# install already done, dont need another one
|
||||
dontInstall=1
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
# Do not install the upstream udev rules, they rely on specific
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
diff --git a/src/tss2-tcti/tctildr-dl.c b/src/tss2-tcti/tctildr-dl.c
|
||||
index b364695c..b13be3ef 100644
|
||||
--- a/src/tss2-tcti/tctildr-dl.c
|
||||
+++ b/src/tss2-tcti/tctildr-dl.c
|
||||
@@ -85,7 +85,15 @@ handle_from_name(const char *file,
|
||||
if (handle == NULL) {
|
||||
return TSS2_TCTI_RC_BAD_REFERENCE;
|
||||
}
|
||||
- *handle = dlopen(file, RTLD_NOW);
|
||||
+ size = snprintf(file_xfrm,
|
||||
+ sizeof (file_xfrm),
|
||||
+ "@PREFIX@%s",
|
||||
+ file);
|
||||
+ if (size >= sizeof (file_xfrm)) {
|
||||
+ LOG_ERROR("TCTI name truncated in transform.");
|
||||
+ return TSS2_TCTI_RC_BAD_VALUE;
|
||||
+ }
|
||||
+ *handle = dlopen(file_xfrm, RTLD_NOW);
|
||||
if (*handle != NULL) {
|
||||
return TSS2_RC_SUCCESS;
|
||||
} else {
|
||||
@@ -94,7 +102,7 @@ handle_from_name(const char *file,
|
||||
/* 'name' alone didn't work, try libtss2-tcti-<name>.so.0 */
|
||||
size = snprintf(file_xfrm,
|
||||
sizeof (file_xfrm),
|
||||
- TCTI_NAME_TEMPLATE_0,
|
||||
+ "@PREFIX@" TCTI_NAME_TEMPLATE_0,
|
||||
file);
|
||||
if (size >= sizeof (file_xfrm)) {
|
||||
LOG_ERROR("TCTI name truncated in transform.");
|
||||
@@ -109,7 +117,7 @@ handle_from_name(const char *file,
|
||||
/* libtss2-tcti-<name>.so.0 didn't work, try libtss2-tcti-<name>.so */
|
||||
size = snprintf(file_xfrm,
|
||||
sizeof (file_xfrm),
|
||||
- TCTI_NAME_TEMPLATE,
|
||||
+ "@PREFIX@" TCTI_NAME_TEMPLATE,
|
||||
file);
|
||||
if (size >= sizeof (file_xfrm)) {
|
||||
LOG_ERROR("TCTI name truncated in transform.");
|
Loading…
Reference in a new issue