Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions pkgs/os-specific/linux/cryptsetup/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{ lib, stdenv, fetchurl, lvm2, json_c
, openssl, libuuid, pkg-config, popt }:
{ lib
, stdenv
, fetchurl
, lvm2
, json_c
, openssl
, libuuid
, pkg-config
, popt
}:

stdenv.mkDerivation rec {
pname = "cryptsetup";
Expand All @@ -13,8 +21,12 @@ stdenv.mkDerivation rec {
sha256 = "sha256-/A35RRiBciZOxb8dC9oIJk+tyKP4VtR+upHzH+NUtQc=";
};

# Disable 4 test cases that fail in a sandbox
patches = [ ./disable-failing-tests.patch ];
patches = [
# Disable 4 test cases that fail in sandbox
./disable-failing-tests.patch
# Allow reading tokens from a relative path, see #167994
./relative-token-path.patch
];

postPatch = ''
patchShebangs tests
Expand Down
18 changes: 18 additions & 0 deletions pkgs/os-specific/linux/cryptsetup/relative-token-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/lib/luks2/luks2_token.c b/lib/luks2/luks2_token.c
index 88d84418..ed3a079b 100644
--- a/lib/luks2/luks2_token.c
+++ b/lib/luks2/luks2_token.c
@@ -151,12 +151,10 @@ crypt_token_load_external(struct crypt_device *cd, const char *name, struct cryp

token = &ret->u.v2;

- r = snprintf(buf, sizeof(buf), "%s/libcryptsetup-token-%s.so", crypt_token_external_path(), name);
+ r = snprintf(buf, sizeof(buf), "libcryptsetup-token-%s.so", name);
if (r < 0 || (size_t)r >= sizeof(buf))
return -EINVAL;

- assert(*buf == '/');
-
log_dbg(cd, "Trying to load %s.", buf);

h = dlopen(buf, RTLD_LAZY);
12 changes: 11 additions & 1 deletion pkgs/os-specific/linux/systemd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
, fetchpatch
, fetchzip
, buildPackages
, makeBinaryWrapper
, ninja
, meson
, m4
Expand Down Expand Up @@ -353,6 +354,7 @@ stdenv.mkDerivation {
nativeBuildInputs =
[
pkg-config
makeBinaryWrapper
gperf
ninja
meson
Expand Down Expand Up @@ -671,7 +673,15 @@ stdenv.mkDerivation {
preFixup = lib.optionalString withEfi ''
mv $out/lib/systemd/boot/efi $out/dont-strip-me
'';
postFixup = lib.optionalString withEfi ''

# Wrap in the correct path for LUKS2 tokens. Must be after the fixup phase
# or the rpath cleanup removes the directories again.
postFixup = lib.optionalString withCryptsetup ''
for f in lib/systemd/systemd-cryptsetup bin/systemd-cryptenroll; do
# This needs to be in LD_LIBRARY_PATH because rpath on a binary is not propagated to libraries using dlopen, in this case `libcryptsetup.so`
wrapProgram $out/$f --prefix LD_LIBRARY_PATH : ${placeholder "out"}/lib/cryptsetup
done
'' + lib.optionalString withEfi ''
mv $out/dont-strip-me $out/lib/systemd/boot/efi
'';

Expand Down