Merge pull request #114080 from baloo/baloo/tpm2-pytss/init
This commit is contained in:
commit
3ede9d8c5c
@ -27,7 +27,21 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
enableParallelBuilding = true;
|
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 = [
|
configureFlags = [
|
||||||
"--enable-unit"
|
"--enable-unit"
|
||||||
@ -35,6 +49,14 @@ stdenv.mkDerivation rec {
|
|||||||
];
|
];
|
||||||
|
|
||||||
doCheck = true;
|
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 = ''
|
postInstall = ''
|
||||||
# Do not install the upstream udev rules, they rely on specific
|
# 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.");
|
41
pkgs/development/python-modules/tpm2-pytss/default.nix
Normal file
41
pkgs/development/python-modules/tpm2-pytss/default.nix
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{ lib, buildPythonPackage, fetchPypi, pythonOlder
|
||||||
|
, pkg-config, swig
|
||||||
|
, tpm2-tss
|
||||||
|
, cryptography, ibm-sw-tpm2
|
||||||
|
}:
|
||||||
|
|
||||||
|
buildPythonPackage rec {
|
||||||
|
pname = "tpm2-pytss";
|
||||||
|
|
||||||
|
# Last version on github is 0.2.4, but it looks
|
||||||
|
# like a mistake (it's missing commits from 0.1.9)
|
||||||
|
version = "0.1.9";
|
||||||
|
disabled = pythonOlder "3.5";
|
||||||
|
|
||||||
|
src = fetchPypi {
|
||||||
|
inherit pname version;
|
||||||
|
sha256 = "sha256-v5Xth0A3tFnLFg54nvWYL2TD201e/GWv+2y5Qc60CmU=";
|
||||||
|
};
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace tpm2_pytss/config.py --replace \
|
||||||
|
'SYSCONFDIR = CONFIG.get("sysconfdir", "/etc")' \
|
||||||
|
'SYSCONFDIR = "${tpm2-tss}/etc"'
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [ pkg-config swig ];
|
||||||
|
# The TCTI is dynamically loaded from tpm2-tss, we have to provide the library to the end-user
|
||||||
|
propagatedBuildInputs = [ tpm2-tss ];
|
||||||
|
|
||||||
|
checkInputs = [
|
||||||
|
cryptography
|
||||||
|
# provide tpm_server used as simulator for the tests
|
||||||
|
ibm-sw-tpm2
|
||||||
|
];
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = "https://github.com/tpm2-software/tpm2-pytss";
|
||||||
|
description = "TPM2 TSS Python bindings for Enhanced System API (ESYS)";
|
||||||
|
license = licenses.bsd2;
|
||||||
|
maintainers = with maintainers; [ baloo ];
|
||||||
|
};
|
||||||
|
}
|
@ -7954,6 +7954,8 @@ in {
|
|||||||
|
|
||||||
tox = callPackage ../development/python-modules/tox { };
|
tox = callPackage ../development/python-modules/tox { };
|
||||||
|
|
||||||
|
tpm2-pytss = callPackage ../development/python-modules/tpm2-pytss { };
|
||||||
|
|
||||||
tqdm = callPackage ../development/python-modules/tqdm { };
|
tqdm = callPackage ../development/python-modules/tqdm { };
|
||||||
|
|
||||||
traceback2 = callPackage ../development/python-modules/traceback2 { };
|
traceback2 = callPackage ../development/python-modules/traceback2 { };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user