mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
escapeSystemdPath relied on lib.strings.normalizePath, which only
collapses duplicate slashes and does not drop "." path components the
way systemd's path_simplify() does. A path like /mnt/./foo was thus
escaped to mnt-.-foo instead of mnt-foo, and systemd refused the
generated unit ("Where= setting doesn't match unit name").
Reimplement the simplification to match `systemd-escape --path` exactly:
drop "." and empty components, collapse a leading ".." run in an
absolute path to the root, and throw on any input systemd-escape
rejects (a non-leading "..", or a relative path that reduces to
nothing). Parity is checked against the systemd-escape binary over a
battery of edge cases and fuzzed inputs. While here, hoist the constant
escape table and partial applications out of the per-call lambda so
they are built once rather than on every call, making the function
~2.5x faster.
Resolves: https://github.com/NixOS/nixpkgs/issues/515270
Assisted-by: Claude:claude-opus-4-8
(cherry picked from commit
|
||
|---|---|---|
| .. | ||
| make-options-doc | ||
| test-driver | ||
| testing | ||
| binfmt-magics.nix | ||
| default.nix | ||
| eval-cacheable-options.nix | ||
| eval-config-minimal.nix | ||
| eval-config.nix | ||
| from-env.nix | ||
| make-btrfs-fs.nix | ||
| make-channel.nix | ||
| make-disk-image.nix | ||
| make-ext4-fs.nix | ||
| make-iso9660-image.nix | ||
| make-iso9660-image.sh | ||
| make-multi-disk-zfs-image.nix | ||
| make-single-disk-zfs-image.nix | ||
| make-squashfs.nix | ||
| make-system-tarball.nix | ||
| make-system-tarball.sh | ||
| qemu-common.nix | ||
| systemd-lib.nix | ||
| systemd-network-units.nix | ||
| systemd-types.nix | ||
| systemd-unit-options.nix | ||
| test-script-prepend.py | ||
| testing-python.nix | ||
| utils.nix | ||