libstore: make diff-hooks work for non-root users
it's kind of weird to not allow diff-hooks in single user mode unless that user is root. maybe that's why we have no tests for them? we can at least add a test that diff hooks are run at all when we expect it. Change-Id: I54d623b5416acda1c205cc062b0f3a33c9f4aaa7
This commit is contained in:
@@ -72,8 +72,8 @@
|
||||
namespace nix {
|
||||
|
||||
static kj::Promise<Result<void>> handleDiffHook(
|
||||
uid_t uid,
|
||||
uid_t gid,
|
||||
std::optional<uid_t> uid,
|
||||
std::optional<uid_t> gid,
|
||||
const Path & tryA,
|
||||
const Path & tryB,
|
||||
const Path & drvPath,
|
||||
@@ -1773,8 +1773,8 @@ try {
|
||||
movePath(actualPath, dst);
|
||||
|
||||
TRY_AWAIT(handleDiffHook(
|
||||
buildUser ? buildUser->getUID() : getuid(),
|
||||
buildUser ? buildUser->getGID() : getgid(),
|
||||
buildUser ? std::optional(buildUser->getUID()) : std::nullopt,
|
||||
buildUser ? std::optional(buildUser->getGID()) : std::nullopt,
|
||||
finalDestPath,
|
||||
dst,
|
||||
worker.store.printStorePath(drvPath),
|
||||
|
||||
@@ -139,3 +139,11 @@ nix-store -q --references "$obtained" >/dev/null
|
||||
nix-build check.nix -A nondeterministic --no-out-link
|
||||
nix-build check.nix -A nondeterministic -A hashmismatch --no-out-link --check --keep-going || status=$?
|
||||
[ "$status" = "110" ]
|
||||
|
||||
|
||||
# basic check that diff hooks are started at all
|
||||
STDERR=$(expectStderr 104 nix-build check.nix -A nondeterministic \
|
||||
--diff-hook "$PWD/diff-hook.sh" \
|
||||
--run-diff-hook \
|
||||
--check 2>&1)
|
||||
grep "diff-hook ran" <<<"$STDERR"
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo diff-hook ran
|
||||
Reference in New Issue
Block a user