Commit Graph

25 Commits

Author SHA1 Message Date
countgitmick
b5d70d2ffb make-initrd-ng: suppress spurious glibc dependency warnings
In Nix, glibc libraries lack rpath entries pointing to themselves,
so libc.so.6 and ld-linux-*.so.* can never be resolved through rpath
alone during initrd generation. They are always present in the initrd
through other paths (the ELF interpreter and other binaries' rpath
entries).

The scripted initrd builder (stage-1.nix findLibs) already skips
ld*.so.? for the same reason. This brings make-initrd-ng in line
with that precedent.

Also removes two unused imports (PermissionsExt, Command) and moves
the remaining warning output from stdout to stderr.

Closes #463894
Closes #282145
Closes #399281
2026-04-08 15:44:53 -07:00
Ben Siraphob
c7e10647ea treewide: fix typos 2026-01-13 14:45:11 -05:00
Gerg-L
98313e2b81 nixos/systemd-initrd: deprecate strip
It only saved ~1MiB of initramfs size, but caused a few issues
like unloadable kernel modules.
2025-05-08 19:08:14 -04:00
r-vdp
a9c75e7689 make-initrd-ng: fix file permissions
We want to strip the write bit from files after we copied them.
XOR is not the right operator for this, since if the bit is 0 in both
the actual permissions and the mask, then the result will be a 1.
So in practice, we were assigning write permissions for group and others
to all files and we were only stripping the write permissions of the
owner (since the owner had write permissions, and so the result of the
XOR is 0).

The correct thing to do is to AND with the maximum permissions that we
want to maintain (which is the inverse of what we want to strip), so
that only those bits are preserved and the others are always set to 0.
2025-05-08 12:13:50 +02:00
sudoBash418
93b98639dd make-initrd-ng: Restore stripped file permissions
Previously, all initrd ELFs would be made *world-writable*.

This commit sets the write bit for the file owner exclusively, and
removes it when done. It also sets the umask so that files don't
implicitly become writable for other users by mistake.

Fixes: https://github.com/NixOS/nixpkgs/security/advisories/GHSA-m7pq-h9p4-8rr4
Reported-By: sudoBash418 <sudobash418@gmail.com>
2025-04-13 12:02:16 -04:00
Jörg Thalheim
3de4714572 make-initrd-ng: also print json itself if it fails to parse
The current error message is hard to debug because the error is in the
nix store:

> Error: failed to parse JSON in
"/build/.attr-1s42g1c76fxb77skzq0b4wdhcrg8jmzb54czmxvh1qm7psgsbcni"
>
> Caused by:
> missing field `source` at line 1 column 102
>
> Location:
> src/main.rs:329:10
2024-08-02 10:24:34 +02:00
Will Fancher
6f959a9e96 nixos/make-initrd-ng: dlopen ELF notes 2024-07-21 06:31:42 -04:00
Will Fancher
e6c544270c nixos/make-initrd-ng: Pass contents as JSON 2024-07-21 06:31:42 -04:00
R. Ryantm
2214a3f6e4 makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-02-12 05:11:50 +00:00
R. Ryantm
d4e775bd1a makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-01-25 13:37:20 +00:00
R. Ryantm
19b4bac3d0 makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-01-07 10:39:28 +00:00
R. Ryantm
5ff7811393 makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-01-01 20:10:05 +00:00
R. Ryantm
d2ffb24948 makeInitrdNGTool: 0.1.0 -> 0.1.0 2023-12-16 14:58:17 +00:00
R. Ryantm
8c15911d79 makeInitrdNGTool: 0.1.0 -> 0.1.0 2023-11-23 13:26:47 +00:00
Will Fancher
18013cc71e systemd-stage-1: Use specific fs packages 2023-10-19 21:13:22 -04:00
R. Ryantm
3876a545ed makeInitrdNGTool: 0.1.0 -> 0.1.0 2023-10-11 02:44:30 +00:00
Cole Helbling
3e63608c7b makeInitrdNGTool: better errors
It's extremely frustrating seeing "Error: Os { code: 13, kind:
PermissionDenied, message: "Permission denied" }" without any hint as to
where exactly that occurred.

This commit fixes that by adding context to most errors.
2023-05-25 13:26:05 -07:00
Lily Foster
d01bc6f9cb make-initrd-ng: document wrapped file behavior 2023-02-20 07:02:55 -05:00
Lily Foster
4df8f9a2f8 make-initrd-ng: support wrapped executables 2023-02-20 07:02:55 -05:00
Linus Heckemann
ee38010981 makeInitrdNG: add meta and update script 2022-08-02 10:54:55 +03:00
Linus Heckemann
6fc909a1cc makeInitrdNG: make stripping fully optional
Now the tool will only strip binaries if a strip executable is passed
via the STRIP environment variable. This is exposed via the strip
option for makeInitrdNG and the NixOS option boot.initrd.systemd.strip.
2022-08-02 10:19:48 +03:00
K900
daee67dae6 make-initrd-ng: use goblin instead of shelling out to patchelf and friends 2022-08-02 10:19:48 +03:00
K900
1356441cb1 make-initrd-ng: rustfmt 2022-08-02 10:19:48 +03:00
Janne Heß
e5995b2235 makeInitrdNG: Strip more and remove output
This strips all elf files as far as possible and removes a lot of
unnecessary output. Also wrap in the binaries instead of relying on
$PATH.
2022-05-01 17:06:14 +02:00
Will Fancher
d193ef8a57 make-initrd-ng: init 2022-03-22 07:02:22 -04:00