about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07T15·18+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07T15·18+0000
commita0a43c32062f756b32feca7d04e89fb5d01767db (patch)
treee1236e717e1e59b06ae8248fbfac7a8f702a94a3 /src/libstore/local-store.cc
parent6a07ff1ec068c6255d45644eb182dea5c0027286 (diff)
* When not running as root, call the setuid helper to change the
  ownership of the build result after the build.

Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index c1fcb035bc82..143f093e5bac 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -223,6 +223,12 @@ void canonicalisePathMetaData(const Path & path)
 
     if (!S_ISLNK(st.st_mode)) {
 
+        if (st.st_uid != geteuid()) {
+            if (chown(path.c_str(), geteuid(), -1) == -1)
+                throw SysError(format("changing owner of `%1%' to %2%")
+                    % path % geteuid());
+        }
+
         /* Mask out all type related bits. */
         mode_t mode = st.st_mode & ~S_IFMT;
         
@@ -234,12 +240,6 @@ void canonicalisePathMetaData(const Path & path)
                 throw SysError(format("changing mode of `%1%' to %2$o") % path % mode);
         }
 
-        if (st.st_uid != geteuid() || st.st_gid != getegid()) {
-            if (chown(path.c_str(), geteuid(), getegid()) == -1)
-                throw SysError(format("changing owner/group of `%1%' to %2%/%3%")
-                    % path % geteuid() % getegid());
-        }
-
         if (st.st_mtime != 0) {
             struct utimbuf utimbuf;
             utimbuf.actime = st.st_atime;