Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-store --repair-path should not delete path before replacing it #6849

Open
lheckemann opened this issue Jul 31, 2022 · 0 comments
Open

nix-store --repair-path should not delete path before replacing it #6849

lheckemann opened this issue Jul 31, 2022 · 0 comments
Labels

Comments

@lheckemann
Copy link
Member

Describe the bug

This operations work on the store paths in place. This can be a problem if operating on store paths that Nix itself needs in order to perform the operation:

[root@tmp:~]# readlink -f /etc/ssl/certs/ca-bundle.crt
/nix/store/5xcgrpb8x4qrbsz56afsfnqvdaq24dx0-nss-cacert-3.77/etc/ssl/certs/ca-bundle.crt

[root@tmp:~]# nix-store --repair-path /nix/store/5xcgrpb8x4qrbsz56afsfnqvdaq24dx0-nss-cacert-3.77/etc/ssl/certs/ca-bundle.crt
copying path '/nix/store/5xcgrpb8x4qrbsz56afsfnqvdaq24dx0-nss-cacert-3.77' from 'https://cache.nixos.org'...
error: unable to download 'https://cache.nixos.org/nar/0lmk54fn95xnln14msnph4gwzscfy2ini7av85iy9lz057n3phdx.nar.xz': Problem with the SSL CA cert (path? access rights?) (77)
error: cannot repair path '/nix/store/5xcgrpb8x4qrbsz56afsfnqvdaq24dx0-nss-cacert-3.77'

This deletes the contents of the path recursively before starting to fetch the replacement. The new path should IMHO be fetched to a different location and renamed into place afterwards (renameat2 with RENAME_EXCHANGE would be ideal here, wherever available, to avoid a window where the path does not exist).

Steps To Reproduce

  1. Try repairing the in-use cacert path.

Expected behavior

The cacert path is repaired without any problems.

nix-env --version output

Tested on:

  • nix-env (Nix) 2.8.1
@lheckemann lheckemann added the bug label Jul 31, 2022
@lheckemann lheckemann changed the title nix-store --repair-path operates in-place nix-store --repair-path should not delete path before replacing it Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant