diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2026-05-30 23:54:05 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2026-08-17 16:47:36 +0200 |
| commit | 64d4de2a920445e5992f020e56490f5fcbdbba7c (patch) | |
| tree | a869360b32fbc5fb0f49d297708ddde801aa3a95 /nix/libutil/util.cc | |
| parent | 8cb871e0c69030599fa8e8410f1ecaee21ddbbd0 (diff) | |
daemon: Bypass authentication when importing content-addressed store items.
This puts ‘importPaths’ on par with ‘addToStore’ and ‘addTextToStore’: since
the two latter RPCs let anyone add content-addressed items in the store,
there’s no reason for ‘importPaths’ to require signatures by authorized keys
on these content-addressed items.
This will allow for things like ‘guix copy’ of .drv items without
authorization, or ‘guix deploy’ with (build-locally? #f) without
authorization.
* nix/libstore/store-api.hh (isContentAddressedPath): New prototype.
* nix/libstore/store-api.cc (isContentAddressedPath): New function.
* nix/libutil/util.hh (isPlainFile): New prototype.
* nix/libutil/util.cc (isPlainFile): New function.
* nix/libstore/local-store.cc (LocalStore::importPath): Define ‘narHash’ and
‘contentAddressed’. Allow unsigned imports when ‘contentAddressed’ is true;
bypass signature verification when ‘contentAddressed’ is true.
* tests/store.scm ("import not signed"): Rewrite to not use a
content-addressed store item.
("import signed by unauthorized key"): Likewise.
("import not signed but content-addressed tree"): New test.
("import not signed but content-addressed regular file"): New test.
("import signed by unauthorized key but content-addressed"): New test.
("import with corrupt signature"): New test.
("import signed by authorized key but hash doesn't match"): New test.
("import with corrupt signature but content-addressed"): New test.
("import signed by authorized key, hash doesn't match, but content-addressed"):
New test.
* doc/guix.texi (Invoking guix archive): Document the exception for
content-addressed store items. Add anchor for ‘--authorize’.
(Invoking guix deploy): Document the benefit of (build-locally? #f).
Add cross-reference for ‘authorize?’.
Co-authored-by: Reepca Russelstein <reepca@russelstein.xyz>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #8979
Diffstat (limited to 'nix/libutil/util.cc')
| -rw-r--r-- | nix/libutil/util.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 95f293ff10f..72c8d38bd50 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc | |||
| @@ -287,6 +287,13 @@ unsigned char getFileType(const Path & path) | |||
| 287 | return DT_UNKNOWN; | 287 | return DT_UNKNOWN; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | bool isPlainFile(const Path & path) | ||
| 291 | { | ||
| 292 | struct stat st = lstat(path); | ||
| 293 | return S_ISREG(st.st_mode) | ||
| 294 | && ((st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0); | ||
| 295 | } | ||
| 296 | |||
| 290 | 297 | ||
| 291 | string readFile(int fd) | 298 | string readFile(int fd) |
| 292 | { | 299 | { |
