aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/derivation-goal.cc
diff options
context:
space:
mode:
authorArtemis Tosini <lix@artem.ist>2024-05-19 22:07:58 +0000
committerArtemis Tosini <lix@artem.ist>2024-05-19 22:07:58 +0000
commit5411fbf20467c5dd561048311519056688b1154d (patch)
tree96f46127cb5c10d16a77633fe836b6858c4b0876 /src/libstore/build/derivation-goal.cc
parent139d31f87658c420622f6880a4bdfee8b522f87c (diff)
libutil: Create chmodPath function
Move the identical static `chmod_` functions in libstore to libutil. the function is called `chmodPath` instead of `chmod` as otherwise it will shadow the standard library chmod in the nix namespace, which is somewhat confusing. Change-Id: I7b5ce379c6c602e3d3a1bbc49dbb70b1ae8f7bad
Diffstat (limited to 'src/libstore/build/derivation-goal.cc')
-rw-r--r--src/libstore/build/derivation-goal.cc11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index 3f24da276..5fa5deb7c 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -786,13 +786,6 @@ void DerivationGoal::tryLocalBuild() {
}
-static void chmod_(const Path & path, mode_t mode)
-{
- if (chmod(path.c_str(), mode) == -1)
- throw SysError("setting permissions on '%s'", path);
-}
-
-
/* Move/rename path 'src' to 'dst'. Temporarily make 'src' writable if
it's a directory and we're not root (to be able to update the
directory's parent link ".."). */
@@ -803,12 +796,12 @@ static void movePath(const Path & src, const Path & dst)
bool changePerm = (geteuid() && S_ISDIR(st.st_mode) && !(st.st_mode & S_IWUSR));
if (changePerm)
- chmod_(src, st.st_mode | S_IWUSR);
+ chmodPath(src, st.st_mode | S_IWUSR);
renameFile(src, dst);
if (changePerm)
- chmod_(dst, st.st_mode);
+ chmodPath(dst, st.st_mode);
}